Module Name: src
Committed By: dyoung
Date: Fri Apr 17 20:22:52 UTC 2009
Modified Files:
src/sys/kern: vfs_subr.c
src/sys/sys: mount.h
Log Message:
Make vfs_unmountall() return true if it was able to unmount any
filesystem at all, false otherwise. This will support tearing down
stacks of filesystems, ccd(4), raid(4), and vnd(4).
Change the misleading variable name 'allerror' to 'any_error'. Make it
a bool.
To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.186 -r1.187 src/sys/sys/mount.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.370 src/sys/kern/vfs_subr.c:1.371
--- src/sys/kern/vfs_subr.c:1.370 Mon Mar 30 16:38:05 2009
+++ src/sys/kern/vfs_subr.c Fri Apr 17 20:22:52 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.370 2009/03/30 16:38:05 yamt Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.371 2009/04/17 20:22:52 dyoung Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.370 2009/03/30 16:38:05 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.371 2009/04/17 20:22:52 dyoung Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -2230,14 +2230,15 @@
* We traverse the list in reverse order under the assumption that doing so
* will avoid needing to worry about dependencies.
*/
-void
+bool
vfs_unmountall(struct lwp *l)
{
struct mount *mp, *nmp;
- int allerror, error;
+ bool any_error, progress;
+ int error;
printf("unmounting file systems...");
- for (allerror = 0, mp = CIRCLEQ_LAST(&mountlist);
+ for (any_error = false, mp = CIRCLEQ_LAST(&mountlist);
!CIRCLEQ_EMPTY(&mountlist);
mp = nmp) {
nmp = CIRCLEQ_PREV(mp, mnt_list);
@@ -2246,15 +2247,18 @@
mp->mnt_stat.f_mntonname, mp->mnt_stat.f_mntfromname);
#endif
atomic_inc_uint(&mp->mnt_refcnt);
- if ((error = dounmount(mp, MNT_FORCE, l)) != 0) {
+ if ((error = dounmount(mp, MNT_FORCE, l)) == 0)
+ progress = true;
+ else {
printf("unmount of %s failed with error %d\n",
mp->mnt_stat.f_mntonname, error);
- allerror = 1;
+ any_error = true;
}
}
printf(" done\n");
- if (allerror)
+ if (any_error)
printf("WARNING: some file systems would not unmount\n");
+ return progress;
}
/*
Index: src/sys/sys/mount.h
diff -u src/sys/sys/mount.h:1.186 src/sys/sys/mount.h:1.187
--- src/sys/sys/mount.h:1.186 Sun Jan 11 02:45:55 2009
+++ src/sys/sys/mount.h Fri Apr 17 20:22:52 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: mount.h,v 1.186 2009/01/11 02:45:55 christos Exp $ */
+/* $NetBSD: mount.h,v 1.187 2009/04/17 20:22:52 dyoung Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@@ -389,7 +389,7 @@
int vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */
int vfs_mountroot(void);
void vfs_shutdown(void); /* unmount and sync file systems */
-void vfs_unmountall(struct lwp *); /* unmount file systems */
+bool vfs_unmountall(struct lwp *); /* unmount file systems */
int vfs_busy(struct mount *, struct mount **);
int vfs_rootmountalloc(const char *, const char *, struct mount **);
void vfs_unbusy(struct mount *, bool, struct mount **);