static char *sccsid
= "@(#)umount.c 4.3 (Berkeley) %G%";
register struct mtab
*mp
;
mf
= open("/etc/mtab", 0);
read(mf
, (char *)mtab
, NMOUNT
*2*NAMSIZ
);
if (strcmp(argv
[1], "-a") == 0){
if (back
= umountfs(argv
[1])){
* It is important to unmount the files in
* reverse! order from the order they were mounted,
* so that file systems mounted as children to other
* file systems get removed in the right order.
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)
fprintf(stdout
, "Unmount of special file %s FAILED\n", fs
.fs_spec
);
fprintf(stdout
, "Unmounted special file %s\n", fs
.fs_spec
);
register struct mtab
*mp
;
while(p1
> name
&& *--p1
!= '/')
for (mp
= mtab
; mp
< &mtab
[NMOUNT
]; mp
++) {
for (p1
= mp
->file
; p1
< &mp
->file
[NAMSIZ
*2];)
while ((--mp
)->file
[0] == 0);
mf
= creat("/etc/mtab", 0644);
write(mf
, (char *)mtab
, (mp
-mtab
+1)*2*NAMSIZ
);
printf("%s not in mount table\n", name
);