[Libsysio-commit] RedStorm: libsysio/src chdir.c fcntl.c getdirentries.c ioctl.c lseek.c open.c read
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2003-09-27 23:37:59
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv11329/src Modified Files: Tag: RedStorm chdir.c fcntl.c getdirentries.c ioctl.c lseek.c open.c read.c stat64.c truncate.c write.c Log Message: Incorporating the head dragged in a whole bunch of symbols. Mostly, improperly defined. They were functions instead of aliases :-( Fixed that... Along the way, base everything around __USE_LARGEFILE64 from the glibc headers when trying to get the xxxx64() entry-points. If this isn't being compiled under glibc then __USE_LARGEFILE64 is defined to be 0. Which means that the internal offset, stat, statvfs, etc types all become the defaults from the system and everything is considered to be "natural". This is a very intrusive change. Everybody should retest. Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.3.10.2 retrieving revision 1.3.10.3 diff -u -w -b -B -p -r1.3.10.2 -r1.3.10.3 --- chdir.c 27 Sep 2003 20:20:40 -0000 1.3.10.2 +++ chdir.c 27 Sep 2003 23:01:23 -0000 1.3.10.3 @@ -78,6 +78,8 @@ #include "mount.h" #include "file.h" +#include "sysio-symbols.h" + struct pnode *_sysio_cwd = NULL; /* @@ -221,12 +223,8 @@ getcwd(char *buf, size_t size) return buf; } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -char * -__getcwd(char *buf, size_t size) -{ - return getcwd(buf, size); -} +#ifdef __GLIBC__ +sysio_sym_weak_alias(getcwd, __getcwd) #endif #ifdef PATH_MAX Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.3.4.1 retrieving revision 1.3.4.2 diff -u -w -b -B -p -r1.3.4.1 -r1.3.4.2 --- fcntl.c 26 Sep 2003 21:28:34 -0000 1.3.4.1 +++ fcntl.c 27 Sep 2003 23:01:23 -0000 1.3.4.2 @@ -51,6 +51,8 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + int fcntl(int fd, int cmd, ...) { @@ -96,17 +98,7 @@ out: return err; } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -__fcntl(int fd, int cmd, ...) -{ - int rc; - va_list ap; - - va_start(ap, cmd); - rc = fcntl(fd, cmd, ap); - va_end(ap); - - return rc; -} +#ifdef __GLIBC__ +#undef __fcntl +sysio_sym_weak_alias(fcntl, __fcntl) #endif Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.1.10.2 retrieving revision 1.1.10.3 diff -u -w -b -B -p -r1.1.10.2 -r1.1.10.3 --- getdirentries.c 19 May 2003 14:05:34 -0000 1.1.10.2 +++ getdirentries.c 27 Sep 2003 23:01:23 -0000 1.1.10.3 @@ -18,8 +18,8 @@ #define __restrict #endif -ssize_t -getdirentries64(int fd, +static ssize_t +_getdirentries64(int fd, char *buf, size_t nbytes, _SYSIO_OFF_T * __restrict basep) @@ -46,6 +46,13 @@ getdirentries64(int fd, return cc; } +#if __USE_LARGEFILE64 +#undef getdirentries64 +sysio_sym_strong_alias(_getdirentries64, getdirentries64) +#endif + +#undef getdirentries + #ifndef DIRENT64_IS_NATURAL #ifndef EOVERFLOW @@ -127,7 +134,7 @@ getdirentries(int fd, dp = (struct dirent *)buf; ibase = *basep; - cc = getdirentries64(fd, ibuf, inbytes, &ibase); + cc = _getdirentries64(fd, ibuf, inbytes, &ibase); if (cc < 0) { cc = -errno; goto out; @@ -212,6 +219,5 @@ out: #undef _dbaselen } #else /* !defined(DIRENT64_IS_NATURAL) */ -sysio_sym_strong_alias(getdirentries64, getdirentries) +sysio_sym_strong_alias(_getdirentries64, getdirentries) #endif - Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.1.1.1.14.1 retrieving revision 1.1.1.1.14.2 diff -u -w -b -B -p -r1.1.1.1.14.1 -r1.1.1.1.14.2 --- ioctl.c 26 Sep 2003 21:28:34 -0000 1.1.1.1.14.1 +++ ioctl.c 27 Sep 2003 23:01:23 -0000 1.1.1.1.14.2 @@ -50,6 +50,8 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + int ioctl(int fd, unsigned long request, ...) { @@ -77,17 +79,7 @@ out: } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -__ioctl(int fd, unsigned long request, ...) -{ - va_list ap; - int rc; - - va_start(ap, request); - rc = ioctl(fd, request, ap); - va_end(ap); - - return rc; -} +#ifdef __GLIBC__ +#undef __ioctl +sysio_sym_weak_alias(ioctl, __ioctl) #endif Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4.4.2 retrieving revision 1.4.4.3 diff -u -w -b -B -p -r1.4.4.2 -r1.4.4.3 --- lseek.c 26 Sep 2003 21:28:34 -0000 1.4.4.2 +++ lseek.c 27 Sep 2003 23:01:23 -0000 1.4.4.3 @@ -103,41 +103,56 @@ out: return fil->f_pos = off; } +#if __USE_LARGEFILE64 +#undef lseek64 sysio_sym_weak_alias(_sysio_lseek, lseek64) +#ifdef __GLIBC__ +#undef __lseek64 +sysio_sym_weak_alias(_sysio_lseek, __lseek64) +#endif +#endif #undef lseek extern off_t lseek(int fd, off_t offset, int whence) { + _SYSIO_OFF_T off; + off_t rtn; - return (off_t )_sysio_lseek(fd, offset, whence); + off = _sysio_lseek(fd, offset, whence); + if (off < 0) + return -1; + rtn = (off_t )off; + if ((_SYSIO_OFF_T )rtn != off) { + errno = EINVAL; + return -1; } - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) - -off_t -__lseek(int fd, off_t offset, int whence) -{ - return lseek(fd, offset, whence); -} - -loff_t -__lseek64( int fd, loff_t offset, int whence) -{ - return lseek( fd, offset, whence ); + return rtn; } -loff_t -__llseek( int fd, loff_t offset, int whence) +#ifdef __GLIBC__ +#undef __lseek +sysio_sym_weak_alias(lseek, __lseek) +#endif + +#ifdef __linux__ +#undef llseek +int +llseek(unsigned int fd __IS_UNUSED, + unsigned long offset_high __IS_UNUSED, + unsigned long offset_low __IS_UNUSED, + loff_t *result __IS_UNUSED, + unsigned int whence __IS_UNUSED) { - return __lseek64(fd, offset, whence); -} -loff_t -__llseek64( int fd, loff_t offset, int whence) -{ - return __lseek64(fd, offset, whence); + /* + * Something is very wrong if this was called. + */ + errno = ENOTSUP; + return -1; } +#undef __llseek +sysio_sym_weak_alias(llseek, __llseek) #endif Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.7.4.3 retrieving revision 1.7.4.4 diff -u -w -b -B -p -r1.7.4.3 -r1.7.4.4 --- open.c 26 Sep 2003 22:14:53 -0000 1.7.4.3 +++ open.c 27 Sep 2003 23:01:23 -0000 1.7.4.4 @@ -49,9 +49,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <sys/queue.h> -#ifdef ALPHA_LINUX -#include <features.h> -#endif #include "sysio.h" #include "inode.h" @@ -59,12 +56,7 @@ #include "fs.h" #include "mount.h" -#ifdef __GLIBC__ -#undef open -#undef __open -#undef open64 -#undef __open64 -#endif +#include "sysio-symbols.h" /* * Open file support. @@ -126,6 +118,8 @@ _sysio_open(struct pnode *pno, int flags return err; } +#undef open + int open(const char *path, int flags, ...) { @@ -213,6 +207,15 @@ error: return -1; } +#ifdef __GLIBC__ +#undef __open +sysio_sym_weak_alias(open, __open) +#undef open64 +sysio_sym_weak_alias(open, open64) +#undef __open64 +sysio_sym_weak_alias(open, __open64) +#endif + int close(int fd) { @@ -224,6 +227,11 @@ close(int fd) return err ? -1 : 0; } +#ifdef __GLIBC__ +#undef __close +sysio_sym_weak_alias(close, __close) +#endif + int creat(const char *path, mode_t mode) { @@ -231,6 +239,15 @@ creat(const char *path, mode_t mode) return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode); } +#ifdef __GLIBC__ +#undef __creat +sysio_sym_weak_alias(creat, __creat) +#undef creat64 +sysio_sym_weak_alias(creat, creat64) +#undef __creat64 +sysio_sym_weak_alias(creat, __creat64) +#endif + mode_t umask(mode_t mask) { @@ -240,49 +257,3 @@ umask(mode_t mask) _sysio_umask = mask & 0777; return omask; } - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -open64(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} - -int -__open64(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} -int -__open(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} - -int -__close(int fd) { - - return close(fd); -} -#endif Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2.10.1 retrieving revision 1.2.10.2 diff -u -w -b -B -p -r1.2.10.1 -r1.2.10.2 --- read.c 26 Sep 2003 21:28:34 -0000 1.2.10.1 +++ read.c 27 Sep 2003 23:01:23 -0000 1.2.10.2 @@ -53,13 +53,15 @@ #include "file.h" #include "inode.h" +#include "sysio-symbols.h" + /* * Schedule asynchronous read of iovec at some file extent. */ static struct ioctx * do_ixreadv(struct file *fil, const struct iovec *iov, size_t count, - off_t offset, + _SYSIO_OFF_T offset, void (*fcompletio)(struct ioctx *)) { struct inode *ino; @@ -96,7 +98,7 @@ do_ixreadv(struct file *fil, * API interface to accomplish asynch read into iovec from given file offset. */ ioid_t -ipreadv(int fd, const struct iovec *iov, size_t count, off_t offset) +ipreadv(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { struct file *fil; struct ioctx *ioctxp; @@ -115,7 +117,7 @@ ipreadv(int fd, const struct iovec *iov, * API interface to accomplish asynch read into buf from given file offset. */ ioid_t -ipread(int fd, void *buf, size_t count, off_t offset) +ipread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) { struct iovec iov[1]; @@ -130,7 +132,7 @@ ipread(int fd, void *buf, size_t count, * API interface to accomplish read into iovec from given file offset. */ ssize_t -preadv(int fd, const struct iovec *iov, size_t count, off_t offset) +preadv(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -143,8 +145,8 @@ preadv(int fd, const struct iovec *iov, /* * API interface to accomplish read into buf from given file offset. */ -ssize_t -pread(int fd, void *buf, size_t count, off_t offset) +static ssize_t +_pread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -154,6 +156,21 @@ pread(int fd, void *buf, size_t count, o return iowait(ioid); } +#if __USE_LARGEFILE64 +#undef pread64 +sysio_sym_weak_alias(_pread, pread64) + +ssize_t +pread(int fd, void *buf, size_t count, off_t offset) +{ + + return _pread(fd, buf, count, offset); +} +#else +#undef pread +sysio_sym_weak_alias(_pread, pread) +#endif + /* * API interface to accomplish asynch read into iovec from current file offset. */ @@ -211,6 +228,16 @@ read(int fd, void *buf, size_t count) return iowait(ioid); } +#ifdef __GLIBC__ +#undef __read +sysio_sym_weak_alias(read, __read) +#endif + +#if __USE_LARGEFILE +#undef read64 +sysio_sym_weak_alias(read, read64) +#endif + #ifdef notdef int read_list(int fd, @@ -223,13 +250,5 @@ read_list(int fd, { errno = ENOSYS; return -1; -} -#endif - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -ssize_t -__read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); } #endif Index: stat64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat64.c,v retrieving revision 1.3.6.1 retrieving revision 1.3.6.2 diff -u -w -b -B -p -r1.3.6.1 -r1.3.6.2 --- stat64.c 12 May 2003 11:48:45 -0000 1.3.6.1 +++ stat64.c 27 Sep 2003 23:01:24 -0000 1.3.6.2 @@ -166,4 +166,4 @@ lstat64(const char *filename, struct sta return __lxstat64(_STAT_VER, filename, buf); } -#endif /* defined(_LARGEFILE64_SOURCE) */ +#endif /* !__USE_LARGEFILE64 */ Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -w -b -B -p -r1.3 -r1.3.6.1 --- truncate.c 24 Mar 2003 22:09:07 -0000 1.3 +++ truncate.c 27 Sep 2003 23:01:24 -0000 1.3.6.1 @@ -53,11 +53,13 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + /* * Truncate file, given path (alias) or index node. */ static int -do_truncate(struct pnode *pno, struct inode *ino, off_t length) +do_truncate(struct pnode *pno, struct inode *ino, _SYSIO_OFF_T length) { struct intnl_stat stbuf; unsigned mask; @@ -75,8 +77,8 @@ do_truncate(struct pnode *pno, struct in return _sysio_setattr(pno, ino, mask, &stbuf); } -int -truncate(const char *path, off_t length) +static int +_truncate(const char *path, _SYSIO_OFF_T length) { int err; struct pnode *pno; @@ -95,8 +97,24 @@ out: return err; } +#if __USE_LARGEFILE64 +#undef truncate64 +sysio_sym_weak_alias(_truncate, truncate64) + +#undef truncate int -ftruncate(int fd, off_t length) +truncate(const char *path, off_t length) +{ + + return _truncate(path, length); +} +#else +#undef truncate +sysio_sym_weak_alias(_truncate, truncate) +#endif + +static int +_ftruncate(int fd, _SYSIO_OFF_T length) { int err; struct file *fil; @@ -115,3 +133,19 @@ out: } return err; } + +#if __USE_LARGEFILE64 +#undef ftruncate64 +sysio_sym_weak_alias(_ftruncate, ftruncate64) + +#undef ftruncate +int +ftruncate(int fd, off_t length) +{ + + return _ftruncate(fd, length); +} +#else +#undef ftruncate +sysio_sym_weak_alias(_ftruncate, ftruncate) +#endif Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.2.12.1 retrieving revision 1.2.12.2 diff -u -w -b -B -p -r1.2.12.1 -r1.2.12.2 --- write.c 26 Sep 2003 21:28:34 -0000 1.2.12.1 +++ write.c 27 Sep 2003 23:01:24 -0000 1.2.12.2 @@ -52,8 +52,8 @@ #include "sysio.h" #include "file.h" #include "inode.h" -#include "fs.h" -#include "mount.h" + +#include "sysio-symbols.h" /* * Schedule asynchronous write of iovec at some file extent. @@ -61,7 +61,7 @@ static struct ioctx * do_ixwritev(struct file *fil, const struct iovec *iov, size_t count, - off_t offset, + _SYSIO_OFF_T offset, void (*fcompletio)(struct ioctx *)) { struct inode *ino; @@ -69,7 +69,7 @@ do_ixwritev(struct file *fil, struct io_arguments ioarguments; struct ioctx *ioctx; - if (!(fil->f_flags & (O_WRONLY|O_RDWR))) { + if (fil->f_flags & O_RDONLY) { errno = EBADF; return IOID_FAIL; } @@ -79,11 +79,7 @@ do_ixwritev(struct file *fil, /* * Huh? It's dead. */ - errno = -EBADF; - return NULL; - } - if (IS_RDONLY(NULL, ino)) { - errno = -EROFS; + errno = EBADF; return NULL; } IOARG_INIT(&ioarguments, @@ -99,10 +95,10 @@ do_ixwritev(struct file *fil, } /* - * API interface to accomplish asynch write from iovec at given file offset. + * API interface to accomplish asynch write into iovec from given file offset. */ ioid_t -ipwritev(int fd, const struct iovec *iov, size_t count, off_t offset) +ipwritev(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { struct file *fil; struct ioctx *ioctxp; @@ -118,10 +114,10 @@ ipwritev(int fd, const struct iovec *iov } /* - * API interface to accomplish asynch write from buf from given file offset. + * API interface to accomplish asynch write into buf from given file offset. */ ioid_t -ipwrite(int fd, const void *buf, size_t count, off_t offset) +ipwrite(int fd, const void *buf, size_t count, _SYSIO_OFF_T offset) { struct iovec iov[1]; @@ -133,10 +129,10 @@ ipwrite(int fd, const void *buf, size_t } /* - * API interface to accomplish write from iovec at given file offset. + * API interface to accomplish write into iovec from given file offset. */ ssize_t -pwritev(int fd, const struct iovec *iov, size_t count, off_t offset) +pwritev(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -147,10 +143,10 @@ pwritev(int fd, const struct iovec *iov, } /* - * API interface to accomplish write from buf from given file offset. + * API interface to accomplish write into buf from given file offset. */ -ssize_t -pwrite(int fd, const void *buf, size_t count, off_t offset) +static ssize_t +_pwrite(int fd, const void *buf, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -160,8 +156,23 @@ pwrite(int fd, const void *buf, size_t c return iowait(ioid); } +#if __USE_LARGEFILE64 +#undef pwrite64 +sysio_sym_weak_alias(_pwrite, pwrite64) + +ssize_t +pwrite(int fd, const void *buf, size_t count, off_t offset) +{ + + return _pwrite(fd, buf, count, offset); +} +#else +#undef pwrite +sysio_sym_weak_alias(_pwrite, pwrite) +#endif + /* - * API interface to accomplish asynch write from iovec at current file offset. + * API interface to accomplish asynch write into iovec from current file offset. */ ioid_t iwritev(int fd, const struct iovec *iov, int count) @@ -182,7 +193,7 @@ iwritev(int fd, const struct iovec *iov, } /* - * API interface to accomplish asynch write from buf at current file offset. + * API interface to accomplish asynch write into buf from current file offset. */ ioid_t iwrite(int fd, const void *buf, size_t count) @@ -217,6 +228,16 @@ write(int fd, const void *buf, size_t co return iowait(ioid); } +#ifdef __GLIBC__ +#undef __write +sysio_sym_weak_alias(write, __write) +#endif + +#if __USE_LARGEFILE +#undef write64 +sysio_sym_weak_alias(write, write64) +#endif + #ifdef notdef int write_list(int fd, @@ -231,18 +252,3 @@ write_list(int fd, return -1; } #endif - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -ssize_t -__write(int fd, const void *buf, size_t count) -{ - return write(fd, buf, count); -} - -ssize_t -__writev(int fd, const struct iovec *iov, int count) -{ - return writev(fd, iov, count); -} -#endif - |