* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)umount.c 5.1 (Berkeley) %G%";
struct mtab mtab
[NMOUNT
];
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)
struct fstab
*fs
, *allocfsent();
if ((fs
= getfsent()) == 0)
if (strcmp(fs
->fs_file
, "/") == 0) {
if (strcmp(fs
->fs_type
, FSTAB_RW
) &&
strcmp(fs
->fs_type
, FSTAB_RO
) &&
strcmp(fs
->fs_type
, FSTAB_RQ
)) {
if (umountfs(fs
->fs_spec
) < 0)
register struct fstab
*fs
;
register struct fstab
*new;
new = (struct fstab
*)malloc(sizeof (*fs
));
cp
= malloc(strlen(fs
->fs_file
) + 1);
cp
= malloc(strlen(fs
->fs_type
) + 1);
cp
= malloc(strlen(fs
->fs_spec
) + 1);
new->fs_passno
= fs
->fs_passno
;
new->fs_freq
= fs
->fs_freq
;
register struct fstab
*fs
;
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
->m_dname
, name
, sizeof (mp
->m_dname
)))
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
);