[Libsysio-commit] unification: libsysio/src access.c chdir.c mount.c namei.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-04-12 01:51:16
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17493 Modified Files: Tag: unification access.c chdir.c mount.c namei.c Log Message: Altered to use new _sysio_p_gone and the changes that come with NULL parent in pnodes. Index: access.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/access.c,v retrieving revision 1.13.2.1 retrieving revision 1.13.2.2 diff -u -w -b -B -p -r1.13.2.1 -r1.13.2.2 --- access.c 10 Apr 2007 21:25:30 -0000 1.13.2.1 +++ access.c 12 Apr 2007 01:51:13 -0000 1.13.2.2 @@ -75,6 +75,8 @@ _sysio_check_permission(struct pnode *pn gid_t *gids; int ngids; + assert(pno); + /* * Check amode. */ Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.25.2.1 retrieving revision 1.25.2.2 diff -u -w -b -B -p -r1.25.2.1 -r1.25.2.2 --- chdir.c 10 Apr 2007 21:25:30 -0000 1.25.2.1 +++ chdir.c 12 Apr 2007 01:51:13 -0000 1.25.2.2 @@ -173,7 +173,8 @@ _sysio_p_path(struct pnode *pno, char ** * the *covered* nodes name, not this one unless we are at * the root of the name-space. */ - while (pno == pno->p_mount->mnt_root && pno != pno->p_parent ) + while (pno == pno->p_mount->mnt_root && + pno != pno->p_parent) pno = pno->p_mount->mnt_covers; /* @@ -187,7 +188,9 @@ _sysio_p_path(struct pnode *pno, char ** n++; assert(n); pno = pno->p_parent; - } while (pno != pno->p_parent); + } while (pno && pno != pno->p_parent); + if (!pno) + return -ENOENT; if (!*buf) size = len + n + 1; @@ -214,7 +217,8 @@ _sysio_p_path(struct pnode *pno, char ** * the *covered* nodes name, not this one unless we are at * the root of the name-space. */ - while (pno == pno->p_mount->mnt_root && pno != pno->p_parent ) + while (pno == pno->p_mount->mnt_root && + pno != pno->p_parent ) pno = pno->p_mount->mnt_covers; /* Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.21.4.2 retrieving revision 1.21.4.3 diff -u -w -b -B -p -r1.21.4.2 -r1.21.4.3 --- mount.c 10 Apr 2007 21:25:31 -0000 1.21.4.2 +++ mount.c 12 Apr 2007 01:51:13 -0000 1.21.4.3 @@ -167,12 +167,15 @@ _sysio_do_mount(struct filesys *fs, } /* * It may have been a while since the root inode was validated; - * better validate again. And it better be a directory! + * better validate again. */ err = _sysio_p_validate(mnt->mnt_root, NULL, NULL); if (err) goto error; + /* + * It better be a directory! + */ if (!S_ISDIR(mnt->mnt_root->p_base->pb_ino->i_stbuf.st_mode)) { err = -ENOTDIR; goto error; @@ -198,7 +201,7 @@ _sysio_do_mount(struct filesys *fs, error: if (mnt->mnt_root) { P_RELE(mnt->mnt_root); - _sysio_p_prune(mnt->mnt_root); + _sysio_p_gone(mnt->mnt_root); } free(mnt); return err; @@ -211,6 +214,7 @@ int _sysio_do_unmount(struct mount *mnt) { struct pnode *root; + struct pnode_base *rootpb; struct filesys *fs; root = mnt->mnt_root; @@ -241,7 +245,10 @@ _sysio_do_unmount(struct mount *mnt) */ P_RELE(root); root->p_cover = NULL; + rootpb = root->p_base; _sysio_p_gone(root); + if (!(rootpb->pb_aliases.lh_first || rootpb->pb_children.lh_first)) + _sysio_pb_gone(rootpb); /* * Release mount record resource. */ @@ -370,6 +377,7 @@ SYSIO_INTERFACE_NAME(umount)(const char { int err; struct pnode *pno; + struct mount *mnt; SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER(umount, target); @@ -379,7 +387,12 @@ SYSIO_INTERFACE_NAME(umount)(const char err = _sysio_namei(_sysio_cwd, target, 0, NULL, &pno); if (err) goto out; + mnt = pno->p_mount; + if (!err && mnt->mnt_root != pno) + err = -EINVAL; P_RELE(pno); /* was ref'd */ + if (err) + goto out; /* * Do the deed. @@ -390,8 +403,7 @@ SYSIO_INTERFACE_NAME(umount)(const char goto error; } #endif - assert(pno->p_mount); - err = _sysio_do_unmount(pno->p_mount); + err = _sysio_do_unmount(mnt); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, umount, 0); @@ -419,23 +431,9 @@ _sysio_unmount_all() */ if (!_sysio_p_prune(pno)) continue; -#ifdef notdef - /* - * Need a ref but only if this is not the root of a - * disconnected graph. If it is, then it is covered by itself - * and, so, already referenced. - */ - if (pno->p_cover != pno) - P_REF(pno); -#endif err = _sysio_do_unmount(mnt); - if (err) { -#ifdef notdef - if (pno->p_cover != pno) - P_RELE(pno); -#endif + if (err) break; - } if (pno == _sysio_root) _sysio_root = NULL; } Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.23.2.1 retrieving revision 1.23.2.2 diff -u -w -b -B -p -r1.23.2.1 -r1.23.2.2 --- namei.c 5 Feb 2007 15:54:28 -0000 1.23.2.1 +++ namei.c 12 Apr 2007 01:51:13 -0000 1.23.2.2 @@ -96,11 +96,11 @@ lookup(struct pnode *parent, assert(parent != NULL); /* - * The parent must be valid and should be connected or a root. + * The parent must be valid and a directory. */ - if (parent->p_base->pb_parent == parent->p_base) + if (!parent->p_parent) return -ENOENT; - if (!parent->p_base->pb_ino) + if (!S_ISDIR(parent->p_base->pb_ino->i_stbuf.st_mode)) return -ENOTDIR; /* @@ -119,8 +119,11 @@ lookup(struct pnode *parent, pno = NULL; if (name->len == 1 && name->name[0] == '.') pno = parent; - else if (name->len == 2 && name->name[0] == '.' && name->name[1] == '.') + else if (name->len == 2 && + name->name[0] == '.' && + name->name[1] == '.') { pno = parent->p_parent; + } if (pno) P_REF(pno); else { @@ -131,10 +134,6 @@ 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. @@ -153,11 +152,7 @@ lookup(struct pnode *parent, /* * (Re)validate the pnode. */ - err = _sysio_p_validate(pno, intnt, path); - if (err) - return err; - - return 0; + return _sysio_p_validate(pno, intnt, path); } /* |