Use kernel mount info rather than fstab. From greywolf@starwolf.com, slightly
modified.
This commit is contained in:
parent
50c94f92ce
commit
daa86d7011
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: umount.c,v 1.15 1995/09/22 02:03:48 mycroft Exp $ */
|
||||
/* $NetBSD: umount.c,v 1.16 1996/05/11 14:13:55 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1989, 1993
|
||||
|
@ -43,7 +43,7 @@ static char copyright[] =
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)umount.c 8.3 (Berkeley) 2/20/94";
|
||||
#else
|
||||
static char rcsid[] = "$NetBSD: umount.c,v 1.15 1995/09/22 02:03:48 mycroft Exp $";
|
||||
static char rcsid[] = "$NetBSD: umount.c,v 1.16 1996/05/11 14:13:55 mycroft Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -130,11 +130,9 @@ main(argc, argv)
|
|||
if ((nfshost != NULL) && (typelist == NULL))
|
||||
maketypelist("nfs");
|
||||
|
||||
if (all) {
|
||||
if (setfsent() == 0)
|
||||
err(1, "%s", _PATH_FSTAB);
|
||||
if (all)
|
||||
errs = umountall();
|
||||
} else
|
||||
else
|
||||
for (errs = 0; *argv != NULL; ++argv)
|
||||
if (umountfs(*argv) != 0)
|
||||
errs = 1;
|
||||
|
@ -144,38 +142,27 @@ main(argc, argv)
|
|||
int
|
||||
umountall()
|
||||
{
|
||||
struct fstab *fs;
|
||||
struct statfs *fs;
|
||||
int n;
|
||||
int rval;
|
||||
char *cp;
|
||||
|
||||
while ((fs = getfsent()) != NULL) {
|
||||
n = getmntinfo(&fs, MNT_NOWAIT);
|
||||
if (n == 0)
|
||||
err(1, NULL);
|
||||
|
||||
rval = 0;
|
||||
while (--n >= 0) {
|
||||
/* 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))
|
||||
if (strncmp(fs[n].f_mntonname, "/", MNAMELEN) == 0)
|
||||
continue;
|
||||
|
||||
if (!selected(fs->fs_vfstype))
|
||||
if (!selected(fs[n].f_fstypename))
|
||||
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);
|
||||
if (umountfs(fs[n].f_mntonname))
|
||||
rval = 1;
|
||||
}
|
||||
return (0);
|
||||
return (rval);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue