diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-06 20:29:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-06 20:29:39 +0000 |
commit | 7472e7abc37d1d43120ae025f36f6803252efa88 (patch) | |
tree | 882530aa2d1c2f203f1de8a88065e8a7ad487b3d | |
parent | fbacbc08fbc22b0943eff6719e75f8d40d94d657 (diff) |
use mounted table instead of fstab for -a; netbsd pr#2363; from greywolf@defender.VAS.viewlogic.com
-rw-r--r-- | sbin/umount/umount.c | 43 |
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 |