Thread: [Libsysio-commit] HEAD: libsysio/src mount.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2003-08-26 13:17:25
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv16025 Modified Files: mount.c Log Message: Fix for mount options processing from Jim Schutt: This patch fixes a buglet in options processing. If the current code parses an option string where the first option is a file-system specific option, it will copy that option and return without processing any more options. This happens since under these conditions, src and dst match at least up to the end of the first option, so *dst = '\0' also terminates the source string, and the loop exits early. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- mount.c 18 Apr 2003 20:24:05 -0000 1.5 +++ mount.c 26 Aug 2003 13:17:20 -0000 1.6 @@ -541,11 +541,12 @@ parse_opts(char *opts, unsigned *flagsp) *dst++ = *src++; while (src != cp); } - *dst = '\0'; if (!*src) break; + *dst = '\0'; src++; /* skip comma */ } + *dst = '\0'; *flagsp = flags; return opts; |
From: jaschut <ja...@us...> - 2003-10-27 23:49:49
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv20287 Modified Files: mount.c Log Message: In _sysio_do_mount(), change the inop_getattr() call to _sysio_p_validate(), since the latter should be checking the inode mode bits, and is potentially cheaper. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- mount.c 13 Oct 2003 01:04:35 -0000 1.8 +++ mount.c 27 Oct 2003 23:49:10 -0000 1.9 @@ -102,8 +102,6 @@ _sysio_do_mount(struct filesys *fs, { struct mount *mnt; int err; - struct intnl_stat stbuf; - struct inode *ino; /* * It's really poor form to allow the new root to be a @@ -148,14 +146,15 @@ _sysio_do_mount(struct filesys *fs, err = -ENOMEM; goto error; } - ino = mnt->mnt_root->p_base->pb_ino; - err = ino->i_ops.inop_getattr(mnt->mnt_root, ino, &stbuf); - if (err) - goto error; /* - * Begtter be a directory object! + * It may have been a while since the root inode was validated; + * better validate again. And it better be a directory! */ - if (!S_ISDIR(stbuf.st_mode)) { + err = _sysio_p_validate(mnt->mnt_root, NULL, NULL); + if (err) + goto error; + + if (!S_ISDIR(mnt->mnt_root->p_base->pb_ino->i_mode)) { err = -ENOTDIR; goto error; } |
From: Lee W. <lw...@us...> - 2004-10-19 15:32:57
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31126/src Modified Files: mount.c Log Message: Added a pseudo-filesystem that allows the mounting of a sub-tree of the namespace onto another place. This is similar to Linux's "bind" mounts. One cannot mount into the same tree. In other words, neither the source nor the target may appear as an ancestor of the other. The FS type name is "sub". Example: mount("/vol/lustre/home", "/home", "sub", 0, NULL); Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -b -B -p -r1.18 -r1.19 --- mount.c 14 Oct 2004 14:59:29 -0000 1.18 +++ mount.c 19 Oct 2004 15:32:38 -0000 1.19 @@ -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 @@ -76,18 +76,36 @@ struct qstr _sysio_mount_file_name = { " */ static LIST_HEAD(, mount) mounts; +static int _sysio_sub_fsswop_mount(const char *source, + unsigned flags, + const void *data, + struct pnode *tocover, + struct mount **mntp); + +static struct fssw_ops _sysio_sub_fssw_ops = { + _sysio_sub_fsswop_mount +}; + /* * Initialization. Must be called before any other routine in this module. */ int _sysio_mount_init() { + int err; LIST_INIT(&mounts); #ifdef AUTOMOUNT_FILE_NAME _sysio_next_component(AUTOMOUNT_FILE_NAME, &_sysio_mount_file_name); #endif + /* + * Register the sub-trees "file system" driver. + */ + err = _sysio_fssw_register("sub", &_sysio_sub_fssw_ops); + if (err) + return err; + return 0; } @@ -421,6 +439,52 @@ _sysio_unmount_all() return err; } +static int +_sysio_sub_fsswop_mount(const char *source, + unsigned flags, + const void *data __IS_UNUSED, + struct pnode *tocover, + struct mount **mntp) +{ + int err; + struct nameidata nameidata; + struct mount *mnt; + + /* + * How can we make a sub-mount from nothing? + */ + if (!_sysio_root) + return -EBUSY; + + /* + * Lookup the source. + */ + ND_INIT(&nameidata, 0, source, _sysio_root, NULL); + err = _sysio_path_walk(_sysio_root, &nameidata); + if (err) + return err; + + /* + * Mount the rooted sub-tree at the given position. + */ + err = + _sysio_do_mount(nameidata.nd_pno->p_mount->mnt_fs, + nameidata.nd_pno->p_base, + nameidata.nd_pno->p_mount->mnt_flags & flags, + tocover, + &mnt); + + /* + * Clean up and return. + */ + if (!err) { + FS_REF(nameidata.nd_pno->p_mount->mnt_fs); + *mntp = mnt; + } + P_RELE(nameidata.nd_pno); + return err; +} + #ifdef AUTOMOUNT_FILE_NAME /* * Parse automount specification formatted as: |
From: Lee W. <lw...@us...> - 2004-10-19 22:24:00
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9909 Modified Files: mount.c Log Message: Added the tiniest bit of paranoia to _sysio_do_mount. Basically, just want to make sure we aren't somehow, strangely, mounting on a pnode that is already mounted on. I can't see how this could happen but I like explicit failures instead of weird behavior. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -b -B -p -r1.19 -r1.20 --- mount.c 19 Oct 2004 15:32:38 -0000 1.19 +++ mount.c 19 Oct 2004 22:23:50 -0000 1.20 @@ -187,6 +187,7 @@ _sysio_do_mount(struct filesys *fs, */ mnt->mnt_covers = tocover = mnt->mnt_root; } + assert(!tocover->p_cover); tocover->p_cover = mnt->mnt_root; LIST_INSERT_HEAD(&mounts, mnt, mnt_link); |
From: Lee W. <lw...@us...> - 2007-09-24 19:00:19
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10952/src Modified Files: mount.c Log Message: All the drivers, in their mount routines, do something like: rootpb = _sysio_pb_new(&noname, NULL, rootino); err = _sysio_do_mount(..., rootpb, ...); This is clumsy. Crafted a convenience function called _sysio_mounti to do this for them. This simplifies the whole process a bit. Don't have to clean up the root pb node on error, for instance. The function is called exactly like _sysio_do_mount but with a ptr to the root inode instead of a ptr to the root pb node. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -w -b -B -p -r1.25 -r1.26 --- mount.c 21 Sep 2007 19:41:37 -0000 1.25 +++ mount.c 24 Sep 2007 19:00:03 -0000 1.26 @@ -200,6 +200,29 @@ error: } /* + * Mount unrooted sub-tree somewhere in the existing name space. + */ +int +_sysio_mounti(struct filesys *fs, + struct inode *rootino, + unsigned flags, + struct pnode *tocover, + struct mount **mntp) +{ + static struct qstr noname = { NULL, 0, 0 }; + struct pnode_base *rootpb; + int err; + + rootpb = _sysio_pb_new(&noname, NULL, rootino); + if (!rootpb) + return -ENOMEM; + err = _sysio_do_mount(fs, rootpb, flags, tocover, mntp); + if (err) + _sysio_pb_gone(rootpb); + return err; +} + +/* * Remove mounted sub-tree from the system. */ int |
From: Lee W. <lw...@us...> - 2008-04-14 23:26:17
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv490 Modified Files: mount.c Log Message: Two changes: 1) _sysio_do_mount and _sysio_do_unmount deliver a debug using _sysio_p_show when called. 2) _sysio_unmount_all always tries to unmount the front of the all-mounts list -- Latest is first. This, to avoid attempting to unmount a lower file system in the graph underneath a failed upper. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -w -b -B -p -r1.26 -r1.27 --- mount.c 24 Sep 2007 19:00:03 -0000 1.26 +++ mount.c 14 Apr 2008 23:26:13 -0000 1.27 @@ -74,7 +74,7 @@ struct qstr _sysio_mount_file_name = { " /* * Active mounts. */ -static LIST_HEAD(, mount) mounts; +LIST_HEAD(, mount) mounts; static int _sysio_sub_fsswop_mount(const char *source, unsigned flags, @@ -187,6 +187,9 @@ _sysio_do_mount(struct filesys *fs, LIST_INSERT_HEAD(&mounts, mnt, mnt_link); +#ifdef P_DEBUG + _sysio_p_show("DO_MOUNT", mnt->mnt_root); +#endif *mntp = mnt; return 0; @@ -239,6 +242,9 @@ _sysio_do_unmount(struct mount *mnt) */ return -EBUSY; } +#ifdef P_DEBUG + _sysio_p_show("DO_UNMOUNT", mnt->mnt_root); +#endif assert(mnt->mnt_covers->p_cover == root); if (_sysio_p_prune(root) != 1) { /* @@ -432,17 +438,15 @@ int _sysio_unmount_all() { int err; - struct mount *mnt, *nxt; + struct mount *mnt; struct pnode *pno; err = 0; - nxt = mounts.lh_first; - while ((mnt = nxt)) { - nxt = mnt->mnt_link.le_next; + while ((mnt = mounts.lh_first)) { pno = mnt->mnt_root; /* * If this is an automount generated mount, the root - * has no reference. We can cause the dismount with a + * has no reference. We can accomplish the dismount with a * simple prune. */ if (!_sysio_p_prune(pno)) |
From: Lee W. <lw...@us...> - 2008-04-22 22:02:56
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22547/src Modified Files: mount.c Log Message: Parent pointer of root of a mount no longer points to the parent of the node it covered. Instead, such nodes loop. Also, the diagnostic that prints a pnode needs some more fields to be initialized in the mount record. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -w -b -B -p -r1.27 -r1.28 --- mount.c 14 Apr 2008 23:26:13 -0000 1.27 +++ mount.c 22 Apr 2008 22:02:49 -0000 1.28 @@ -159,8 +159,9 @@ _sysio_do_mount(struct filesys *fs, /* * Get alias for the new root. */ + mnt->mnt_root = mnt->mnt_covers = NULL; mnt->mnt_root = - _sysio_p_new_alias(tocover ? tocover->p_parent : NULL, rootpb, mnt); + _sysio_p_new_alias(NULL, rootpb, mnt); if (!mnt->mnt_root) { err = -ENOMEM; goto error; @@ -236,6 +237,7 @@ _sysio_do_unmount(struct mount *mnt) struct filesys *fs; root = mnt->mnt_root; + assert(root->p_ref); if (root->p_cover && root->p_cover != root) { /* * Active mount. @@ -727,15 +729,13 @@ _sysio_automount(struct pnode *mntpno) /* * Do the deed. */ - P_REF(mntpno->p_parent); + assert(mntpno->p_parent->p_ref); err = (*fssw->fssw_ops.fsswop_mount)(source, flags, opts, mntpno->p_parent, &mnt); - if (err) - P_RELE(mntpno->p_parent); out: if (buf) |
From: Lee W. <lw...@us...> - 2008-04-23 00:23:26
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11187/src Modified Files: mount.c Log Message: In _sysio_do_mount we now test to ensure that everything is a directory that we can. Also, got rid of _sysio_p_gone use in that routine. Would like to get it everywhere, restricting it to the inode.c file only. Someday... Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -w -b -B -p -r1.28 -r1.29 --- mount.c 22 Apr 2008 22:02:49 -0000 1.28 +++ mount.c 23 Apr 2008 00:23:21 -0000 1.29 @@ -123,6 +123,15 @@ _sysio_do_mount(struct filesys *fs, int err; /* + * Directories only, please. + */ + if ((tocover && + !(tocover->p_base->pb_ino && + S_ISDIR(tocover->p_base->pb_ino->i_stbuf.st_mode))) || + !rootpb->pb_ino || !S_ISDIR(rootpb->pb_ino->i_stbuf.st_mode)) + return -ENOTDIR; + + /* * It's really poor form to allow the new root to be a * descendant of the pnode being covered. */ @@ -167,13 +176,6 @@ _sysio_do_mount(struct filesys *fs, 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; - } - /* * Cover up the mount point. */ mnt->mnt_covers = tocover; @@ -195,10 +197,6 @@ _sysio_do_mount(struct filesys *fs, return 0; error: - if (mnt->mnt_root) { - P_RELE(mnt->mnt_root); - _sysio_p_gone(mnt->mnt_root); - } free(mnt); return err; } |
From: Lee W. <lw...@us...> - 2008-06-18 15:58:14
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1603 Modified Files: mount.c Log Message: Fixed a bug in _sysio_do_mount. It wasn't properly checking that the object to cover was a directory. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- mount.c 17 Jun 2008 17:18:57 -0000 1.30 +++ mount.c 18 Jun 2008 15:50:39 -0000 1.31 @@ -127,9 +127,10 @@ _sysio_do_mount(struct filesys *fs, * Directories only, please. */ if ((tocover && - (tocover->p_base->pb_ino && + !(tocover->p_base->pb_ino && S_ISDIR(tocover->p_base->pb_ino->i_stbuf.st_mode))) || - !rootpb->pb_ino || !S_ISDIR(rootpb->pb_ino->i_stbuf.st_mode)) + !(rootpb->pb_ino && + S_ISDIR(rootpb->pb_ino->i_stbuf.st_mode))) return -ENOTDIR; /* |
From: Lee W. <lw...@us...> - 2009-09-21 21:30:53
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14094/src Modified Files: mount.c Log Message: In the submount routine, at the end we were releasing the pnode we just tried to cover. That should have been a PUT. It is now :) Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -w -b -B -p -r1.33 -r1.34 --- mount.c 31 Aug 2009 21:38:29 -0000 1.33 +++ mount.c 21 Sep 2009 21:30:42 -0000 1.34 @@ -538,7 +538,7 @@ _sysio_sub_fsswop_mount(const char *sour FS_REF(nameidata.nd_pno->p_mount->mnt_fs); *mntp = mnt; } - P_RELE(nameidata.nd_pno); + P_PUT(nameidata.nd_pno); return err; } |