diff options
author | dg <dg@FreeBSD.org> | 1994-08-20 16:03:26 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1994-08-20 16:03:26 +0000 |
commit | f817326b2eacf649d2b0d53d60ff2d4b6fd74577 (patch) | |
tree | e9031b5de5b5dd36f5609577351266694d3cb1ba /sys/kern/vfs_subr.c | |
parent | a376cb63c72e1f3347c10ab96276fd745e816fea (diff) | |
download | FreeBSD-src-f817326b2eacf649d2b0d53d60ff2d4b6fd74577.zip FreeBSD-src-f817326b2eacf649d2b0d53d60ff2d4b6fd74577.tar.gz |
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.
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index d088b28..e26b030 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.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. */ |