diff options
author | David Greenman <dg@FreeBSD.org> | 1994-08-20 16:03:26 +0000 |
---|---|---|
committer | David Greenman <dg@FreeBSD.org> | 1994-08-20 16:03:26 +0000 |
commit | e0e9c421121fbf3d1c6e8e5b20f57e99efc9072f (patch) | |
tree | e9031b5de5b5dd36f5609577351266694d3cb1ba /sys/kern/vfs_export.c | |
parent | d90963f5e456da477483517dd7710332e383b162 (diff) | |
download | src-e0e9c421121fbf3d1c6e8e5b20f57e99efc9072f.tar.gz src-e0e9c421121fbf3d1c6e8e5b20f57e99efc9072f.zip |
Implemented filesystem clean bit via:
machdep.c:
Changed printf's a little and call vfs_unmountall() if the sync was
successful.
cd9660_vfsops.c, ffs_vfsops.c, nfs_vfsops.c, lfs_vfsops.c:
Allow dismount of root FS. It is now disallowed at a higher level.
vfs_conf.c:
Removed unused rootfs global.
vfs_subr.c:
Added new routines vfs_unmountall and vfs_unmountroot. Filesystems
are now dismounted if the machine is properly rebooted.
ffs_vfsops.c:
Toggle clean bit at the appropriate places. Print warning if an
unclean FS is mounted.
ffs_vfsops.c, lfs_vfsops.c:
Fix bug in selecting proper flags for VOP_CLOSE().
vfs_syscalls.c:
Disallow dismounting root FS via umount syscall.
Notes
Notes:
svn path=/head/; revision=2152
Diffstat (limited to 'sys/kern/vfs_export.c')
-rw-r--r-- | sys/kern/vfs_export.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index d088b28bf317..e26b0303f20b 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 - * $Id: vfs_subr.c,v 1.3 1994/08/02 07:43:27 davidg Exp $ + * $Id: vfs_subr.c,v 1.4 1994/08/18 22:35:09 wollman Exp $ */ /* @@ -169,6 +169,70 @@ vfs_unbusy(mp) } } +void +vfs_unmountroot(rootfs) + struct mount *rootfs; +{ + struct mount *mp = rootfs; + int error; + + if (vfs_busy(mp)) { + printf("failed to unmount root\n"); + return; + } + + mp->mnt_flag |= MNT_UNMOUNT; + if (error = vfs_lock(mp)) { + printf("lock of root filesystem failed (%d)\n", error); + return; + } + + vnode_pager_umount(mp); /* release cached vnodes */ + cache_purgevfs(mp); /* remove cache entries for this file sys */ + + if (error = VFS_SYNC(mp, MNT_WAIT, initproc->p_ucred, initproc)) + printf("sync of root filesystem failed (%d)\n", error); + + if (error = VFS_UNMOUNT(mp, MNT_FORCE, initproc)) + printf("unmount of root filesystem failed (%d)\n", error); + + mp->mnt_flag &= ~MNT_UNMOUNT; + vfs_unbusy(mp); +} + +/* + * Unmount all filesystems. Should only be called by halt(). + */ +void +vfs_unmountall() +{ + struct mount *mp, *mp_next, *rootfs = NULL; + int error; + + /* unmount all but rootfs */ + for (mp = mountlist.tqh_first; mp != NULL; mp = mp_next) { + mp_next = mp->mnt_list.tqe_next; + + if (mp->mnt_flag & MNT_ROOTFS) { + rootfs = mp; + continue; + } + + error = dounmount(mp, MNT_FORCE, initproc); + if (error) { + printf("unmount of %s failed (%d)\n", + mp->mnt_stat.f_mntonname, error); + } + } + + /* and finally... */ + if (rootfs) { + vfs_unmountroot(rootfs); + } else { + printf("no root filesystem\n"); + } +} + /* * Lookup a mount point by filesystem identifier. */ |