[Libsysio-commit] HEAD: libsysio/src dev.c getdirentries.c lseek.c mknod.c open.c read.c stat.c stat
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2003-10-10 18:51:47
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv14350/src Modified Files: dev.c getdirentries.c lseek.c mknod.c open.c read.c stat.c stat64.c statvfs.c statvfs64.c truncate.c write.c Log Message: Red Storm branch mega-merge. Please, no more changes to any of the Red Storm branches. We'll keep them for reference for awhile but then, they go away. Finally! Index: dev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- dev.c 27 Sep 2003 19:42:03 -0000 1.3 +++ dev.c 10 Oct 2003 18:50:31 -0000 1.4 @@ -74,7 +74,9 @@ const struct inode_ops _sysio_nodev_ops _sysio_nodev_inop_datasync, _sysio_nodev_inop_ioctl, _sysio_nodev_inop_mknod, +#ifdef _HAVE_STATVFS _sysio_nodev_inop_statvfs, +#endif _sysio_nodev_inop_gone }; Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- getdirentries.c 31 Jul 2003 22:21:35 -0000 1.2 +++ getdirentries.c 10 Oct 2003 18:50:31 -0000 1.3 @@ -1,7 +1,6 @@ -#ifdef __GNUC__ -#include <alloca.h> -#else #include <stdlib.h> +#ifdef __GLIBC__ +#include <alloca.h> #endif #include <string.h> #include <errno.h> @@ -19,8 +18,11 @@ #define __restrict #endif -ssize_t -getdirentries64(int fd, char *buf, size_t nbytes, off64_t * __restrict basep) +static ssize_t +_getdirentries64(int fd, + char *buf, + size_t nbytes, + _SYSIO_OFF_T * __restrict basep) { struct file *fil; ssize_t cc; @@ -44,6 +46,13 @@ getdirentries64(int fd, char *buf, size_ return cc; } +#if _LARGEFILE64_SOURCE +#undef getdirentries64 +sysio_sym_strong_alias(_getdirentries64, getdirentries64) +#endif + +#undef getdirentries + #ifndef DIRENT64_IS_NATURAL #ifndef EOVERFLOW @@ -56,33 +65,59 @@ getdirentries64(int fd, char *buf, size_ #define _namlen(dp) (strlen((dp)->d_name)) #endif +#ifndef _rndup +#define _rndup(n, boundary) \ + ((((n) + (boundary) - 1 ) / (boundary)) * (boundary)) +#endif + +#if !(defined(BSD) || defined(REDSTORM)) ssize_t -getdirentries(int fd, char *buf, size_t nbytes, off_t * __restrict basep) +getdirentries(int fd, + char *buf, + size_t nbytes, + off_t * __restrict basep) +#else +int +getdirentries(int fd, + char *buf, + int nbytes, + long * __restrict basep) +#endif { size_t inbytes; void *ibuf; - off64_t ibase; + _SYSIO_OFF_T ibase; ssize_t cc; struct dirent *dp, *nxtdp; - struct dirent64 *od64p = NULL, *d64p = NULL; +#if defined(BSD) || defined(REDSTORM) + int off; +#endif + struct intnl_dirent *od64p, *d64p; size_t n; size_t reclen; char *cp; #define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0]) -#ifdef __GNUC__ +#ifdef __GLIBC__ #define _dreclen(namlen) \ ((_dbaselen + (namlen) + __alignof__ (struct dirent)) & \ ~(__alignof__ (struct dirent) - 1)) #define _fast_alloc(n) alloca(n) #define _fast_free(p) -#else /* !defined(__GNUC__) */ -#define _dreclen(namelen) \ - (_rndup(_dbaselen + (namlen) + 1, sizeof(unsigned long long)) +#else /* !defined(__GLIBC__) */ +#define _dreclen(namlen) \ + _rndup(_dbaselen + (namlen) + 1, sizeof(int)) #define _fast_alloc(n) malloc(n) #define _fast_free(p) free(p) #endif +#if defined(BSD) || defined(REDSTORM) + if (nbytes < 0) { + errno = -EINVAL; + return -1; + } +#endif + inbytes = nbytes; if (inbytes > 8 * 1024) { /* @@ -99,7 +134,7 @@ getdirentries(int fd, char *buf, size_t 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; @@ -110,6 +145,9 @@ getdirentries(int fd, char *buf, size_t goto out; } +#if defined(BSD) || defined(REDSTORM) + off = *basep; +#endif od64p = NULL; d64p = ibuf; for (;;) { @@ -121,14 +159,22 @@ getdirentries(int fd, char *buf, size_t n = strlen(d64p->d_name); #endif reclen = _dreclen(n); - if (reclen >= nbytes) + if (reclen >= (unsigned )nbytes) break; dp->d_ino = (ino_t )d64p->d_ino; +#if !(defined(BSD) || defined(REDSTORM)) dp->d_off = (off_t )d64p->d_off; +#endif if ((sizeof(dp->d_ino) != sizeof(d64p->d_ino) && - dp->d_ino != d64p->d_ino) && + dp->d_ino != d64p->d_ino) + || +#if !(defined(BSD) || defined(REDSTORM)) (sizeof(dp->d_off) != sizeof(d64p->d_off) && - dp->d_off != d64p->d_off)) { + dp->d_off != d64p->d_off) +#else + (off + (int )reclen < off) +#endif + ) { cc = -EOVERFLOW; break; } @@ -142,6 +188,9 @@ getdirentries(int fd, char *buf, size_t od64p = d64p; d64p = (void *)d64p + d64p->d_reclen; nbytes -= reclen; +#if defined(BSD) || defined(REDSTORM) + off += reclen; +#endif dp = nxtdp; } @@ -154,10 +203,15 @@ out: } cc = (char *)dp - buf; if (cc) - *basep = od64p->d_off; + *basep = +#if !(defined(BSD) || defined(REDSTORM)) + od64p->d_off; +#else + off; +#endif return cc; -#ifdef __GNUC__ +#ifdef __GLIBC__ #undef _fast_alloc #undef _fast_free #endif @@ -165,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: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- lseek.c 6 Oct 2003 21:19:31 -0000 1.7 +++ lseek.c 10 Oct 2003 18:50:31 -0000 1.8 @@ -53,8 +53,8 @@ #include "sysio-symbols.h" -static off64_t -_sysio_lseek(int fd, off64_t offset, int whence) +static _SYSIO_OFF_T +_sysio_lseek(int fd, _SYSIO_OFF_T offset, int whence) { int err; struct file *fil; @@ -117,11 +117,44 @@ sysio_sym_weak_alias(_sysio_lseek, __lse 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; + } + return rtn; } #ifdef __GLIBC__ #undef __lseek sysio_sym_weak_alias(lseek, __lseek) +#endif + +#if 0 +#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) +{ + + /* + * Something is very wrong if this was called. + */ + errno = ENOTSUP; + return -1; +} + +#undef __llseek +sysio_sym_weak_alias(llseek, __llseek) +#endif #endif Index: mknod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mknod.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- mknod.c 26 Mar 2003 00:06:05 -0000 1.3 +++ mknod.c 10 Oct 2003 18:50:31 -0000 1.4 @@ -62,6 +62,10 @@ #undef mknod #undef __xmknod +#if defined(BSD) || defined(REDSTORM) +#define _MKNOD_VER 0 +#endif + int __xmknod(int __ver, const char *path, mode_t mode, dev_t *dev) { Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- open.c 6 Oct 2003 21:19:31 -0000 1.9 +++ open.c 10 Oct 2003 18:50:31 -0000 1.10 @@ -118,6 +118,8 @@ _sysio_open(struct pnode *pno, int flags return err; } +#undef open + int open(const char *path, int flags, ...) { @@ -146,7 +148,12 @@ open(const char *path, int flags, ...) * Will need mode too. */ va_start(ap, flags); - mode = va_arg(ap, mode_t); + mode = +#ifndef REDSTORM + va_arg(ap, mode_t); +#else + va_arg(ap, int); +#endif va_end(ap); mode &= ~_sysio_umask; /* apply umask */ Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- read.c 6 Oct 2003 21:19:31 -0000 1.5 +++ read.c 10 Oct 2003 18:50:31 -0000 1.6 @@ -61,7 +61,7 @@ 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; @@ -98,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; @@ -117,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]; @@ -132,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; @@ -145,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; @@ -156,6 +156,21 @@ pread(int fd, void *buf, size_t count, o return iowait(ioid); } +#if _LARGEFILE64_SOURCE +#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. */ Index: stat.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- stat.c 24 Mar 2003 22:09:07 -0000 1.3 +++ stat.c 10 Oct 2003 18:50:31 -0000 1.4 @@ -62,7 +62,11 @@ #undef __xstat #undef __lxstat -#if !(defined(__GNUC__) && __GNUC__ >= 2) +#if !defined(_STAT_VER) +#define _STAT_VER 0 +#endif + +#if 0 && !(defined(__GLIBC__) && __GLIBC__ >= 2) #warning Check assumptions here about stat/stat64 sizes and offsets #endif Index: stat64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat64.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- stat64.c 24 Mar 2003 22:09:07 -0000 1.3 +++ stat64.c 10 Oct 2003 18:50:31 -0000 1.4 @@ -41,6 +41,8 @@ * le...@sa... */ +#ifdef _LARGFILE64_SOURCE + #include <errno.h> #include <assert.h> #include <sys/types.h> @@ -164,3 +166,4 @@ lstat64(const char *filename, struct sta return __lxstat64(_STAT_VER, filename, buf); } +#endif /* !_LARGEFILE64_SOURCE */ Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- statvfs.c 24 Mar 2003 22:09:07 -0000 1.3 +++ statvfs.c 10 Oct 2003 18:50:31 -0000 1.4 @@ -41,6 +41,10 @@ * le...@sa... */ +#ifdef _HAVE_STATVFS + +#if !(defined(BSD) || defined(REDSTORM)) + #include <unistd.h> #include <errno.h> #include <assert.h> @@ -136,3 +140,5 @@ err: out: return err; } +#endif /* if !(defined(BSD) || defined(REDSTORM)) */ +#endif /* defined(_HAVE_STATVFS) */ Index: statvfs64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- statvfs64.c 24 Mar 2003 22:09:07 -0000 1.3 +++ statvfs64.c 10 Oct 2003 18:50:31 -0000 1.4 @@ -41,6 +41,9 @@ * le...@sa... */ +#ifdef _HAVE_STATVFS + +#if !(defined(BSD) || defined(REDSTORM)) #include <unistd.h> #include <errno.h> #include <assert.h> @@ -93,3 +96,5 @@ out: } return err; } +#endif /* if !(defined(BSD) || defined(REDSTORM)) */ +#endif /* define(_HAVE_STATVFS) */ Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- truncate.c 24 Mar 2003 22:09:07 -0000 1.3 +++ truncate.c 10 Oct 2003 18:50:31 -0000 1.4 @@ -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 _LARGEFILE64_SOURCE +#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 _LARGEFILE64_SOURCE +#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.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- write.c 6 Oct 2003 21:19:31 -0000 1.5 +++ write.c 10 Oct 2003 18:50:31 -0000 1.6 @@ -52,8 +52,8 @@ #include "sysio.h" #include "file.h" #include "inode.h" -#include "fs.h" -#include "mount.h" + +#include "sysio-symbols.h" #include "sysio-symbols.h" @@ -63,7 +63,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; @@ -71,7 +71,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; } @@ -81,11 +81,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, @@ -101,10 +97,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; @@ -120,10 +116,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]; @@ -135,10 +131,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; @@ -149,10 +145,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; @@ -162,8 +158,23 @@ pwrite(int fd, const void *buf, size_t c return iowait(ioid); } +#if _LARGEFILE64_SOURCE +#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) @@ -184,7 +195,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) |