From dc5f68cad3c8ee4c583acf9afbfdb7354cd3d6af Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 25 May 2000 23:31:54 +0000 Subject: [PATCH] ChangeLog, getsize.c, llseek.c, unix_io.c: getsize.c (ext2fs_get_device_size): Use open64() instead of open() if it exists. unix_io.c (unix_open): Use open64() instead of open() if it exists. llseek.c: Simplify header includes of unistd.h. If lseek64 is available (and prototypes are defined) use it in preference to llseek. --- lib/ext2fs/ChangeLog | 10 ++++++++++ lib/ext2fs/getsize.c | 7 +++++++ lib/ext2fs/llseek.c | 18 +++++++++++------- lib/ext2fs/unix_io.c | 11 ++++++++++- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 9bcb2ec8..bfd3bf12 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,5 +1,15 @@ 2000-05-25 + * getsize.c (ext2fs_get_device_size): Use open64() instead of + open() if it exists. + + * unix_io.c (unix_open): Use open64() instead of open() if it + exists. + + * llseek.c: Simplify header includes of unistd.h. If lseek64 is + available (and prototypes are defined) use it in + preference to llseek. + * Makefile: Add hack dependency rule so that parallel makes work correctly. diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c index b92ce8d8..7f805b4d 100644 --- a/lib/ext2fs/getsize.c +++ b/lib/ext2fs/getsize.c @@ -9,6 +9,9 @@ * %End-Header% */ +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE + #include #if HAVE_UNISTD_H #include @@ -66,7 +69,11 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize, char ch; #endif /* HAVE_SYS_DISKLABEL_H */ +#ifdef HAVE_OPEN64 + fd = open64(file, O_RDONLY); +#else fd = open(file, O_RDONLY); +#endif if (fd < 0) return errno; diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c index d75f42db..27348d9c 100644 --- a/lib/ext2fs/llseek.c +++ b/lib/ext2fs/llseek.c @@ -9,6 +9,9 @@ * %End-Header% */ +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE + #if HAVE_SYS_TYPES_H #include #endif @@ -27,10 +30,11 @@ #ifdef __linux__ -#ifdef HAVE_LLSEEK -#if HAVE_UNISTD_H -#include -#endif +#if defined(HAVE_LSEEK64) && defined(HAVE_LSEEK64_PROTOTYPE) + +#define my_llseek lseek64 + +#elif defined(HAVE_LLSEEK) #include #ifndef HAVE_LLSEEK_PROTOTYPE @@ -39,7 +43,7 @@ extern long long llseek (int fd, long long offset, int origin); #define my_llseek llseek -#else /* HAVE_LLSEEK */ +#else /* ! HAVE_LLSEEK */ #ifdef __alpha__ @@ -77,9 +81,9 @@ static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin) return (retval == -1 ? (ext2_loff_t) retval : result); } -#endif /* HAVE_LLSEEK */ +#endif /* __alpha__ */ -#endif /* __alpha__ */ +#endif /* HAVE_LLSEEK */ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin) { diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index c46602e8..e0cc4db4 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -11,6 +11,9 @@ * %End-Header% */ +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE + #include #include #if HAVE_UNISTD_H @@ -78,6 +81,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) io_channel io = NULL; struct unix_private_data *data = NULL; errcode_t retval; + int open_flags; if (name == 0) return EXT2_ET_BAD_DEVICE_NAME; @@ -111,7 +115,12 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) if (retval) goto cleanup; - data->dev = open(name, (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY); + open_flags = (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY; +#ifdef HAVE_OPEN64 + data->dev = open64(name, open_flags); +#else + data->dev = open(name, open_flags); +#endif if (data->dev < 0) { retval = errno; goto cleanup; -- 2.11.0