From 54e4a312a7ac8609604d922950d29f618d1cb04c Mon Sep 17 00:00:00 2001 From: David McCullough Date: Fri, 9 Aug 2002 12:58:02 +0000 Subject: pread and pwrite were broken in several ways: * pwrite was using the write system call. * SYSCALL_INLINE was only defined for pread and reused by pwrite meaning pwrite did a pread :-). * The kernel pread/pwrite interfaces always take a 64bit value. So the libc versions must do the LONG_LONG_PAIR stuff otherwise the pread/pwrite calls will not work. These guys are working now for SH at least (and I can format my DiskOnChip again ;-) --- libc/sysdeps/linux/common/pread_write.c | 42 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'libc/sysdeps/linux/common/pread_write.c') diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c index 61d1bee4f..801359276 100644 --- a/libc/sysdeps/linux/common/pread_write.c +++ b/libc/sysdeps/linux/common/pread_write.c @@ -40,45 +40,49 @@ #include #ifdef __NR_pread -#define __NR___libc_pread __NR_pread -_syscall4(ssize_t, __libc_pread, int, fd, void *, buf, size_t, count, off_t, offset); -weak_alias (__libc_pread, pread) -#if defined __UCLIBC_HAVE_LFS__ -#ifndef INLINE_SYSCALL -#define INLINE_SYSCALL(name, nr, args...) __syscall_pread (args) #define __NR___syscall_pread __NR_pread static inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf, size_t, count, off_t, offset_hi, off_t, offset_lo); -#endif +#define __NR___libc_pread __NR_pread + +ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset) +{ + return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR((off_t)0,offset))); +} +weak_alias (__libc_pread, pread) + +#if defined __UCLIBC_HAVE_LFS__ ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset) { - return(INLINE_SYSCALL (pread, 5, fd, buf, - count, __LONG_LONG_PAIR ((off_t) (offset >> 32), (off_t) (offset & 0xffffffff)))); + return(__syscall_pread(fd, buf, count, + __LONG_LONG_PAIR((off_t)(offset>>32),(off_t)(offset&0xffffffff)))); } weak_alias (__libc_pread64, pread64) #endif /* __UCLIBC_HAVE_LFS__ */ + #endif /* __NR_pread */ #ifdef __NR_pwrite #define __NR___libc_pwrite __NR_pwrite -_syscall4(ssize_t, __libc_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset); -weak_alias (__libc_pwrite, pwrite) -#if defined __UCLIBC_HAVE_LFS__ -#ifndef INLINE_SYSCALL -#define INLINE_SYSCALL(name, nr, args...) __syscall_write (args) -#define __NR___syscall_write __NR_write -static inline _syscall5(ssize_t, __syscall_write, int, fd, const void *, buf, +#define __NR___syscall_pwrite __NR_pwrite +static inline _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset_hi, off_t, offset_lo); -#endif +ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset) +{ + return(__syscall_pwrite(fd,buf,count,__LONG_LONG_PAIR((off_t)0,offset))); +} +weak_alias (__libc_pwrite, pwrite) + +#if defined __UCLIBC_HAVE_LFS__ ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset) { - return(INLINE_SYSCALL (pwrite, 5, fd, buf, - count, __LONG_LONG_PAIR ((off_t) (offset >> 32), (off_t) (offset & 0xffffffff)))); + return(__syscall_pwrite(fd, buf, count, + __LONG_LONG_PAIR((off_t)(offset>>32),(off_t)(offset&0xffffffff)))); } weak_alias (__libc_pwrite64, pwrite64) #endif /* __UCLIBC_HAVE_LFS__ */ -- cgit v1.2.3