[Libsysio-commit] HEAD: libsysio/src mount.c
Brought to you by:
lward
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: |