[Libsysio-commit] HEAD: libsysio/src namei.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2009-02-04 19:17:47
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27400/src Modified Files: namei.c Log Message: Added support for the new ND_NXMNT flag. Changed the local routine that traverses to the next component in a path, called lookup. It now takes nameidata flags, and honors ND_NOPERMCHECK and ND_NXMNT. Removed the check_permissions flag as it's function is captured in this more general mechanism. Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -w -b -B -p -r1.33 -r1.34 --- namei.c 6 Dec 2008 21:56:25 -0000 1.33 +++ namei.c 4 Feb 2009 19:17:42 -0000 1.34 @@ -82,10 +82,10 @@ _sysio_next_component(const char *path, static int lookup(struct pnode *parent, struct qstr *name, + unsigned flags, struct pnode **pnop, struct intent *intnt, - const char *path, - int check_permissions) + const char *path) { int err; struct pnode *pno; @@ -98,7 +98,7 @@ lookup(struct pnode *parent, * Sometimes we don't want to check permissions. At initialization * time, for instance. */ - if (check_permissions) { + if (!(flags & ND_NOPERMCHECK)) { err = _sysio_permitted(parent, X_OK); if (err) return err; @@ -123,7 +123,9 @@ lookup(struct pnode *parent, * one node in any given type locked while we're doing this. */ pno = parent; - if (pno == pno->p_parent && pno->p_cover != pno) { + if (!(flags & ND_NXMNT) && + pno == pno->p_parent && + pno->p_cover != pno) { /* * This node loops on itself and is not the root @@ -168,6 +170,7 @@ lookup(struct pnode *parent, err = _sysio_p_find_alias(parent, name, &pno); if (err) return err; + if (!(flags & ND_NXMNT)) { /* * While covered, move to the covering node. */ @@ -180,6 +183,7 @@ lookup(struct pnode *parent, pno = cover; } } + } *pnop = pno; @@ -198,6 +202,7 @@ lookup(struct pnode *parent, * ND_NEGOK if terminal/leaf does not exist, return * path node (alias) anyway. * ND_NOPERMCHECK do not check permissions + * ND_NXMNT do not cross mount points */ int _sysio_path_walk(struct pnode *parent, struct nameidata *nd) @@ -247,7 +252,11 @@ _sysio_path_walk(struct pnode *parent, s parent = nd->nd_root; if (!parent) abort(); - (void )_sysio_namei(nd->nd_root, icwd, 0, NULL, &parent); + (void )_sysio_namei(nd->nd_root, + icwd, + nd->nd_flags & ND_NXMNT, + NULL, + &parent); if (_sysio_p_chdir(parent) != 0) abort(); P_PUT(parent); @@ -328,7 +337,8 @@ _sysio_path_walk(struct pnode *parent, s ino = nd->nd_pno->p_base->pb_ino; } #ifdef AUTOMOUNT_FILE_NAME - else if (ino && + else if ((nd->nd_flags & ND_NXMNT) && + ino && nd->nd_amcnt < MAX_MOUNT_DEPTH && S_ISDIR(ino->i_stbuf.st_mode) && ino->i_stbuf.st_mode & S_ISUID && @@ -351,10 +361,10 @@ _sysio_path_walk(struct pnode *parent, s err = lookup(nd->nd_pno, &_sysio_mount_file_name, + 0, &pno, NULL, - NULL, - 1); + NULL); } if (!err && (err = _sysio_automount(pno)) == 0) { struct pnode *covered; @@ -463,12 +473,12 @@ _sysio_path_walk(struct pnode *parent, s err = lookup(parent, &this, + (nd->nd_flags & (ND_NOPERMCHECK|ND_NXMNT)), &nd->nd_pno, (path || !next.len) ? nd->nd_intent : NULL, - (path && next.len) ? path : NULL, - !(nd->nd_flags & ND_NOPERMCHECK)); + (path && next.len) ? path : NULL); if (err) { if (err == -ENOENT && !next.len && |