From eaa059b45499e56c0f3cdf3fe20674bd8717f4cd Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 6 May 1996 20:29:38 +0000 Subject: [PATCH] use mounted table instead of fstab for -a; netbsd pr#2363; from greywolf@defender.VAS.viewlogic.com --- sbin/umount/umount.c | 43 ++++++++++++------------------------------- 1 file 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 -- 2.20.1