vfs_mount.c (158930) | vfs_mount.c (159181) |
---|---|
1/*- 2 * Copyright (c) 1999-2004 Poul-Henning Kamp 3 * Copyright (c) 1999 Michael Smith 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * (c) UNIX System Laboratories, Inc. 7 * All or some portions of this file are derived from material licensed 8 * to the University of California by American Telephone and Telegraph --- 21 unchanged lines hidden (view full) --- 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1999-2004 Poul-Henning Kamp 3 * Copyright (c) 1999 Michael Smith 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * (c) UNIX System Laboratories, Inc. 7 * All or some portions of this file are derived from material licensed 8 * to the University of California by American Telephone and Telegraph --- 21 unchanged lines hidden (view full) --- 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 158930 2006-05-26 02:38:48Z rodrigc $"); | 38__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 159181 2006-06-02 20:29:02Z pjd $"); |
39 40#include <sys/param.h> 41#include <sys/conf.h> 42#include <sys/jail.h> 43#include <sys/kernel.h> 44#include <sys/libkern.h> 45#include <sys/mac.h> 46#include <sys/malloc.h> --- 31 unchanged lines hidden (view full) --- 78 char *fspath, int fsflags, void *fsdata); 79static struct mount *vfs_mount_alloc(struct vnode *dvp, struct vfsconf *vfsp, 80 const char *fspath, struct thread *td); 81static int vfs_mountroot_ask(void); 82static int vfs_mountroot_try(const char *mountfrom); 83static int vfs_donmount(struct thread *td, int fsflags, 84 struct uio *fsoptions); 85static void free_mntarg(struct mntarg *ma); | 39 40#include <sys/param.h> 41#include <sys/conf.h> 42#include <sys/jail.h> 43#include <sys/kernel.h> 44#include <sys/libkern.h> 45#include <sys/mac.h> 46#include <sys/malloc.h> --- 31 unchanged lines hidden (view full) --- 78 char *fspath, int fsflags, void *fsdata); 79static struct mount *vfs_mount_alloc(struct vnode *dvp, struct vfsconf *vfsp, 80 const char *fspath, struct thread *td); 81static int vfs_mountroot_ask(void); 82static int vfs_mountroot_try(const char *mountfrom); 83static int vfs_donmount(struct thread *td, int fsflags, 84 struct uio *fsoptions); 85static void free_mntarg(struct mntarg *ma); |
86static void vfs_mount_destroy(struct mount *, struct thread *); | 86static void vfs_mount_destroy(struct mount *); |
87static int vfs_getopt_pos(struct vfsoptlist *opts, const char *name); 88 89static int usermount = 0; 90SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, 91 "Unprivileged users may mount and unmount file systems"); 92 93MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure"); 94MALLOC_DEFINE(M_VNODE_MARKER, "vnodemarker", "vnode marker"); --- 386 unchanged lines hidden (view full) --- 481 arc4rand(&mp->mnt_hashseed, sizeof mp->mnt_hashseed, 0); 482 return (mp); 483} 484 485/* 486 * Destroy the mount struct previously allocated by vfs_mount_alloc(). 487 */ 488static void | 87static int vfs_getopt_pos(struct vfsoptlist *opts, const char *name); 88 89static int usermount = 0; 90SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, 91 "Unprivileged users may mount and unmount file systems"); 92 93MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure"); 94MALLOC_DEFINE(M_VNODE_MARKER, "vnodemarker", "vnode marker"); --- 386 unchanged lines hidden (view full) --- 481 arc4rand(&mp->mnt_hashseed, sizeof mp->mnt_hashseed, 0); 482 return (mp); 483} 484 485/* 486 * Destroy the mount struct previously allocated by vfs_mount_alloc(). 487 */ 488static void |
489vfs_mount_destroy(struct mount *mp, struct thread *td) | 489vfs_mount_destroy(struct mount *mp) |
490{ 491 int i; 492 | 490{ 491 int i; 492 |
493 lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, td); | |
494 MNT_ILOCK(mp); 495 for (i = 0; mp->mnt_ref && i < 3; i++) 496 msleep(mp, MNT_MTX(mp), PVFS, "mntref", hz); 497 /* 498 * This will always cause a 3 second delay in rebooting due to 499 * refs on the root mountpoint that never go away. Most of these 500 * are held by init which never exits. 501 */ --- 502 unchanged lines hidden (view full) --- 1004 error = vfs_allocate_syncvnode(mp); 1005 vfs_unbusy(mp, td); 1006 if (error) 1007 vrele(vp); 1008 } else { 1009 VI_LOCK(vp); 1010 vp->v_iflag &= ~VI_MOUNT; 1011 VI_UNLOCK(vp); | 493 MNT_ILOCK(mp); 494 for (i = 0; mp->mnt_ref && i < 3; i++) 495 msleep(mp, MNT_MTX(mp), PVFS, "mntref", hz); 496 /* 497 * This will always cause a 3 second delay in rebooting due to 498 * refs on the root mountpoint that never go away. Most of these 499 * are held by init which never exits. 500 */ --- 502 unchanged lines hidden (view full) --- 1003 error = vfs_allocate_syncvnode(mp); 1004 vfs_unbusy(mp, td); 1005 if (error) 1006 vrele(vp); 1007 } else { 1008 VI_LOCK(vp); 1009 vp->v_iflag &= ~VI_MOUNT; 1010 VI_UNLOCK(vp); |
1012 vfs_mount_destroy(mp, td); | 1011 vfs_unbusy(mp, td); 1012 vfs_mount_destroy(mp); |
1013 vput(vp); 1014 } 1015 return (error); 1016} 1017 1018/* 1019 * --------------------------------------------------------------------- 1020 * Unmount a filesystem. --- 185 unchanged lines hidden (view full) --- 1206 mtx_lock(&mountlist_mtx); 1207 TAILQ_REMOVE(&mountlist, mp, mnt_list); 1208 mtx_unlock(&mountlist_mtx); 1209 if (coveredvp != NULL) { 1210 coveredvp->v_mountedhere = NULL; 1211 vput(coveredvp); 1212 } 1213 vfs_event_signal(NULL, VQ_UNMOUNT, 0); | 1013 vput(vp); 1014 } 1015 return (error); 1016} 1017 1018/* 1019 * --------------------------------------------------------------------- 1020 * Unmount a filesystem. --- 185 unchanged lines hidden (view full) --- 1206 mtx_lock(&mountlist_mtx); 1207 TAILQ_REMOVE(&mountlist, mp, mnt_list); 1208 mtx_unlock(&mountlist_mtx); 1209 if (coveredvp != NULL) { 1210 coveredvp->v_mountedhere = NULL; 1211 vput(coveredvp); 1212 } 1213 vfs_event_signal(NULL, VQ_UNMOUNT, 0); |
1214 vfs_mount_destroy(mp, td); | 1214 lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, td); 1215 vfs_mount_destroy(mp); |
1215 return (0); 1216} 1217 1218/* 1219 * --------------------------------------------------------------------- 1220 * Mounting of root filesystem 1221 * 1222 */ --- 881 unchanged lines hidden --- | 1216 return (0); 1217} 1218 1219/* 1220 * --------------------------------------------------------------------- 1221 * Mounting of root filesystem 1222 * 1223 */ --- 881 unchanged lines hidden --- |