From ae3fe1baa3849d43869390b28e97a96009d702eb Mon Sep 17 00:00:00 2001 From: Frank Chen Date: Fri, 24 Oct 2014 07:44:32 +0000 Subject: PD #100988 off_t --> loff_t to fix >2G file access Change-Id: I712a53e0645d971e917147517bd18e8b4dd7653b --- diff --git a/config.h b/config.h index f34630b..1fe90de 100644 --- a/config.h +++ b/config.h @@ -1,3 +1,4 @@ +#include /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ @@ -412,6 +413,11 @@ /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _FILE_OFFSET_BITS */ +#ifndef _OFF_T_DEFINED_ +#define _OFF_T_DEFINED_ +#define off_t loff_t +#endif + /* Define for large files, on AIX-style hosts. */ /* #undef _LARGE_FILES */ diff --git a/libntfs-3g/unix_io.c b/libntfs-3g/unix_io.c index 4f2c18b..799db0b 100755 --- a/libntfs-3g/unix_io.c +++ b/libntfs-3g/unix_io.c @@ -61,10 +61,14 @@ #include "logging.h" #include "misc.h" +#ifdef __USE_FILE_OFFSET64 +#include +#endif + #define DEV_FD(dev) (*(int *)dev->d_private) #ifdef __USE_FILE_OFFSET64 -#include +#define fcntl __fcntl64 #endif /* Define to nothing if not present on this system. */ @@ -227,7 +231,11 @@ static int ntfs_device_unix_io_close(struct ntfs_device *dev) static s64 ntfs_device_unix_io_seek(struct ntfs_device *dev, s64 offset, int whence) { +#ifdef __USE_FILE_OFFSET64 return lseek64(DEV_FD(dev), offset, whence); +#else + return lseek(DEV_FD(dev), offset, whence); +#endif } /** @@ -281,7 +289,11 @@ static s64 ntfs_device_unix_io_write(struct ntfs_device *dev, const void *buf, static s64 ntfs_device_unix_io_pread(struct ntfs_device *dev, void *buf, s64 count, s64 offset) { +#ifdef __USE_FILE_OFFSET64 return pread64(DEV_FD(dev), buf, count, offset); +#else + return pread(DEV_FD(dev), buf, count, offset); +#endif } /** @@ -303,7 +315,11 @@ static s64 ntfs_device_unix_io_pwrite(struct ntfs_device *dev, const void *buf, return -1; } NDevSetDirty(dev); +#ifdef __USE_FILE_OFFSET64 return pwrite64(DEV_FD(dev), buf, count, offset); +#else + return pwrite(DEV_FD(dev), buf, count, offset); +#endif } /** -- cgit