summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-05-06 20:29:38 +0000
committerderaadt <deraadt@openbsd.org>1996-05-06 20:29:38 +0000
commiteaa059b45499e56c0f3cdf3fe20674bd8717f4cd (patch)
treea390aa5ad3c48b943bbc0b9b66337ff4ac426772
parentremove unused files, conserning to the last sync (diff)
downloadwireguard-openbsd-eaa059b45499e56c0f3cdf3fe20674bd8717f4cd.tar.xz
wireguard-openbsd-eaa059b45499e56c0f3cdf3fe20674bd8717f4cd.zip
use mounted table instead of fstab for -a; netbsd pr#2363; from greywolf@defender.VAS.viewlogic.com
-rw-r--r--sbin/umount/umount.c43
1 files changed, 12 insertions, 31 deletions
diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c
index 403a09377ed..a807d76b329 100644
--- a/sbin/umount/umount.c
+++ b/sbin/umount/umount.c
@@ -144,38 +144,19 @@ main(argc, argv)
int
umountall()
{
- struct fstab *fs;
- int rval;
- char *cp;
-
- while ((fs = getfsent()) != NULL) {
- /* Ignore the root. */
- if (strcmp(fs->fs_file, "/") == 0)
- continue;
- /*
- * !!!
- * Historic practice: ignore unknown FSTAB_* fields.
- */
- if (strcmp(fs->fs_type, FSTAB_RW) &&
- strcmp(fs->fs_type, FSTAB_RO) &&
- strcmp(fs->fs_type, FSTAB_RQ))
- continue;
-
- if (!selected(fs->fs_vfstype))
- continue;
-
- /*
- * We want to unmount the file systems in the reverse order
- * that they were mounted. So, we save off the file name
- * in some allocated memory, and then call recursively.
- */
- if ((cp = malloc((size_t)strlen(fs->fs_file) + 1)) == NULL)
- err(1, NULL);
- (void)strcpy(cp, fs->fs_file);
- rval = umountall();
- return (umountfs(cp) || rval);
+ struct statfs *mtab;
+ int rval = 0;
+ int nfsys; /* number of mounted filesystems */
+ int i;
+
+ if (nfsys = getmntinfo(&mtab, MNT_NOWAIT)) {
+ for (i=nfsys - 1; i; i--) {
+ if (strcmp(mtab[i].f_mntonname, "/")) {
+ if (umountfs(mtab[i].f_mntonname)) rval = 1;
+ }
+ }
}
- return (0);
+ return(rval);
}
int