pread, pwrite linux implementation does not conform to Single Unix Specification
Andreas Schwab
schwab@suse.de
Wed Jul 17 11:52:00 GMT 2002
"Gerhard Tonn" <TON@de.ibm.com> writes:
|> Anybody any opinion on this subject? Is the implementation supposed to be
|> changed or does it work as designed? At least powerpc linux seems to have
|> made it SUS compliant in their special implementation.
Here is a patch:
2002-07-17 Andreas Schwab <schwab@suse.de>
* sysdeps/unix/sysv/linux/pread.c: Sign extend offset.
* sysdeps/unix/sysv/linux/pwrite.c: Likewise.
* sysdeps/unix/sysv/linux/mips/pread.c: Likewise.
* sysdeps/unix/sysv/linux/mips/pwrite.c: Likewise.
Index: sysdeps/unix/sysv/linux/pread.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/pread.c,v
retrieving revision 1.12
diff -u -p -a -r1.12 sysdeps/unix/sysv/linux/pread.c
--- sysdeps/unix/sysv/linux/pread.c 6 Jul 2001 04:56:12 -0000 1.12
+++ sysdeps/unix/sysv/linux/pread.c 17 Jul 2002 18:46:17 -0000
@@ -50,7 +50,7 @@ __libc_pread (fd, buf, count, offset)
/* First try the syscall. */
result = INLINE_SYSCALL (pread, 5, fd, CHECK_N (buf, count), count,
- __LONG_LONG_PAIR (0, offset));
+ __LONG_LONG_PAIR (-(offset < 0), offset));
# if __ASSUME_PREAD_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
Index: sysdeps/unix/sysv/linux/pwrite.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/pwrite.c,v
retrieving revision 1.11
diff -u -p -a -r1.11 sysdeps/unix/sysv/linux/pwrite.c
--- sysdeps/unix/sysv/linux/pwrite.c 6 Jul 2001 04:56:12 -0000 1.11
+++ sysdeps/unix/sysv/linux/pwrite.c 17 Jul 2002 18:46:17 -0000
@@ -50,7 +50,7 @@ __libc_pwrite (fd, buf, count, offset)
/* First try the syscall. */
result = INLINE_SYSCALL (pwrite, 5, fd, CHECK_N (buf, count), count,
- __LONG_LONG_PAIR (0, offset));
+ __LONG_LONG_PAIR (-(offset < 0), offset));
# if __ASSUME_PWRITE_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
Index: sysdeps/unix/sysv/linux/mips/pread.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/pread.c,v
retrieving revision 1.7
diff -u -p -a -r1.7 sysdeps/unix/sysv/linux/mips/pread.c
--- sysdeps/unix/sysv/linux/mips/pread.c 6 Jul 2001 04:56:18 -0000 1.7
+++ sysdeps/unix/sysv/linux/mips/pread.c 17 Jul 2002 18:46:17 -0000
@@ -49,7 +49,7 @@ __libc_pread (fd, buf, count, offset)
/* First try the syscall. */
result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
- __LONG_LONG_PAIR (0, offset));
+ __LONG_LONG_PAIR (-(offset < 0), offset));
# if __ASSUME_PREAD_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
Index: sysdeps/unix/sysv/linux/mips/pwrite.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/pwrite.c,v
retrieving revision 1.7
diff -u -p -a -r1.7 sysdeps/unix/sysv/linux/mips/pwrite.c
--- sysdeps/unix/sysv/linux/mips/pwrite.c 6 Jul 2001 04:56:18 -0000 1.7
+++ sysdeps/unix/sysv/linux/mips/pwrite.c 17 Jul 2002 18:46:17 -0000
@@ -48,7 +48,7 @@ __libc_pwrite (fd, buf, count, offset)
/* First try the syscall. */
result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
- __LONG_LONG_PAIR (0, offset));
+ __LONG_LONG_PAIR (-(offset < 0), offset));
# if __ASSUME_PWRITE_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Libc-alpha
mailing list