[Libsysio-commit] HEAD: libsysio/src rw.c dev.c dup.c file.c fs.c init.c inode.c ioctx.c lseek.c mkd
Brought to you by:
lward
|
From: Lee W. <lw...@us...> - 2004-02-06 20:10:48
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29990/src Modified Files: dev.c dup.c file.c fs.c init.c inode.c ioctx.c lseek.c mkdir.c module.mk mount.c namei.c rmdir.c statvfs64.c symlink.c truncate.c unlink.c Added Files: rw.c Log Message: Merging strided-IO branch + Strided-IO infrastructure. Internals altered to move data base don multiple targeted regions in both the file address space and local memory. + Added [i]{read,write}x, calls to perform extent-based or strided-IO directly. + Many bug fixes + Many uocnfig fixes + --with-zero-sum-memory; A config option that causes the shutdown code to carefully release *all* memory acquired from the heap, by the library. Useful for debugging tasks such as leak detection. Index: dev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- dev.c 12 Jan 2004 18:05:21 -0000 1.5 +++ dev.c 6 Feb 2004 20:07:30 -0000 1.6 @@ -66,8 +66,8 @@ const struct inode_ops _sysio_nodev_ops _sysio_nodev_inop_link, _sysio_nodev_inop_unlink, _sysio_nodev_inop_rename, - _sysio_nodev_inop_ipreadv, - _sysio_nodev_inop_ipwritev, + _sysio_nodev_inop_read, + _sysio_nodev_inop_write, _sysio_nodev_inop_iodone, _sysio_nodev_inop_fcntl, _sysio_nodev_inop_sync, Index: dup.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dup.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- dup.c 26 Jan 2004 16:34:54 -0000 1.4 +++ dup.c 6 Feb 2004 20:07:30 -0000 1.5 @@ -65,22 +65,12 @@ dup2(int oldfd, int newfd) } if (oldfd == newfd) { -#ifdef REDSTORM -#undef __dup2 -sysio_sym_weak_alias(dup2, __dup2) -#endif - SYSIO_LEAVE; return newfd; } rc = _sysio_fd_dup2(oldfd, newfd); if (rc < 0) { - -#ifdef REDSTORM -#undef __dup -sysio_sym_weak_alias(dup, __dup) -#endif errno = -rc; rc = -1; } @@ -89,6 +78,11 @@ sysio_sym_weak_alias(dup, __dup) return rc; } +#ifdef REDSTORM +#undef __dup2 +sysio_sym_weak_alias(dup2, __dup2) +#endif + int dup(int oldfd) { Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- file.c 13 Oct 2003 01:04:35 -0000 1.6 +++ file.c 6 Feb 2004 20:07:30 -0000 1.7 @@ -50,6 +50,7 @@ #include "sysio.h" #include "file.h" #include "inode.h" +#include "xtio.h" /* * Support for file IO. @@ -99,12 +100,16 @@ _sysio_fgone(struct file *fil) void _sysio_fcompletio(struct ioctx *ioctx, struct file *fil) { + _SYSIO_OFF_T off; - if (ioctx->ioctx_errno) + if (ioctx->ioctx_cc <= 0) return; assert(ioctx->ioctx_ino == fil->f_ino); - fil->f_pos = ioctx->ioctx_offset + ioctx->ioctx_cc; + off = fil->f_pos + ioctx->ioctx_cc; + if (fil->f_pos && off <= fil->f_pos) + abort(); + fil->f_pos = off; } /* @@ -143,6 +148,16 @@ fd_grow(size_t n) return 0; } +#if ZERO_SUM_MEMORY +void +_sysio_fd_shutdown() +{ + + free(_sysio_oftab); + _sysio_oftab_size = 0; +} +#endif + /* * Find a free slot in the open files table. */ Index: fs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fs.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- fs.c 24 Apr 2003 02:15:29 -0000 1.8 +++ fs.c 6 Feb 2004 20:07:30 -0000 1.9 @@ -105,6 +105,22 @@ _sysio_fssw_register(const char *name, s return 0; } +#if ZERO_SUM_MEMORY +/* + * Shutdown + */ +void +_sysio_fssw_shutdown() +{ + struct fsswent *fssw; + + while ((fssw = fsswitch.lh_first)) { + LIST_REMOVE(fssw, fssw_link); + free(fssw); + } +} +#endif + /* * Allocate and initialize a new file system record. */ Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- init.c 21 Jan 2004 15:06:31 -0000 1.5 +++ init.c 6 Feb 2004 20:07:30 -0000 1.6 @@ -52,6 +52,10 @@ #include "file.h" #include "dev.h" +#if ZERO_SUM_MEMORY +#include "fs.h" +#endif + #ifdef STDFD_DEV #include "stdfd.h" #endif @@ -113,4 +117,10 @@ _sysio_shutdown() if (!(_sysio_fd_close_all() == 0 && _sysio_unmount_all() == 0)) abort(); + +#if ZERO_SUM_MEMORY + _sysio_fd_shutdown(); + _sysio_i_shutdown(); + _sysio_fssw_shutdown(); +#endif } Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- inode.c 12 Jan 2004 18:05:22 -0000 1.12 +++ inode.c 6 Feb 2004 20:07:30 -0000 1.13 @@ -96,6 +96,24 @@ static size_t n_names = 0; static size_t max_names = (2 * NAMES_TABLE_LEN); /* + * Number of pnodes to grab per memory allocation when filling the + * free list. + */ +#define PNODES_PER_CHUNK ((8 * 1024) / sizeof(struct pnode) - 2) + +#if ZERO_SUM_MEMORY +/* + * Allocation information for pnodes bulk allocation. + */ +struct pnodes_block { + LIST_ENTRY(pnodes_block) pnblk_links; + struct pnode pnblk_nodes[PNODES_PER_CHUNK]; +}; + +static LIST_HEAD( ,pnodes_block) pnblocks; +#endif + +/* * List of all path-nodes (aliases) referenced by any tree. */ struct pnodes_head _sysio_pnodes; @@ -124,6 +142,9 @@ _sysio_i_init() for (i = 0; i < NAMES_TABLE_LEN; i++) LIST_INIT(&names[i]); +#if ZERO_SUM_MEMORY + LIST_INIT(&pnblocks); +#endif TAILQ_INIT(&_sysio_pnodes); LIST_INIT(&free_pnodes); @@ -205,6 +226,7 @@ _sysio_i_new(struct filesys *fs, { struct inode *ino; struct itable_entry *head; + struct inode_ops operations; if (n_inodes > max_inodes) { /* @@ -217,6 +239,7 @@ _sysio_i_new(struct filesys *fs, if (!ino) return NULL; ino->i_ops = *ops; + operations = *ops; if (S_ISBLK(type) || S_ISCHR(type) || S_ISFIFO(type)) { struct inode_ops *o; @@ -225,15 +248,15 @@ _sysio_i_new(struct filesys *fs, * those from the device table. */ o = _sysio_dev_lookup(type, rdev); - ino->i_ops.inop_open = o->inop_open; - ino->i_ops.inop_close = o->inop_close; - ino->i_ops.inop_ipreadv = o->inop_ipreadv; - ino->i_ops.inop_ipwritev = o->inop_ipwritev; - ino->i_ops.inop_iodone = o->inop_iodone; - ino->i_ops.inop_datasync = o->inop_datasync; - ino->i_ops.inop_ioctl = o->inop_ioctl; + operations.inop_open = o->inop_open; + operations.inop_close = o->inop_close; + operations.inop_read = o->inop_read; + operations.inop_write = o->inop_write; + operations.inop_iodone = o->inop_iodone; + operations.inop_datasync = o->inop_datasync; + operations.inop_ioctl = o->inop_ioctl; } - I_INIT(ino, fs, type, rdev, &ino->i_ops, fid, immunity, private); + I_INIT(ino, fs, type, rdev, &operations, fid, immunity, private); ino->i_ref = 1; TAILQ_INSERT_TAIL(&_sysio_inodes, ino, i_nodes); head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; @@ -437,19 +460,46 @@ static void more_pnodes() { size_t n; +#if ZERO_SUM_MEMORY + struct pnodes_block *pnblk; +#endif struct pnode *pno; - n = (8 * 1024) / sizeof(struct pnode); /* numbers! */ - assert(n); - pno = malloc(n * sizeof(struct pnode)); +#if ZERO_SUM_MEMORY + pnblk = malloc(sizeof(struct pnodes_block)); + pno = NULL; + if (pnblk) { + LIST_INSERT_HEAD(&pnblocks, pnblk, pnblk_links); + pno = pnblk->pnblk_nodes; + } +#else + pno = malloc(PNODES_PER_CHUNK * sizeof(struct pnode)); +#endif if (!pno) return; + n = PNODES_PER_CHUNK; do { LIST_INSERT_HEAD(&free_pnodes, pno, p_links); pno++; } while (--n); } +#if ZERO_SUM_MEMORY +/* + * Shutdown + */ +void +_sysio_i_shutdown() +{ + struct pnodes_block *pnblk; + + while ((pnblk = pnblocks.lh_first)) { + LIST_REMOVE(pnblk, pnblk_links); + free(pnblk); + } +} +#endif + /* * Allocate, initialize and establish appropriate links for new path (alias) * node. Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- ioctx.c 17 Oct 2003 21:30:29 -0000 1.6 +++ ioctx.c 6 Feb 2004 20:07:30 -0000 1.7 @@ -9,7 +9,7 @@ * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * - * Cplant(TM) Copyright 1998-2003 Sandia Corporation. + * Cplant(TM) Copyright 1998-2004 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States @@ -51,16 +51,30 @@ #include "sysio.h" #include "inode.h" +#include "xtio.h" /* * Asynchronous IO context support. */ /* + * Arguments to IO vector enumerator callback when used by _sysio_doio(). + */ +struct doio_helper_args { + ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *); /* base func */ + void *arg; /* caller arg */ +}; + +/* * List of all outstanding (in-flight) asynch IO requests tracked * by the system. */ -LIST_HEAD( ,ioctx) aioq; +static LIST_HEAD( ,ioctx) aioq; + +/* + * Free callback entry. + */ +#define cb_free(cb) free(cb) /* * Initialization. Must be called before using any other routine in this @@ -75,39 +89,44 @@ _sysio_ioctx_init() } /* - * Allocate and initialisze a new IO context. + * Enter an IO context onto the async IO events queue. + */ +void +_sysio_ioctx_enter(struct ioctx *ioctx) +{ + + LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link); +} + +/* + * Allocate and initialize a new IO context. */ struct ioctx * _sysio_ioctx_new(struct inode *ino, const struct iovec *iov, size_t iovlen, - _SYSIO_OFF_T offset) + const struct intnl_xtvec *xtv, + size_t xtvlen) { struct ioctx *ioctx; - ioctx = - malloc(sizeof(struct ioctx) + iovlen * sizeof(struct iovec)); + ioctx = malloc(sizeof(struct ioctx)); if (!ioctx) return NULL; I_REF(ino); - ioctx->ioctx_iovec = (void *)ioctx + sizeof(struct ioctx); - (void )memcpy((void *)ioctx->ioctx_iovec, - iov, - iovlen * sizeof(struct iovec)); IOCTX_INIT(ioctx, 0, (ioid_t )ioctx, ino, - ioctx->ioctx_iovec, - iovlen, - offset); + iov, iovlen, + xtv, xtvlen); /* * Link request onto the outstanding requests queue. */ - LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link); + _sysio_ioctx_enter(ioctx); return ioctx; } @@ -166,7 +185,6 @@ _sysio_ioctx_find(ioid_t id) ssize_t _sysio_ioctx_wait(struct ioctx *ioctx) { - int err; ssize_t cc; /* @@ -179,7 +197,6 @@ _sysio_ioctx_wait(struct ioctx *ioctx) /* * Get status. */ - err = 0; cc = ioctx->ioctx_cc; if (cc < 0) cc = -ioctx->ioctx_errno; @@ -193,6 +210,16 @@ _sysio_ioctx_wait(struct ioctx *ioctx) } /* + * Free callback entry. + */ +void +_sysio_ioctx_cb_free(struct ioctx_callback *cb) +{ + + cb_free(cb); +} + +/* * Complete an asynchronous IO request. */ void @@ -206,17 +233,296 @@ _sysio_ioctx_complete(struct ioctx *ioct while ((entry = ioctx->ioctx_cbq.tqh_first)) { TAILQ_REMOVE(&ioctx->ioctx_cbq, entry, iocb_next); (*entry->iocb_f)(ioctx, entry->iocb_data); - free(entry); + cb_free(entry); } - if (ioctx->ioctx_fast) - return; - /* * Unlink from the file record's outstanding request queue. */ LIST_REMOVE(ioctx, ioctx_link); + if (ioctx->ioctx_fast) + return; + I_RELE(ioctx->ioctx_ino); + free(ioctx); } + +/* + * General help validating strided-IO vectors. + * + * A driver may call this to make sure underflow/overflow of an off_t can't + * occur and overflow of a ssize_t can't occur when writing. The sum + * of the reconciled transfer length is returned or some appropriate + * error depending on underflow/overflow. + * + * The following algorithm assumes: + * + * a) sizeof(size_t) >= sizeof(ssize_t) + * b) 2's complement arithmetic + * c) The compiler won't optimize away code because it's developers + * believed that something with an undefined result in `C' can't happen. + */ +ssize_t +_sysio_validx(const struct intnl_xtvec *xtv, size_t xtvlen, + const struct iovec *iov, size_t iovlen, + _SYSIO_OFF_T limit) +{ + ssize_t acc, cc; + struct iovec iovec; + struct intnl_xtvec xtvec; + _SYSIO_OFF_T off; + + if (!(xtvlen && iovlen)) + return -EINVAL; + + acc = 0; + xtvec.xtv_len = iovec.iov_len = 0; + do { + while (!xtvec.xtv_len) { + if (!xtvlen--) + break; + if (!xtv->xtv_len) { + xtv++; + continue; + } + xtvec = *xtv++; + if (xtvec.xtv_off < 0) + return -EINVAL; + } + if (!xtvec.xtv_len) + break; + do { + while (!iovec.iov_len) { + if (!iovlen--) + break; + if (!iov->iov_len) { + iov++; + continue; + } + iovec = *iov++; + } + if (!iovec.iov_len) + break; + cc = iovec.iov_len; + if (cc < 0) + return -EINVAL; + if ((size_t )cc > xtvec.xtv_len) + cc = xtvec.xtv_len; + xtvec.xtv_len -= cc; + iovec.iov_len -= cc; + off = xtvec.xtv_off + cc; + if (xtvec.xtv_off && off <= xtvec.xtv_off) + return off < 0 ? -EINVAL : -EOVERFLOW; + if (off > limit) + return -EFBIG; + xtvec.xtv_off = off; + cc += acc; + if (acc && (cc <= acc)) + return -EINVAL; + acc = cc; + } while (xtvec.xtv_len && iovlen); + } while ((xtvlen || xtvec.xtv_len) && iovlen); + return acc; +} + +/* + */ +ssize_t +_sysio_enumerate_extents(const struct intnl_xtvec *xtv, size_t xtvlen, + const struct iovec *iov, size_t iovlen, + ssize_t (*f)(const struct iovec *, int, + _SYSIO_OFF_T, + ssize_t, + void *), + void *arg) +{ + ssize_t acc, cc; + struct iovec iovec; + struct intnl_xtvec xtvec; + const struct iovec *start; + _SYSIO_OFF_T off; + size_t n; + + acc = 0; + iovec.iov_len = 0; + while (xtvlen) { + /* + * Coalesce contiguous extent vector entries. + */ + off = xtvec.xtv_off = xtv->xtv_off; + off += xtvec.xtv_len = xtv->xtv_len; + while (++xtv, --xtvlen) { + if (off != xtv->xtv_off) { + /* + * Not contiguous. + */ + break; + } + if (!xtv->xtv_len) { + /* + * Zero length. + */ + continue; + } + off += xtv->xtv_len; + xtvec.xtv_len += xtv->xtv_len; + } + while (xtvec.xtv_len) { + if (iovec.iov_len) { + cc = + (*f)(&iovec, 1, + xtvec.xtv_off, + xtvec.xtv_len, + arg); + if (cc <= 0) { + if (acc) + return acc; + return cc; + } + cc += acc; + if (acc && cc <= acc) + abort(); /* paranoia */ + acc = cc; + iovec.iov_base += cc; + iovec.iov_len -= cc; + } else { + start = iov; + n = xtvec.xtv_len; + do { + if (iov->iov_len > n) { + /* + * That'll do. + */ + break; + } + n -= iov->iov_len; + iov++; + } while (--iovlen); + if (iov == start) { + iovec = *iov++; + if (iovec.iov_len > n) + iovec.iov_len = n; + continue; + } + cc = + (*f)(start, iov - start, + xtvec.xtv_off, + xtvec.xtv_len - n, + arg); + if (cc <= 0) { + if (acc) + return acc; + return cc; + } + cc += acc; + if (acc && cc <= acc) + abort(); /* paranoia */ + acc = cc; + } + xtvec.xtv_off += cc; + xtvec.xtv_len -= cc; + } + } + return acc; +} + +ssize_t +_sysio_enumerate_iovec(const struct iovec *iov, size_t count, + _SYSIO_OFF_T off, + ssize_t limit, + ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), + void *arg) +{ + ssize_t acc, cc; + size_t n; + unsigned indx; + size_t remain; + + if (!count) + return -EINVAL; + assert(limit >= 0); + acc = 0; + n = limit; + for (indx = 0; indx < count; indx++) { + if (limit < 0 || iov[indx].iov_len < n) { + cc = (ssize_t )iov[indx].iov_len; + if (cc < 0) + return -EINVAL; + } else + cc = (ssize_t )n; + if (!cc) + continue; + n -= cc; + cc += acc; + if (acc && cc <= acc) + return -EINVAL; + acc = cc; + } + if (!acc) + return 0; + acc = 0; + do { + if (!iov->iov_len) { + iov++; + continue; + } + n = + limit < 0 || iov[indx].iov_len < (size_t )limit + ? iov[indx].iov_len + : (size_t )limit; + cc = (*f)(iov->iov_base, n, off, arg); + if (cc <= 0) { + if (acc) + return acc; + return cc; + } + remain = iov->iov_len - cc; + cc += acc; + if (acc && cc <= acc) + abort(); /* bad driver! */ + acc = cc; + if (remain) + break; /* short/limited read */ + iov++; + } while (--count); + return acc; +} + +static ssize_t +_sysio_doio_helper(const struct iovec *iov, int count, + _SYSIO_OFF_T off, + ssize_t limit, + struct doio_helper_args *args) +{ + + return _sysio_enumerate_iovec(iov, count, + off, limit, + args->f, + args->arg); +} + +/* + * A meta-driver for the whole strided-io process. Appropriate when + * the driver can't handle anything but simple p{read,write}-like + * interface. + */ +ssize_t +_sysio_doio(const struct intnl_xtvec *xtv, size_t xtvlen, + const struct iovec *iov, size_t iovlen, + ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), + void *arg) +{ + struct doio_helper_args arguments; + + arguments.f = f; + arguments.arg = arg; + return _sysio_enumerate_extents(xtv, xtvlen, + iov, iovlen, + (ssize_t (*)(const struct iovec *, int, + _SYSIO_OFF_T, + ssize_t, + void *))_sysio_doio_helper, + &arguments); +} Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -b -B -p -r1.11 -r1.12 --- lseek.c 26 Jan 2004 16:34:54 -0000 1.11 +++ lseek.c 6 Feb 2004 20:07:30 -0000 1.12 @@ -43,6 +43,7 @@ #include <errno.h> #include <unistd.h> +#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/queue.h> @@ -56,51 +57,50 @@ static _SYSIO_OFF_T _sysio_lseek(int fd, _SYSIO_OFF_T offset, int whence) { - int err; struct file *fil; - _SYSIO_OFF_T off = 0; + _SYSIO_OFF_T off, pos; struct intnl_stat stbuf; - err = 0; fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } + if (!fil) + return -EBADF; - off = fil->f_pos; + off = -1; switch (whence) { case SEEK_SET: - off = offset; + off = 0; break; case SEEK_CUR: - off += offset; + off = fil->f_pos; break; case SEEK_END: + { + int err; + err = (*fil->f_ino->i_ops.inop_getattr)(NULL, fil->f_ino, &stbuf); if (err) - break; + return err; + } off = stbuf.st_size; - off += offset; break; default: - err = -EINVAL; - goto out; + return -EINVAL; } - - if (off < 0) - err = -EINVAL; - -out: - if (err) { - errno = -err; - return -1; - } - return fil->f_pos = off; + pos = off + offset; + if (pos < 0 || (off && pos <= off)) + return -EINVAL; +#ifdef O_LARGEFILE + if (pos >= ((fil->f_flags & O_LARGEFILE) ? _SYSIO_OFF_T_MAX : LONG_MAX)) + return -EOVERFLOW; +#else + if (pos >= _SYSIO_OFF_T_MAX) + return -EOVERFLOW; +#endif + return fil->f_pos = pos; } #if _LARGEFILE64_SOURCE @@ -127,15 +127,12 @@ lseek(int fd, off_t offset, int whence) off = _sysio_lseek(fd, offset, whence); if (off < 0) { + errno = -off; SYSIO_LEAVE; return -1; } rtn = (off_t )off; - if ((_SYSIO_OFF_T )rtn != off) { - errno = EINVAL; - SYSIO_LEAVE; - return -1; - } + assert(rtn == off); SYSIO_LEAVE; return rtn; } Index: mkdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mkdir.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- mkdir.c 26 Jan 2004 16:34:54 -0000 1.5 +++ mkdir.c 6 Feb 2004 20:07:30 -0000 1.6 @@ -83,11 +83,11 @@ out: err = -1; } + SYSIO_LEAVE; + return err; +} #ifdef REDSTORM #undef __mkdir sysio_sym_weak_alias(mkdir, __mkdir) #endif - SYSIO_LEAVE; - return err; -} Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -b -B -p -r1.1 -r1.2 --- module.mk 16 Dec 2003 15:43:14 -0000 1.1 +++ module.mk 6 Feb 2004 20:07:30 -0000 1.2 @@ -5,9 +5,8 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/ioctl.c src/ioctx.c src/iowait.c \ src/link.c src/lseek.c src/mkdir.c \ src/mknod.c src/mount.c src/namei.c \ - src/open.c src/read.c src/rename.c \ + src/open.c src/rw.c src/rename.c \ src/rmdir.c src/stat64.c src/stat.c \ src/statvfs64.c src/statvfs.c src/symlink.c \ - src/truncate.c src/unlink.c src/utime.c \ - src/write.c + src/truncate.c src/unlink.c src/utime.c SRCDIR_EXTRA = src/module.mk Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- mount.c 27 Oct 2003 23:49:10 -0000 1.9 +++ mount.c 6 Feb 2004 20:07:30 -0000 1.10 @@ -57,6 +57,9 @@ #include "fs.h" #include "mount.h" #include "inode.h" +#ifdef AUTOMOUNT_FILE_NAME +#include "xtio.h" +#endif /* * File system and volume mount support. @@ -522,7 +525,6 @@ parse_opts(char *opts, unsigned *flagsp) flags |= MOUNT_F_RO; src += 2; } -#ifdef AUTOMOUNT_FILE_NAME else if (src + 4 == cp && strncmp(src, "auto", 4) == 0) { /* * Enable automounts. @@ -530,7 +532,6 @@ parse_opts(char *opts, unsigned *flagsp) flags |= MOUNT_F_AUTO; src += 4; } -#endif if (src < cp) { /* * Copy what we didn't consume. @@ -563,6 +564,7 @@ _sysio_automount(struct pnode *mntpno) struct intnl_stat stbuf; struct iovec iovec; struct ioctx iocontext; + struct intnl_xtvec xtvec; ssize_t cc; char *fstype, *source, *opts; unsigned flags; @@ -596,8 +598,16 @@ _sysio_automount(struct pnode *mntpno) err = _sysio_open(mntpno, O_RDONLY, 0); if (err) goto out; - IOCTX_INIT(&iocontext, 1, (ioid_t )&iocontext, ino, &iovec, 1, 0); - err = (*ino->i_ops.inop_ipreadv)(ino, &iocontext); + xtvec.xtv_off = 0; + xtvec.xtv_len = stbuf.st_size; + IOCTX_INIT(&iocontext, + 1, + (ioid_t )&iocontext, + ino, + &iovec, 1, + &xtvec, 1); + _sysio_ioctx_enter(&iocontext); + err = (*ino->i_ops.inop_read)(ino, &iocontext); if (err) { _sysio_ioctx_complete(&iocontext); (void )(*ino->i_ops.inop_close)(ino); Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- namei.c 12 Jan 2004 23:02:08 -0000 1.9 +++ namei.c 6 Feb 2004 20:07:30 -0000 1.10 @@ -244,20 +244,19 @@ _sysio_path_walk(struct pnode *parent, s nd->nd_pno = nameidata.nd_pno; ino = nd->nd_pno->p_base->pb_ino; } - #ifdef AUTOMOUNT_FILE_NAME - /* - * We're committed to a lookup. It's time to see if we're - * going to do it in an automount-point and arrange the - * mount if so. - */ - if (ino && + else if (ino && S_ISDIR(ino->i_mode) && (nd->nd_pno->p_mount->mnt_flags & MOUNT_F_AUTO) && nd->nd_amcnt < MAX_MOUNT_DEPTH && ino->i_mode & S_ISVTX) { struct pnode *pno; + /* + * We're committed to a lookup. It's time to see if + * we're going to do it in an automount-point and + * arrange the mount if so. + */ assert(!nd->nd_pno->p_cover); err = lookup(nd->nd_pno, @@ -265,6 +264,8 @@ _sysio_path_walk(struct pnode *parent, s &pno, NULL, NULL); + if (pno) + P_RELE(pno); if (!err && _sysio_automount(pno) == 0) { struct pnode *root; @@ -285,7 +286,9 @@ _sysio_path_walk(struct pnode *parent, s assert(root); P_RELE(nd->nd_pno); nd->nd_pno = root; +#if 0 P_REF(nd->nd_pno); +#endif ino = nd->nd_pno->p_base->pb_ino; assert(ino); @@ -293,13 +296,11 @@ _sysio_path_walk(struct pnode *parent, s * Must send the intent-path again. */ path = nd->nd_path; - } - if (!err) { - P_RELE(pno); nd->nd_amcnt++; + /* * Must go back top and retry with this - * new pnode. + * new pnode as parent. */ continue; } @@ -426,7 +427,7 @@ _sysio_path_walk(struct pnode *parent, s * On error, we will want to drop our reference to the current * path node if at end. */ - if (err) { + if (err && nd->nd_pno) { P_RELE(nd->nd_pno); nd->nd_pno = NULL; } Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- rmdir.c 26 Jan 2004 16:34:54 -0000 1.6 +++ rmdir.c 6 Feb 2004 20:07:30 -0000 1.7 @@ -84,11 +84,12 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; + return err; +} #ifdef REDSTORM #undef __rmdir sysio_sym_weak_alias(rmdir, __rmdir) #endif - return err; -} Index: statvfs64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- statvfs64.c 26 Jan 2004 16:34:54 -0000 1.7 +++ statvfs64.c 6 Feb 2004 20:07:30 -0000 1.8 @@ -76,14 +76,14 @@ out: } SYSIO_LEAVE; + return err; +} + #ifdef REDSTORM #undef __statvfs64 sysio_sym_weak_alias(statvfs64, __statvfs64) #endif - return err; -} - int fstatvfs64(int fd, struct statvfs64 *buf) { Index: symlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/symlink.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- symlink.c 26 Jan 2004 16:34:54 -0000 1.5 +++ symlink.c 6 Feb 2004 20:07:30 -0000 1.6 @@ -84,10 +84,10 @@ out: err = -1; } SYSIO_LEAVE; + return err; +} #ifdef REDSTORM #undef __symlink sysio_sym_weak_alias(symlink, __symlink) #endif - return err; -} Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- truncate.c 21 Jan 2004 14:44:53 -0000 1.6 +++ truncate.c 6 Feb 2004 20:07:30 -0000 1.7 @@ -64,6 +64,9 @@ do_truncate(struct pnode *pno, struct in struct intnl_stat stbuf; unsigned mask; + if (length < 0) + return -EINVAL; + if (!ino && pno->p_base->pb_ino) ino = pno->p_base->pb_ino; if (!ino) Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- unlink.c 26 Jan 2004 16:34:54 -0000 1.7 +++ unlink.c 6 Feb 2004 20:07:30 -0000 1.8 @@ -85,10 +85,10 @@ out: err = -1; } SYSIO_LEAVE; + return err; +} #ifdef REDSTORM #undef __unlink sysio_sym_weak_alias(unlink, __unlink) #endif - return err; -} |