* 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.5 (Berkeley) %G%";
#include <sys/socketvar.h>
#include <rpc/pmap_clnt.h>
#include <rpc/pmap_prot.h>
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_file
) < 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
;
struct sockaddr_in saddr
;
struct timeval pertry
, try;
enum clnt_stat clnt_stat
;
if (umount(name
, MNT_NOFORCE
) < 0) {
if ((delimp
= index(fs
->fs_spec
, '@')) != NULL
) {
if ((hp
= gethostbyname(hostp
)) != NULL
) {
bcopy(hp
->h_addr
,(caddr_t
)&saddr
.sin_addr
,hp
->h_length
);
saddr
.sin_family
= AF_INET
;
if ((clp
= clntudp_create(&saddr
, RPCPROG_MNT
,
RPCMNT_VER1
, pertry
, &so
)) == NULL
) {
clnt_pcreateerror("Cannot MNT PRC");
clp
->cl_auth
= authunix_create_default();
clnt_stat
= clnt_call(clp
, RPCMNT_UMOUNT
, xdr_dir
, fs
->fs_spec
,
xdr_void
, (caddr_t
)0, try);
if (clnt_stat
!= RPC_SUCCESS
) {
clnt_perror(clp
, "Bad MNT RPC");
auth_destroy(clp
->cl_auth
);
fprintf(stderr
, "%s: Unmounted\n", name
);
* xdr routines for mount rpc's
return (xdr_string(xdrsp
, &dirp
, RPCMNT_PATHLEN
));