diff options
author | Karel Zak <kzak@redhat.com> | 2006-12-07 00:25:33 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2006-12-07 00:25:33 +0100 |
commit | 726f69e29ca9d4842f3acb20fffd2466fda62c09 (patch) | |
tree | abbc1b6e9bfb0dfe32e81a83648e261ccb2d5a5f /disk-utils/llseek.c | |
parent | 6dbe3af945a63f025561abb83275cee9ff06c57b (diff) | |
download | util-linux-old-726f69e29ca9d4842f3acb20fffd2466fda62c09.tar.gz |
Imported from util-linux-2.5 tarball.
Diffstat (limited to 'disk-utils/llseek.c')
-rw-r--r-- | disk-utils/llseek.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/disk-utils/llseek.c b/disk-utils/llseek.c index 66166d3a..3e59ec95 100644 --- a/disk-utils/llseek.c +++ b/disk-utils/llseek.c @@ -5,16 +5,19 @@ * under the terms of the GNU Public License. */ +#define FOR_UTIL_LINUX + #include <sys/types.h> #include <errno.h> #include <unistd.h> #include <linux/unistd.h> -#if 0 +#ifndef FOR_UTIL_LINUX #include "et/com_err.h" #include "ext2fs/io.h" #endif +#ifdef FOR_UTIL_LINUX #if defined(__GNUC__) || defined(HAS_LONG_LONG) typedef long long ext2_loff_t; #else @@ -24,6 +27,7 @@ typedef long ext2_loff_t; extern ext2_loff_t ext2_llseek(unsigned int fd, ext2_loff_t offset, unsigned int origin); +#endif #ifdef __linux__ @@ -47,8 +51,15 @@ ext2_loff_t ext2_llseek (unsigned int fd, ext2_loff_t offset, int retval; static int do_compat = 0; - if (do_compat) + if (do_compat) { + compat_lseek: + if ((sizeof(off_t) < sizeof(ext2_loff_t)) && + (offset >= ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))) { + errno = -EINVAL; + return -1; + } return lseek (fd, (off_t) offset, origin); + } offset_high = ((unsigned long long) offset) >> 32; offset_low = ((unsigned long long) offset) & 0xffffffff; @@ -59,7 +70,7 @@ ext2_loff_t ext2_llseek (unsigned int fd, ext2_loff_t offset, * which does not support the llseek system call */ do_compat++; - return lseek (fd, (off_t) offset, origin); + goto compat_lseek; } if (retval == -1) result = -1; |