static char *sccsid
= "@(#)umount.c 4.6 (Berkeley) %G%";
register struct mtab
*mp
;
mf
= open("/etc/mtab", 0);
read(mf
, (char *)mtab
, sizeof (mtab
));
if (argc
> 0 && !strcmp(*argv
, "-v")) {
if (argc
> 0 && !strcmp(*argv
, "-a")) {
fprintf(stderr
, "Usage: umount [ -a ] [ -v ] [ dev ... ]\n");
if (umountfs(*argv
++) == 0)
if ((fsp
= getfsent()) == 0)
fs
= *fsp
; /* save info locally; it is static from getfsent() */
if (strcmp(fs
.fs_file
, "/") == 0)
if (strcmp(fs
.fs_type
, FSTAB_RW
) && strcmp(fs
.fs_type
, FSTAB_RO
))
if (umountfs(fs
.fs_spec
) < 0) {
register struct mtab
*mp
;
fprintf(stderr
, "%s: Unmounted\n", name
);
while ((p1
= rindex(name
, '/')) && p1
[1] == 0)
for (mp
= mtab
; mp
< &mtab
[NMOUNT
]; mp
++) {
if (strncmp(mp
->spec
, name
, sizeof (mp
->spec
)))
for (mp
= &mtab
[NMOUNT
]; mp
>= mtab
; mp
--)
mf
= creat("/etc/mtab", 0644);
write(mf
, (char *)mtab
, (mp
-mtab
) * sizeof (struct mtab
));
fprintf(stderr
, "%s: Not mounted\n", name
);