[Libsysio-commit] unification: libsysio/src chdir.c chmod.c chown.c dev.c fcntl.c file.c file_hack.
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-02-05 15:54:37
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6564/src Modified Files: Tag: unification chdir.c chmod.c chown.c dev.c fcntl.c file.c file_hack.c fsync.c getdirentries.c init.c inode.c ioctl.c ioctx.c link.c lseek.c mkdir.c mknod.c module.mk mount.c namei.c open.c readlink.c rename.c rmdir.c rw.c stat.c statvfs.c statvfs64.c symlink.c truncate.c unlink.c utime.c Removed Files: Tag: unification stat64.c Log Message: The open file table now maintains a link to the path-node, or `pnode', instead of the inode. This is done in order to enable support for per-mount options. The issue is that bound-mounts could not have independent options. We had lost the linkage between the mount that a particular alias came from and, so, could not act on per-mount flags. As part of this, all calls through the VFS have been wrapped by macros. They all begin with PNOP_. For instance, the inop_mkdir call is wrapped with PNOP_MKDIR now. These modifications, while intrusive, require no changes to the existing drivers. However, there are many calls that take both a path-node and an inode, and at some time in the future, the path-node, only, will be passed. You might be pro-active in altering the various entry-points so that the inode is ignored -- It's always available now. Of course, that can't be done for the IO routines, which take only an inode. Note, though, that the ioctx structure now carries the path-node, in addition. Perhaps use that? In short, I'm going to deprecate the passing of inodes through the VFS in favor of the path-node at some point. Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -w -b -B -p -r1.25 -r1.25.2.1 --- chdir.c 3 May 2006 22:34:46 -0000 1.25 +++ chdir.c 5 Feb 2007 15:54:27 -0000 1.25.2.1 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 Index: chmod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v retrieving revision 1.14 retrieving revision 1.14.10.1 diff -u -w -b -B -p -r1.14 -r1.14.10.1 --- chmod.c 27 Jul 2004 15:00:43 -0000 1.14 +++ chmod.c 5 Feb 2007 15:54:27 -0000 1.14.10.1 @@ -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-2007 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 @@ -55,7 +55,7 @@ #include "sysio-symbols.h" static int -do_chmod(struct pnode *pno, struct inode *ino, mode_t mode) +do_chmod(struct pnode *pno, mode_t mode) { int err; struct intnl_stat stbuf; @@ -64,7 +64,7 @@ do_chmod(struct pnode *pno, struct inode (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); stbuf.st_mode = mode & 07777; mask = SETATTR_MODE; - err = _sysio_setattr(pno, ino, mask, &stbuf); + err = _sysio_setattr(pno, mask, &stbuf); return err; } @@ -79,7 +79,7 @@ SYSIO_INTERFACE_NAME(chmod)(const char * err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) goto out; - err = do_chmod(pno, pno->p_base->pb_ino, mode); + err = do_chmod(pno, mode); P_RELE(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); @@ -106,7 +106,7 @@ SYSIO_INTERFACE_NAME(fchmod)(int fd, mod goto out; } - err = do_chmod(NULL, fil->f_ino, mode); + err = do_chmod(fil->f_pno, mode); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); } Index: chown.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v retrieving revision 1.13 retrieving revision 1.13.10.1 diff -u -w -b -B -p -r1.13 -r1.13.10.1 --- chown.c 27 Jul 2004 15:00:43 -0000 1.13 +++ chown.c 5 Feb 2007 15:54:27 -0000 1.13.10.1 @@ -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-2007 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 @@ -55,7 +55,7 @@ #include "sysio-symbols.h" static int -_do_chown(struct pnode *pno, struct inode *ino, uid_t owner, gid_t group) +_do_chown(struct pnode *pno, uid_t owner, gid_t group) { int err; struct intnl_stat stbuf; @@ -71,7 +71,7 @@ _do_chown(struct pnode *pno, struct inod stbuf.st_gid = group; mask |= SETATTR_GID; } - err = _sysio_setattr(pno, ino, mask, &stbuf); + err = _sysio_setattr(pno, mask, &stbuf); return err; } @@ -87,7 +87,7 @@ SYSIO_INTERFACE_NAME(chown)(const char * if (err) goto out; - err = _do_chown(pno, pno->p_base->pb_ino, owner, group); + err = _do_chown(pno, owner, group); P_RELE(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); @@ -114,7 +114,7 @@ SYSIO_INTERFACE_NAME(fchown)(int fd, uid goto out; } - err = _do_chown(NULL, fil->f_ino, owner, group); + err = _do_chown(fil->f_pno, owner, group); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); } Index: dev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -u -w -b -B -p -r1.10 -r1.10.4.1 --- dev.c 4 Aug 2005 20:17:10 -0000 1.10 +++ dev.c 5 Feb 2007 15:54:27 -0000 1.10.4.1 @@ -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-2007 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 Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -w -b -B -p -r1.25 -r1.25.2.1 --- fcntl.c 24 Mar 2006 16:34:07 -0000 1.25 +++ fcntl.c 5 Feb 2007 15:54:27 -0000 1.25.2.1 @@ -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-2005 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -73,13 +73,13 @@ _sysio_lustre_fcntl(int fd, int cmd, va_ #endif static int -_sysio_fcntl_raw_call(struct inode *ino, int *r, int cmd, ...) +_sysio_fcntl_raw_call(struct pnode *pno, int *r, int cmd, ...) { va_list ap; int err; va_start(ap, cmd); - err = ino->i_ops.inop_fcntl(ino, cmd, ap, r); + err = PNOP_FCNTL(pno, cmd, ap, r); va_end(ap); return err; } @@ -125,7 +125,7 @@ _sysio_fcntl_lock(struct file *fil, int return -EINVAL; } err = - _sysio_fcntl_raw_call(fil->f_ino, &rtn, cmd, &flock); + _sysio_fcntl_raw_call(fil->f_pno, &rtn, cmd, &flock); if (err) return err; /* @@ -141,7 +141,7 @@ _sysio_fcntl_lock(struct file *fil, int case SEEK_END: fl->l_start = flock.l_start; fl->l_start -= - fil->f_ino->i_stbuf.st_size; + fil->f_pno->p_base->pb_ino->i_stbuf.st_size; break; default: abort(); @@ -208,9 +208,7 @@ _sysio_vfcntl(int fd, int cmd, va_list a * Refresh the cached attributes. */ err = - fil->f_ino->i_ops.inop_getattr(NULL, - fil->f_ino, - &buf); + PNOP_GETATTR(fil->f_pno, &buf); if (err) { rtn = -1; break; @@ -264,7 +262,7 @@ _sysio_vfcntl(int fd, int cmd, va_list a break; #endif default: - err = fil->f_ino->i_ops.inop_fcntl(fil->f_ino, cmd, ap, &rtn); + err = PNOP_FCNTL(fil->f_pno, cmd, ap, &rtn); break; } Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -w -b -B -p -r1.20 -r1.20.2.1 --- file.c 3 Jan 2006 13:26:33 -0000 1.20 +++ file.c 5 Feb 2007 15:54:27 -0000 1.20.2.1 @@ -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-2007 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 @@ -66,7 +66,7 @@ static size_t _sysio_oftab_size = 0; * Create and initialize open file record. */ struct file * -_sysio_fnew(struct inode *ino, int flags) +_sysio_fnew(struct pnode *pno, int flags) { struct file *fil; @@ -74,9 +74,9 @@ _sysio_fnew(struct inode *ino, int flags if (!fil) return NULL; - _SYSIO_FINIT(fil, ino, flags); + _SYSIO_FINIT(fil, pno, flags); F_REF(fil); - I_REF(fil->f_ino); + P_REF(fil->f_pno); return fil; } @@ -90,10 +90,10 @@ _sysio_fgone(struct file *fil) int err; assert(!fil->f_ref); - assert(fil->f_ino); - err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino); + assert(fil->f_pno); + err = PNOP_CLOSE(fil->f_pno); assert(!err); - I_RELE(fil->f_ino); + P_RELE(fil->f_pno); free(fil); } @@ -108,7 +108,7 @@ _sysio_fcompletio(struct ioctx *ioctx, s if (ioctx->ioctx_cc <= 0) return; - assert(ioctx->ioctx_ino == fil->f_ino); + assert(ioctx->ioctx_ino == fil->f_pno->p_base->pb_ino); off = fil->f_pos + ioctx->ioctx_cc; if (fil->f_pos && off <= fil->f_pos) abort(); Index: file_hack.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file_hack.c,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -w -b -B -p -r1.10 -r1.10.2.1 --- file_hack.c 4 Jan 2006 13:16:18 -0000 1.10 +++ file_hack.c 5 Feb 2007 15:54:27 -0000 1.10.2.1 @@ -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-2007 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 @@ -97,7 +97,7 @@ static inline oftab_t *select_oftab(int * Create and initialize open file record. */ struct file * -_sysio_fnew(struct inode *ino, int flags) +_sysio_fnew(struct pnode *pno, int flags) { struct file *fil; @@ -105,9 +105,9 @@ _sysio_fnew(struct inode *ino, int flags if (!fil) return NULL; - _SYSIO_FINIT(fil, ino, flags); + _SYSIO_FINIT(fil, pno, flags); F_REF(fil); - I_REF(ino); + P_REF(pno); return fil; } @@ -121,9 +121,9 @@ _sysio_fgone(struct file *fil) int err; assert(!fil->f_ref); - assert(fil->f_ino); - err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino); - I_RELE(fil->f_ino); + assert(fil->f_pno); + err = PNOP_CLOSE(fil->f_pno); + P_RELE(fil->f_pno); assert(!err); free(fil); } @@ -139,7 +139,7 @@ _sysio_fcompletio(struct ioctx *ioctx, s if (ioctx->ioctx_cc <= 0) return; - assert(ioctx->ioctx_ino == fil->f_ino); + assert(ioctx->ioctx_ino == fil->f_pno->p_base->pb_ino); off = fil->f_pos + ioctx->ioctx_cc; if (fil->f_pos && off <= fil->f_pos) abort(); Index: fsync.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fsync.c,v retrieving revision 1.8 retrieving revision 1.8.8.1 diff -u -w -b -B -p -r1.8 -r1.8.8.1 --- fsync.c 21 Sep 2004 16:18:30 -0000 1.8 +++ fsync.c 5 Feb 2007 15:54:27 -0000 1.8.8.1 @@ -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-2007 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 @@ -60,9 +60,9 @@ SYSIO_INTERFACE_NAME(fsync)(int fd) SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) + if (!(fil && fil->f_pno)) SYSIO_INTERFACE_RETURN(-1, -EBADF); - err = (*fil->f_ino->i_ops.inop_sync)(fil->f_ino); + err = PNOP_SYNC(fil->f_pno); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); } @@ -75,8 +75,8 @@ SYSIO_INTERFACE_NAME(fdatasync)(int fd) SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) + if (!(fil && fil->f_pno)) SYSIO_INTERFACE_RETURN(-1, -EBADF); - err = (*fil->f_ino->i_ops.inop_datasync)(fil->f_ino); + err = PNOP_DATASYNC(fil->f_pno); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); } Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.20 retrieving revision 1.20.4.1 diff -u -w -b -B -p -r1.20 -r1.20.4.1 --- getdirentries.c 4 Aug 2005 20:17:10 -0000 1.20 +++ getdirentries.c 5 Feb 2007 15:54:27 -0000 1.20.4.1 @@ -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-2004 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -92,14 +92,14 @@ filldirents(struct file *fil, _SYSIO_OFF_T opos; ssize_t cc; - if (!S_ISDIR(fil->f_ino->i_stbuf.st_mode)) + if(!fil->f_pno->p_base->pb_ino) + return -EBADF; + if (!S_ISDIR(fil->f_pno->p_base->pb_ino->i_stbuf.st_mode)) return -ENOTDIR; opos = fil->f_pos; cc = - (*fil->f_ino->i_ops.inop_filldirentries)(fil->f_ino, - &fil->f_pos, - buf, nbytes); + PNOP_FILLDIRENTRIES(fil->f_pno, &fil->f_pos, buf, nbytes); if (cc < 0) return cc; *basep = opos; @@ -120,9 +120,6 @@ PREPEND(_, SYSIO_INTERFACE_NAME(getdiren SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - return -EBADF; - cc = filldirents(fil, buf, nbytes, basep); SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0); } @@ -190,9 +187,6 @@ SYSIO_INTERFACE_NAME(getdirentries)(int SYSIO_INTERFACE_ENTER; fil = _sysio_fd_find(fd); - if (!(fil && fil->f_ino)) - return -EBADF; - count = cc = filldirents(fil, buf, nbytes, &b); d64p = (void *)buf; dp = (void *)buf; Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.30 retrieving revision 1.30.2.1 diff -u -w -b -B -p -r1.30 -r1.30.2.1 --- init.c 4 May 2006 02:31:05 -0000 1.30 +++ init.c 5 Feb 2007 15:54:27 -0000 1.30.2.1 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -547,7 +547,6 @@ do_creat(char *args) CREATE_FILE = 4 } op; int intent_mode; - struct inode *ino; int i; len = strlen(args); @@ -639,7 +638,6 @@ do_creat(char *args) err = _sysio_open(pno, O_CREAT|O_EXCL, mode); if (err) break; - ino = pno->p_base->pb_ino; if (v[6].ovi_value) { struct iovec iovec; struct intnl_xtvec xtvec; @@ -655,13 +653,12 @@ do_creat(char *args) IOCTX_INIT(&io_context, 1, 1, - ino, + pno, &iovec, 1, &xtvec, 1); _sysio_ioctx_enter(&io_context); err = - (*ino->i_ops.inop_write)(pno->p_base->pb_ino, - &io_context); + PNOP_WRITE(pno, &io_context); if (!err) { ssize_t cc; @@ -673,7 +670,7 @@ do_creat(char *args) } else _sysio_ioctx_complete(&io_context); } - i = (*ino->i_ops.inop_close)(ino); + i = PNOP_CLOSE(pno); if (!err) err = i; break; @@ -821,7 +818,7 @@ do_chmd(char *args) err = _sysio_namei(dir, v[0].ovi_value, ND_NOPERMCHECK, NULL, &pno); if (err) return err; - err = _sysio_setattr(pno, pno->p_base->pb_ino, SETATTR_MODE, &stbuf); + err = _sysio_setattr(pno, SETATTR_MODE, &stbuf); P_RELE(pno); return err; @@ -873,7 +870,7 @@ do_open(char *args) err = _sysio_open(pno, m, 0); if (err) break; - fil = _sysio_fnew(pno->p_base->pb_ino, m); + fil = _sysio_fnew(pno, m); if (!fil) { err = -ENOMEM; break; Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -w -b -B -p -r1.25 -r1.25.2.1 --- inode.c 1 Jun 2006 21:28:57 -0000 1.25 +++ inode.c 5 Feb 2007 15:54:27 -0000 1.25.2.1 @@ -396,7 +396,6 @@ _sysio_pb_new(struct qstr *name, struct cp = (char *)pb + sizeof(struct pnode_base); (void )strncpy(cp, name->name, name->len); pb->pb_name.name = cp; - assert(name->hashval); pb->pb_name.hashval = name->hashval; LIST_INSERT_HEAD(&names[name->hashval % NAMES_TABLE_LEN], pb, @@ -435,12 +434,6 @@ pb_destroy(struct pnode_base *pb) if (pb->pb_parent) LIST_REMOVE(pb, pb_sibs); -#ifndef NDEBUG - /* - * This can help us catch pb-nodes that are free'd redundantly. - */ - pb->pb_name.hashval = 0; -#endif free(pb); } @@ -516,8 +509,6 @@ _sysio_p_new_alias(struct pnode *parent, { struct pnode *pno; - assert(!pb->pb_name.name || pb->pb_name.hashval); - pno = free_pnodes.lh_first; if (!pno) { more_pnodes(); @@ -562,35 +553,56 @@ _sysio_p_gone(struct pnode *pno) } /* + * Disconnect name referenced by the given path node from our reflection of + * the graph. + */ +void +_sysio_pb_disconnect(struct pnode_base *pb) +{ + /* + * We can't really do this. Callers aren't prepared to have + * path nodes disappear out from underneath. Then, there might be + * referenced aliases. Instead, we arrange things so that the + * referenced path-base node will never be found by the graph + * search routines again. + */ + pb->pb_parent = pb; +} + +/* * (Re)Validate passed path node. */ int _sysio_p_validate(struct pnode *pno, struct intent *intnt, const char *path) { struct inode *ino; - struct pnode_base *rootpb; int err; ino = pno->p_base->pb_ino; + err = PNOP_LOOKUP(pno, &ino, intnt, path); + if (!err) { + if (pno->p_base->pb_ino == NULL) { /* - * An invalid pnode will not have an associated inode. We'll use - * the FS root inode, then -- It *must* be valid. + * Make valid. */ - rootpb = pno->p_mount->mnt_root->p_base; - assert(rootpb->pb_ino); - err = - rootpb->pb_ino->i_ops.inop_lookup(pno, - &ino, - intnt, - path); - /* - * If the inode lookup returns a different inode, release the old if - * present and point to the new. - */ - if (err || pno->p_base->pb_ino != ino) { - if (pno->p_base->pb_ino) - I_RELE(pno->p_base->pb_ino); pno->p_base->pb_ino = ino; + } else if (pno->p_base->pb_ino != ino) { + /* + * Path resolves to a different inode, now. The + * currently attached inode, then, is stale. + */ + err = -ESTALE; + I_RELE(ino); + } + } + if (err && pno->p_base->pb_ino) { + /* + * Something has gone wrong with a valid path-base node. We + * need to disconnect the underlying path-base node from the + * tree. Setting the hash value of the name to zero will + * cause the graph search routines to ignore the node. + */ + _sysio_pb_disconnect(pno->p_base); } return err; } @@ -608,9 +620,13 @@ _sysio_p_find_alias(struct pnode *parent int err; struct pnode *pno; + if (!parent) + return -ENOENT; + /* * Find the named child. */ + pb = NULL; if (name->len) { /* * Try the names table. @@ -625,20 +641,6 @@ _sysio_p_find_alias(struct pnode *parent break; pb = pb->pb_names.le_next; } - } else { - /* - * Brute force through the parent's list of children. - */ - pb = parent->p_base->pb_children.lh_first; - while (pb) { - if (pb->pb_parent == parent->p_base && - pb->pb_name.len == name->len && - strncmp(pb->pb_name.name, - name->name, - name->len) == 0) - break; - pb = pb->pb_sibs.le_next; - } } if (!pb) { /* @@ -663,8 +665,7 @@ _sysio_p_find_alias(struct pnode *parent } if (!pno) { /* - * Hmm. No alias. Just create an invalid one, to be - * validated later. + * Hmm. No alias. Create one. */ pno = _sysio_p_new_alias(parent, pb, parent->p_mount); if (!pno) @@ -676,7 +677,7 @@ _sysio_p_find_alias(struct pnode *parent } /* - * Prune idle path base nodes freom the passed sub-tree, including the root. + * Prune idle path base nodes from the passed sub-tree, including the root. */ static void _sysio_prune(struct pnode_base *rpb) @@ -744,8 +745,6 @@ _sysio_p_prune(struct pnode *root) continue; } assert(!pno->p_cover); /* covered => ref'd! */ - assert(!pno->p_base->pb_name.name || - pno->p_base->pb_name.hashval); /* * Ok to prune. */ @@ -812,9 +811,9 @@ _sysio_p_prune(struct pnode *root) char * _sysio_pb_path(struct pnode_base *pb, const char separator) { - char *buf; size_t len, n; struct pnode_base *tmp; + char *buf; char *cp; /* @@ -829,15 +828,21 @@ _sysio_pb_path(struct pnode_base *pb, co if (n) len++; tmp = tmp->pb_parent; - } while (tmp); + } while (tmp && tmp != tmp->pb_parent); if (!len) len++; + if (tmp && tmp->pb_parent == tmp) + len = 0; /* * Alloc space. */ buf = malloc(len + 1); if (!buf) return NULL; + if (tmp && tmp->pb_parent == tmp) { + buf[0] = '\0'; + return buf; + } /* * Fill in the path buffer -- Backwards, since we're starting * from the end. @@ -865,19 +870,9 @@ _sysio_pb_path(struct pnode_base *pb, co */ int _sysio_setattr(struct pnode *pno, - struct inode *ino, unsigned mask, struct intnl_stat *stbuf) { - /* - * It is possible that pno is null (for ftruncate call). - */ - - if (pno) - assert(!ino || pno->p_base->pb_ino == ino); - if (!ino) - ino = pno->p_base->pb_ino; - assert(ino); if (pno && IS_RDONLY(pno)) return -EROFS; @@ -886,7 +881,7 @@ _sysio_setattr(struct pnode *pno, * Determining permission to change the attributes is * difficult, at best. Just try it. */ - return (*ino->i_ops.inop_setattr)(pno, ino, mask, stbuf); + return PNOP_SETATTR(pno, mask, stbuf); } /* Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.12 retrieving revision 1.12.8.1 diff -u -w -b -B -p -r1.12 -r1.12.8.1 --- ioctl.c 21 Sep 2004 16:18:31 -0000 1.12 +++ ioctl.c 5 Feb 2007 15:54:27 -0000 1.12.8.1 @@ -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-2007 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 @@ -70,7 +70,7 @@ SYSIO_INTERFACE_NAME(ioctl)(int fd, unsi } va_start(ap, request); - err = fil->f_ino->i_ops.inop_ioctl(fil->f_ino, request, ap); + err = PNOP_IOCTL(fil->f_pno, request, ap); va_end(ap); out: Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.24 retrieving revision 1.24.4.1 diff -u -w -b -B -p -r1.24 -r1.24.4.1 --- ioctx.c 16 Jun 2005 21:21:42 -0000 1.24 +++ ioctx.c 5 Feb 2007 15:54:27 -0000 1.24.4.1 @@ -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-2004 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -101,7 +101,7 @@ _sysio_ioctx_enter(struct ioctx *ioctx) * Allocate and initialize a new IO context. */ struct ioctx * -_sysio_ioctx_new(struct inode *ino, +_sysio_ioctx_new(struct pnode *pno, int wr, const struct iovec *iov, size_t iovlen, @@ -114,12 +114,12 @@ _sysio_ioctx_new(struct inode *ino, if (!ioctx) return NULL; - I_REF(ino); + P_REF(pno); IOCTX_INIT(ioctx, 0, wr, - ino, + pno, iov, iovlen, xtv, xtvlen); @@ -184,7 +184,7 @@ _sysio_ioctx_done(struct ioctx *ioctx) if (ioctx->ioctx_done) return 1; - if (!(*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx)) + if (!PNOP_IODONE(ioctx->ioctx_pno, ioctx)) return 0; ioctx->ioctx_done = 1; return 1; @@ -264,8 +264,6 @@ _sysio_ioctx_complete(struct ioctx *ioct if (ioctx->ioctx_fast) return; - - I_RELE(ioctx->ioctx_ino); - + P_RELE(ioctx->ioctx_pno); free(ioctx); } Index: link.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/link.c,v retrieving revision 1.12 retrieving revision 1.12.4.1 diff -u -w -b -B -p -r1.12 -r1.12.4.1 --- link.c 25 Jan 2005 18:56:14 -0000 1.12 +++ link.c 5 Feb 2007 15:54:28 -0000 1.12.4.1 @@ -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-2007 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 @@ -89,7 +89,7 @@ SYSIO_INTERFACE_NAME(link)(const char *o * driver is implemented using differentiated inode operations based * on file type, such as incore does. */ - err = old->p_parent->p_base->pb_ino->i_ops.inop_link(old, new); + err = PNOP_LINK(old, new); if (err) goto error2; /* Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -w -b -B -p -r1.27 -r1.27.2.1 --- lseek.c 28 Oct 2005 17:59:31 -0000 1.27 +++ lseek.c 5 Feb 2007 15:54:28 -0000 1.27.2.1 @@ -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-2005 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -82,10 +82,7 @@ _sysio_lseek_prepare(struct file *fil, * in the inode record for this. Give the * driver a chance to refresh them. */ - err = - (*fil->f_ino->i_ops.inop_getattr)(NULL, - fil->f_ino, - &stbuf); + err = PNOP_GETATTR(fil->f_pno, &stbuf); if (err) return err; @@ -114,7 +111,7 @@ _sysio_lseek(struct file *fil, pos = _sysio_lseek_prepare(fil, offset, whence, max); if (pos < 0) return pos; - pos = (fil->f_ino->i_ops.inop_pos)(fil->f_ino, pos); + pos = PNOP_POS(fil->f_pno, pos); if (pos < 0) return pos; fil->f_pos = pos; Index: mkdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mkdir.c,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -u -w -b -B -p -r1.19 -r1.19.2.1 --- mkdir.c 1 Jun 2006 21:28:57 -0000 1.19 +++ mkdir.c 5 Feb 2007 15:54:28 -0000 1.19.2.1 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -58,7 +58,6 @@ int _sysio_mkdir(struct pnode *pno, mode_t mode) { int err; - struct inode *parenti; if (pno->p_base->pb_ino) return -EEXIST; @@ -68,9 +67,7 @@ _sysio_mkdir(struct pnode *pno, mode_t m return err; mode |= S_IFDIR; - parenti = pno->p_parent->p_base->pb_ino; - assert(parenti); - return (*parenti->i_ops.inop_mkdir)(pno, mode); + return PNOP_MKDIR(pno, mode); } int Index: mknod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mknod.c,v retrieving revision 1.18 retrieving revision 1.18.2.1 diff -u -w -b -B -p -r1.18 -r1.18.2.1 --- mknod.c 3 May 2006 22:31:04 -0000 1.18 +++ mknod.c 5 Feb 2007 15:54:28 -0000 1.18.2.1 @@ -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-2007 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 @@ -82,9 +82,7 @@ _sysio_mknod(struct pnode *pno, mode_t m if (IS_RDONLY(pno)) return -EROFS; - return (*pno->p_parent->p_base->pb_ino->i_ops.inop_mknod)(pno, - mode, - dev); + return PNOP_MKNOD(pno, mode, dev); } int Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.10 retrieving revision 1.10.8.1 diff -u -w -b -B -p -r1.10 -r1.10.8.1 --- module.mk 25 Oct 2004 14:29:16 -0000 1.10 +++ module.mk 5 Feb 2007 15:54:28 -0000 1.10.8.1 @@ -23,7 +23,7 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/link.c src/lseek.c src/mkdir.c \ src/mknod.c src/mount.c src/namei.c \ src/open.c src/rw.c src/reconcile.c src/rename.c \ - src/rmdir.c src/stat64.c src/stat.c \ + src/rmdir.c src/stat.c \ src/stddir.c src/readdir.c src/readdir64.c \ src/symlink.c src/readlink.c \ src/truncate.c src/unlink.c src/utime.c \ Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.21 retrieving revision 1.21.4.1 diff -u -w -b -B -p -r1.21 -r1.21.4.1 --- mount.c 25 Jan 2005 00:37:14 -0000 1.21 +++ mount.c 5 Feb 2007 15:54:28 -0000 1.21.4.1 @@ -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-2004 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -680,18 +680,18 @@ _sysio_automount(struct pnode *mntpno) IOCTX_INIT(&iocontext, 1, 0, - ino, + mntpno, &iovec, 1, &xtvec, 1); _sysio_ioctx_enter(&iocontext); - err = (*ino->i_ops.inop_read)(ino, &iocontext); + err = PNOP_READ(mntpno, &iocontext); if (err) { _sysio_ioctx_complete(&iocontext); - (void )(*ino->i_ops.inop_close)(ino); + (void )PNOP_CLOSE(mntpno); goto out; } cc = _sysio_ioctx_wait(&iocontext); - err = (*ino->i_ops.inop_close)(ino); + err = PNOP_CLOSE(mntpno); if (err) goto out; if (cc < 0) { Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -u -w -b -B -p -r1.23 -r1.23.2.1 --- namei.c 4 May 2006 02:32:08 -0000 1.23 +++ namei.c 5 Feb 2007 15:54:28 -0000 1.23.2.1 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -94,6 +94,12 @@ lookup(struct pnode *parent, int err; struct pnode *pno; + assert(parent != NULL); + /* + * The parent must be valid and should be connected or a root. + */ + if (parent->p_base->pb_parent == parent->p_base) + return -ENOENT; if (!parent->p_base->pb_ino) return -ENOTDIR; @@ -125,6 +131,10 @@ lookup(struct pnode *parent, if (err) return err; } + if (pno->p_base->pb_parent == pno->p_base) { + P_RELE(pno); + return -ENOENT; + } /* * While covered, move to the covering node. @@ -256,10 +266,7 @@ _sysio_path_walk(struct pnode *parent, s err = -ENOMEM; break; } - cc = - ino->i_ops.inop_readlink(nd->nd_pno, - lpath, - MAXPATHLEN); + cc = PNOP_READLINK(nd->nd_pno, lpath, MAXPATHLEN); if (cc < 0) { free(lpath); err = (int )cc; Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.28 retrieving revision 1.28.2.1 diff -u -w -b -B -p -r1.28 -r1.28.2.1 --- open.c 3 May 2006 22:34:46 -0000 1.28 +++ open.c 5 Feb 2007 15:54:28 -0000 1.28.2.1 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -77,7 +77,6 @@ _sysio_open(struct pnode *pno, int flags int ro; int w; int err; - struct inode *ino; ro = IS_RDONLY(pno); w = flags & (O_WRONLY|O_RDWR); @@ -89,35 +88,29 @@ _sysio_open(struct pnode *pno, int flags } if (w && ro) return -EROFS; - ino = pno->p_base->pb_ino; - if ((flags & O_CREAT) && !ino) { - struct pnode *parent; - + if ((flags & O_CREAT) && !pno->p_base->pb_ino) { /* * Must create it. */ if (ro) return -EROFS; - parent = pno->p_parent; - err = _sysio_p_validate(parent, NULL, NULL); - if (!err) { - ino = parent->p_base->pb_ino; - assert(ino); - err = (*ino->i_ops.inop_open)(pno, flags, mode); - } + err = _sysio_p_validate(pno->p_parent, NULL, NULL); + if (!err) + err = PNOP_OPEN(pno, flags, mode); } else if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) err = -EEXIST; - else if (!ino) + else if (!pno->p_base->pb_ino) err = _sysio_p_validate(pno, NULL, NULL); #ifdef O_NOFOLLOW - else if (flags & O_NOFOLLOW && S_ISLNK(ino->i_stbuf.st_mode)) + else if (flags & O_NOFOLLOW && + S_ISLNK(pno->p_base->pb_ino->i_stbuf.st_mode)) err = -ELOOP; #endif else { /* * Simple open of pre-existing file. */ - err = (*ino->i_ops.inop_open)(pno, flags, mode); + err = PNOP_OPEN(pno, flags, mode); } return err; @@ -188,7 +181,7 @@ SYSIO_INTERFACE_NAME(open)(const char *p /* * Get a file descriptor. */ - fil = _sysio_fnew(pno->p_base->pb_ino, flags); + fil = _sysio_fnew(pno, flags); if (!fil) { rtn = -ENOMEM; goto error; Index: readlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/readlink.c,v retrieving revision 1.6 retrieving revision 1.6.8.1 diff -u -w -b -B -p -r1.6 -r1.6.8.1 --- readlink.c 14 Oct 2004 14:59:29 -0000 1.6 +++ readlink.c 5 Feb 2007 15:54:28 -0000 1.6.8.1 @@ -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-2004 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -61,7 +61,6 @@ SYSIO_INTERFACE_NAME(readlink)(const cha struct intent intent; int err; struct pnode *pno; - struct inode *ino; SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER; @@ -69,12 +68,11 @@ SYSIO_INTERFACE_NAME(readlink)(const cha err = _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); if (err) goto out; - ino = pno->p_base->pb_ino; - if (!S_ISLNK(ino->i_stbuf.st_mode)) { + if (!S_ISLNK(pno->p_base->pb_ino->i_stbuf.st_mode)) { err = -EINVAL; goto error; } - err = (*ino->i_ops.inop_readlink)(pno, buf, bufsiz); + err = PNOP_READLINK(pno, buf, bufsiz); error: P_RELE(pno); out: Index: rename.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rename.c,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -u -w -b -B -p -r1.11 -r1.11.4.1 --- rename.c 25 Jan 2005 18:56:15 -0000 1.11 +++ rename.c 5 Feb 2007 15:54:28 -0000 1.11.4.1 @@ -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-2007 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 @@ -161,21 +161,15 @@ SYSIO_INTERFACE_NAME(rename)(const char err = -EBUSY; goto error1; } - /* - * Use the parent node operations to request the task in case the - * driver is implemented using differentiated inode operations based - * on file type, such as incore does. - */ - err = old->p_parent->p_base->pb_ino->i_ops.inop_rename(old, new); + err = PNOP_RENAME(old, new); if (err) goto error1; /* - * Reflect the successful rename in the active name space graph. + * Reflect the successful rename in the active name space graph by + * "losing" the existing, relevant, parts of the graph. A subsequent + * lookup will reestablish the proper graph. */ - if (new->p_base->pb_ino) - I_GONE(new->p_base->pb_ino); - new->p_base->pb_ino = old->p_base->pb_ino; - I_REF(new->p_base->pb_ino); + _sysio_pb_disconnect(old->p_base); error1: P_RELE(new); Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -w -b -B -p -r1.20 -r1.20.2.1 --- rmdir.c 3 May 2006 22:34:46 -0000 1.20 +++ rmdir.c 5 Feb 2007 15:54:28 -0000 1.20.2.1 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -60,7 +60,6 @@ SYSIO_INTERFACE_NAME(rmdir)(const char * struct intent intent; int err; struct pnode *pno; - struct inode *ino; SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER; @@ -79,20 +78,13 @@ SYSIO_INTERFACE_NAME(rmdir)(const char * err = -EBUSY; goto error; } - /* - * Use the parent node operations to request the task in case the - * driver is implemented using differentiated inode operations based - * on file type, such as incore does. - */ - err = (*pno->p_parent->p_base->pb_ino->i_ops.inop_rmdir)(pno); + err = PNOP_RMDIR(pno); if (err) goto error; /* - * Invalidate the path-base node and kill the i-node. + * Disconnect the path node from the existing graph. */ - ino = pno->p_base->pb_ino; - pno->p_base->pb_ino = NULL; - I_GONE(ino); + _sysio_pb_disconnect(pno->p_base); error: P_RELE(pno); out: Index: rw.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rw.c,v retrieving revision 1.16 retrieving revision 1.16.4.1 diff -u -w -b -B -p -r1.16 -r1.16.4.1 --- rw.c 25 Jan 2005 00:37:14 -0000 1.16 +++ rw.c 5 Feb 2007 15:54:28 -0000 1.16.4.1 @@ -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-2004 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -57,8 +57,12 @@ #include "sysio-symbols.h" -#define IIOXOP_READ(ino) (ino)->i_ops.inop_read, 0 -#define IIOXOP_WRITE(ino) (ino)->i_ops.inop_write, 1 +#define _IIOXOP_F(_fil, _fbase) \ + ((_fil)->f_pno->p_base->pb_ino ? \ + (_fil)->f_pno->p_base->pb_ino->i_ops.inop_##_fbase : \ + NULL) +#define IIOXOP_READ(_fil) _IIOXOP_F((_fil), read), 0 +#define IIOXOP_WRITE(_fil) _IIOXOP_F((_fil), write), 1 /* * Decoding the interface routine names: @@ -96,7 +100,6 @@ _sysio_iiox(int (*f)(struct inode *, str void (*completio)(struct ioctx *, void *), struct ioctx **ioctxp) { - struct inode *ino; ssize_t cc; struct ioctx *ioctx; int err; @@ -110,8 +113,7 @@ _sysio_iiox(int (*f)(struct inode *, str : !(fil->f_flags & O_WRONLY))) return -EBADF; - ino = fil->f_ino; - if (!ino) { + if (!fil->f_pno->p_base->pb_ino) { /* * Huh? It's dead. */ @@ -128,7 +130,8 @@ _sysio_iiox(int (*f)(struct inode *, str _SYSIO_OFF_T_MAX); if (cc < 0) return cc; - ioctx = _sysio_ioctx_new(ino, wr, iov, iov_count, xtv, xtv_count); + ioctx = + _sysio_ioctx_new(fil->f_pno, wr, iov, iov_count, xtv, xtv_count); if (!ioctx) return -ENOMEM; if ((iov_free && @@ -146,7 +149,8 @@ _sysio_iiox(int (*f)(struct inode *, str (void (*)(struct ioctx *, void *))completio, fil))) || - (err = (*f)(ino, ioctx))) { + (err = (f == NULL ? -ESTALE : 0)) || + (err = (*f)(fil->f_pno->p_base->pb_ino, ioctx))) { /* * Release the callback queue. Don't want it run after all. */ @@ -258,7 +262,7 @@ SYSIO_INTERFACE_NAME(ireadv)(int fd, con SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), + _sysio_iiov(IIOXOP_READ(fil), fil, iov, count, NULL, xtv, free_xtv, @@ -286,7 +290,7 @@ SYSIO_INTERFACE_NAME(readv)(int fd, cons SYSIO_INTERFACE_RETURN(-1, -EBADF); err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), + _sysio_iiov(IIOXOP_READ(fil), fil, iov, count, NULL, &xtvector, NULL, @@ -341,7 +345,7 @@ SYSIO_INTERFACE_NAME(iread)(int fd, void SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); } err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), + _sysio_iiov(IIOXOP_READ(fil), fil, iov, 1, free_iov, xtv, free_xtv, @@ -373,7 +377,7 @@ SYSIO_INTERFACE_NAME(read)(int fd, void iovector.iov_base = buf; iovector.iov_len = count; err = - _sysio_iiov(IIOXOP_READ(fil->f_ino), + _sysio_iiov(IIOXOP_READ(fil), fil, &iovector, 1, NULL, &xtvector, NULL, @@ -454,7 +458,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(ipreadv) SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), + _sysio_ipiov(IIOXOP_READ(fil), fil, iov, count, NULL, offset, @@ -505,7 +509,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(preadv)) SYSIO_INTERFACE_RETURN(-1, -EBADF); err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), + _sysio_ipiov(IIOXOP_READ(fil), fil, iov, count, NULL, offset, @@ -564,7 +568,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(ipread)) iov->iov_base = buf; xtv->xtv_len = iov->iov_len = count; err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), + _sysio_ipiov(IIOXOP_READ(fil), fil, iov, 1, free_iov, offset, @@ -623,7 +627,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(pread))( iovec.iov_base = buf; xtvec.xtv_len = iovec.iov_len = count; err = - _sysio_ipiov(IIOXOP_READ(fil->f_ino), + _sysio_ipiov(IIOXOP_READ(fil), fil, &iovec, 1, NULL, offset, @@ -690,7 +694,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(ireadx)) SYSIO_INTERFACE_RETURN(IOID_FAIL, -EINVAL); err = - _sysio_iiox(IIOXOP_READ(fil->f_ino), + _sysio_iiox(IIOXOP_READ(fil), fil, iov, iov_count, NULL, xtv, xtv_count, NULL, @@ -742,7 +746,7 @@ SYSIO_INTERFACE_NAME(ireadx)(int fd, } err = - _sysio_iiox(IIOXOP_READ(fil->f_ino), + _sysio_iiox(IIOXOP_READ(fil), fil, iov, iov_count, NULL, ixtv, xtv_count, free_xtv, @@ -833,7 +837,7 @@ SYSIO_INTERFACE_NAME(iwritev)(int fd, SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), + _sysio_iiov(IIOXOP_WRITE(fil), fil, iov, count, NULL, xtv, free_xtv, @@ -861,7 +865,7 @@ SYSIO_INTERFACE_NAME(writev)(int fd, con SYSIO_INTERFACE_RETURN(-1, -EBADF); err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), + _sysio_iiov(IIOXOP_WRITE(fil), fil, iov, count, NULL, &xtvector, NULL, @@ -908,7 +912,7 @@ SYSIO_INTERFACE_NAME(iwrite)(int fd, con SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); } err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), + _sysio_iiov(IIOXOP_WRITE(fil), fil, iov, 1, free_iov, xtv, free_xtv, @@ -940,7 +944,7 @@ SYSIO_INTERFACE_NAME(write)(int fd, cons iovector.iov_base = (void *)buf; iovector.iov_len = count; err = - _sysio_iiov(IIOXOP_WRITE(fil->f_ino), + _sysio_iiov(IIOXOP_WRITE(fil), fil, &iovector, 1, NULL, &xtvector, NULL, @@ -982,7 +986,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(ipwritev SYSIO_INTERFACE_RETURN(IOID_FAIL, -ENOMEM); err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), + _sysio_ipiov(IIOXOP_WRITE(fil), fil, iov, count, NULL, offset, @@ -1033,7 +1037,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(pwritev) SYSIO_INTERFACE_RETURN(-1, -EBADF); err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), + _sysio_ipiov(IIOXOP_WRITE(fil), fil, iov, count, NULL, offset, @@ -1092,7 +1096,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(ipwrite) iov->iov_base = (void *)buf; xtv->xtv_len = iov->iov_len = count; err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), + _sysio_ipiov(IIOXOP_WRITE(fil), fil, iov, 1, free_iov, offset, @@ -1151,7 +1155,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(pwrite)) iovec.iov_base = (void *)buf; xtvec.xtv_len = iovec.iov_len = count; err = - _sysio_ipiov(IIOXOP_WRITE(fil->f_ino), + _sysio_ipiov(IIOXOP_WRITE(fil), fil, &iovec, 1, NULL, offset, @@ -1214,7 +1218,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(iwritex) SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF); err = - _sysio_iiox(IIOXOP_WRITE(fil->f_ino), + _sysio_iiox(IIOXOP_WRITE(fil), fil, iov, iov_count, NULL, xtv, xtv_count, NULL, @@ -1265,7 +1269,7 @@ SYSIO_INTERFACE_NAME(iwritex)(int fd, } err = - _sysio_iiox(IIOXOP_WRITE(fil->f_ino), + _sysio_iiox(IIOXOP_WRITE(fil), fil, iov, iov_count, NULL, ixtv, xtv_count, free_xtv, Index: stat.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v retrieving revision 1.17 retrieving revision 1.17.8.1 diff -u -w -b -B -p -r1.17 -r1.17.8.1 --- stat.c 14 Oct 2004 14:59:29 -0000 1.17 +++ stat.c 5 Feb 2007 15:54:28 -0000 1.17.8.1 @@ -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-2007 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 @@ -41,6 +41,7 @@ * le...@sa... */ +#include <string.h> #include <errno.h> #include <assert.h> #include <sys/types.h> @@ -54,6 +55,141 @@ #include "sysio-symbols.h" +#if !defined(_STAT_VER) +#define _STAT_VER 0 +#endif + +static int +_sysio_fxstat(int ver, int fildes, struct intnl_stat *stat_buf) +{ + struct file *fil; + int err; + SYSIO_INTERFACE_DISPLAY_BLOCK; + + SYSIO_INTERFACE_ENTER; + if (ver != _STAT_VER) { + err = -ENOSYS; + goto out; + } + + err = 0; + fil = _sysio_fd_find(fildes); + if (!fil) { + err = -EBADF; + goto out; + } + /* + * Never use the attributes cached in the inode record. We + * want fresh ones. + */ + err = PNOP_GETATTR(fil->f_pno, stat_buf); +out: + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); +} + +static int +_sysio_xstatnd(int ver, + const char *filename, + struct intnl_stat *stat_buf, + unsigned ndflags) +{ + struct intent intent; + int err; + struct pnode *pno; + SYSIO_INTERFACE_DISPLAY_BLOCK; + + SYSIO_INTERFACE_ENTER; + if (ver != _STAT_VER) { + err = -ENOSYS; + goto out; + } + + INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); + err = _sysio_namei(_sysio_cwd, filename, ndflags, &intent, &pno); + if (err) + goto out; + /* + * Leverage the INT_GETATTR intent above. We are counting + * on the FS driver to either make sure the attributes cached in + * the inode are always correct or refresh them in the lookup, above. + */ + (void )memcpy(stat_buf, + &pno->p_base->pb_ino->i_stbuf, + sizeof(struct intnl_stat)); + P_RELE(pno); +out: + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); +} + +#if _LARGEFILE64_SOURCE + +#ifndef REDSTORM +#undef fstat64 +#undef stat64 +#undef lstat64 +#endif + +#undef __fxstat64 +#undef __xstat64 +#undef __lxstat64 + +int +PREPEND(__, SYSIO_INTERFACE_NAME(fxstat64))(int __ver, + int __fildes, + struct stat64 *__stat_buf) +{ + + return _sysio_fxstat(__ver, __fildes, __stat_buf); +} + +#ifndef REDSTORM +int +SYSIO_INTERFACE_NAME(fstat64)(int fd, struct stat64 *buf) +{ + + return PREPEND(__, SYSIO_INTERFACE_NAME(fxstat64))(_STAT_VER, fd, buf); +} +#endif + +int +PREPEND(__, SYSIO_INTERFACE_NAME(xstat64))(int __ver, + const char *__filename, + struct stat64 *__stat_buf) +{ + return _sysio_xstatnd(__ver, __filename, __stat_buf, 0); +} + +#ifndef REDSTORM +int +SYSIO_INTERFACE_NAME(stat64)(const char *filename, struct stat64 *buf) +{ + + return PREPEND(__, SYSIO_INTERFACE_NAME(xstat64))(_STAT_VER, + filename, + buf); +} +#endif + +int +PREPEND(__, SYSIO_INTERFACE_NAME(lxstat64))(int __ver, + const char *__filename, + struct stat64 *__stat_buf) +{ + return _sysio_xstatnd(__ver, __filename, __stat_buf, ND_NOFOLLOW); +} + +#ifndef REDSTORM +int +SYSIO_INTERFACE_NAME(lstat64)(const char *filename, struct stat64 *buf) +{ + + return PREPEND(__, SYSIO_INTERFACE_NAME(lxstat64))(_STAT_VER, + filename, + buf); +} +#endif +#endif /* !_LARGEFILE64_SOURCE */ + #ifndef REDSTORM #undef fstat #undef stat @@ -64,10 +200,6 @@ #undef __xstat #undef __lxstat -#if !defined(_STAT_VER) -#define _STAT_VER 0 -#endif - #if _LARGEFILE64_SOURCE static void convstat(struct stat64 *st64_buf, struct stat *st_buf) @@ -94,43 +226,23 @@ PREPEND(__, SYSIO_INTERFACE_NAME(fxstat) int __fildes, struct stat *__stat_buf) { - struct file *fil; - int err; struct intnl_stat *buf; + int err; #if _LARGEFILE64_SOURCE struct stat64 st64; #endif - SYSIO_INTERFACE_DISPLAY_BLOCK; - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } - - err = 0; - fil = _sysio_fd_find(__fildes); - if (!fil) { - err = -EBADF; - goto out; - } #if _LARGEFILE64_SOURCE buf = &st64; #else buf = __stat_buf; #endif - /* - * Never use the attributes cached in the inode record. Give the - * driver a chance to refresh them. - */ - err = - fil->f_ino->i_ops.inop_getattr(NULL, fil->f_ino, buf); + err = _sysio_fxstat(__ver, __fildes, buf); #if _LARGEFILE64_SOURCE if (!err) convstat(buf, __stat_buf); #endif -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); + return err; } #ifdef REDSTORM @@ -164,36 +276,23 @@ PREPEND(__, SYSIO_INTERFACE_NAME(xstat)) const char *__filename, struct stat *__stat_buf) { - struct intent intent; + struct intnl_stat *buf; int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } +#if _LARGEFILE64_SOURCE + struct stat64 st64; +#endif - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, 0, &intent, &pno); - if (err) - goto out; - /* - * Leverage the INT_GETATTR intent above. We are counting - * on the FS driver to either make sure the attributes cached in - * the inode are always correct or refresh them in the lookup, above. - */ - ino = pno->p_base->pb_ino; #if _LARGEFILE64_SOURCE - convstat(&ino->i_stbuf, __stat_buf); + buf = &st64; #else - (void )memcpy(__stat_buf, &ino->i_stbuf, sizeof(struct intnl_stat)); + buf = __stat_buf; #endif - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); + err = _sysio_xstatnd(__ver, __filename, buf, 0); +#if _LARGEFILE64_SOURCE + if (!err) + convstat(buf, __stat_buf); +#endif + return err; } #ifdef REDSTORM @@ -228,36 +327,23 @@ PREPEND(__, SYSIO_INTERFACE_NAME(lxstat) const char *__filename, struct stat *__stat_buf) { - struct intent intent; + struct intnl_stat *buf; int err; - struct pnode *pno; - struct inode *ino; - SYSIO_INTERFACE_DISPLAY_BLOCK; - - SYSIO_INTERFACE_ENTER; - if (__ver != _STAT_VER) { - err = -ENOSYS; - goto out; - } +#if _LARGEFILE64_SOURCE + struct stat64 st64; +#endif - INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, __filename, ND_NOFOLLOW, &intent, &pno); - if (err) - goto out; - /* - * Leverage the INT_GETATTR intent above. We are counting - * on the FS driver to either make sure the attributes cached in - * the inode are always correct or refresh them in the lookup, above. - */ - ino = pno->p_base->pb_ino; #if _LARGEFILE64_SOURCE - convstat(&ino->i_stbuf, __stat_buf); + buf = &st64; #else - (void )memcpy(__stat_buf, &ino->i_stbuf, sizeof(struct intnl_stat)); + buf = __stat_buf; #endif - P_RELE(pno); -out: - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); + err = _sysio_xstatnd(__ver, __filename, buf, ND_NOFOLLOW); +#if _LARGEFILE64_SOURCE + if (!err) + convstat(buf, __stat_buf); +#endif + return err; } #ifdef REDSTORM Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v retrieving revision 1.12 retrieving revision 1.12.10.1 diff -u -w -b -B -p -r1.12 -r1.12.10.1 --- statvfs.c 27 Jul 2004 15:00:48 -0000 1.12 +++ statvfs.c 5 Feb 2007 15:54:28 -0000 1.12.10.1 @@ -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-2007 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 @@ -94,7 +94,7 @@ SYSIO_INTERFACE_NAME(statvfs)(const char if (err) goto out; - err = pno->p_base->pb_ino->i_ops.inop_statvfs(pno, NULL, _call_buf); + err = PNOP_STATVFS(pno, _call_buf); P_RELE(pno); if (err) goto err; @@ -134,7 +134,7 @@ SYSIO_INTERFACE_NAME(fstatvfs)(int fd, s goto out; } - err = filp->f_ino->i_ops.inop_statvfs(NULL, filp->f_ino, _call_buf); + err = PNOP_STATVFS(filp->f_pno, _call_buf); if (err) goto err; #ifndef INTNL_STATVFS_IS_NATURAL Index: statvfs64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v retrieving revision 1.14 retrieving revision 1.14.10.1 diff -u -w -b -B -p -r1.14 -r1.14.10.1 --- statvfs64.c 27 Jul 2004 15:00:48 -0000 1.14 +++ statvfs64.c 5 Feb 2007 15:54:28 -0000 1.14.10.1 @@ -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-2007 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 @@ -66,7 +66,7 @@ SYSIO_INTERFACE_NAME(statvfs64)(const ch if (err) goto out; - err = pno->p_base->pb_ino->i_ops.inop_statvfs(pno, NULL, buf); + err = PNOP_STATVFS(pno, buf); P_RELE(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); @@ -93,7 +93,7 @@ SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, goto out; } - err = filp->f_ino->i_ops.inop_statvfs(NULL, filp->f_ino, buf); + err = PNOP_STATVFS(filp->f_pno, buf); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err); } Index: symlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/symlink.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -w -b -B -p -r1.16 -r1.16.2.1 --- symlink.c 3 May 2006 22:34:46 -0000 1.16 +++ symlink.c 5 Feb 2007 15:54:28 -0000 1.16.2.1 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 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 @@ -80,13 +80,7 @@ ... [truncated message content] |