Whamcloud - gitweb
libext2fs: don't hang in ext2fs_new_block2() on a full bigalloc file system
[tools/e2fsprogs.git] / lib / ext2fs / unix_io.c
index 82e0fe4..c1d0561 100644 (file)
@@ -17,7 +17,9 @@
 
 #define _LARGEFILE_SOURCE
 #define _LARGEFILE64_SOURCE
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include <stdio.h>
 #include <string.h>
@@ -159,12 +161,13 @@ static errcode_t unix_get_stats(io_channel channel, io_stats *stats)
 static errcode_t raw_read_blk(io_channel channel,
                              struct unix_private_data *data,
                              unsigned long long block,
-                             int count, void *buf)
+                             int count, void *bufv)
 {
        errcode_t       retval;
        ssize_t         size;
        ext2_loff_t     location;
        int             actual = 0;
+       unsigned char   *buf = bufv;
 
        size = (count < 0) ? -count : count * channel->block_size;
        data->io_stats.bytes_read += size;
@@ -219,12 +222,13 @@ error_out:
 static errcode_t raw_write_blk(io_channel channel,
                               struct unix_private_data *data,
                               unsigned long long block,
-                              int count, const void *buf)
+                              int count, const void *bufv)
 {
        ssize_t         size;
        ext2_loff_t     location;
        int             actual = 0;
        errcode_t       retval;
+       const unsigned char *buf = bufv;
 
        if (count == 1)
                size = channel->block_size;
@@ -472,8 +476,10 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
        open_flags = (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY;
        if (flags & IO_FLAG_EXCLUSIVE)
                open_flags |= O_EXCL;
+#ifdef O_DIRECT
        if (flags & IO_FLAG_DIRECT_IO)
                open_flags |= O_DIRECT;
+#endif
        data->flags = flags;
 
 #ifdef HAVE_OPEN64