038ddbfb10d2ff6c93f5f95fb1a49134591d6d3b
* Copyright (c) 1989, 1993, 1995
* The Regents of the University of California. All rights reserved.
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
* %sccs.include.redist.c%
static char copyright
[] =
"@(#) Copyright (c) 1989, 1993, 1995\n\
The Regents of the University of California. All rights reserved.\n";
static char sccsid
[] = "@(#)showmount.c 8.2 (Berkeley) %G%";
#include <sys/socketvar.h>
#include <rpc/pmap_clnt.h>
#include <rpc/pmap_prot.h>
struct mountlist
*ml_left
;
struct mountlist
*ml_right
;
char ml_host
[RPCMNT_NAMELEN
+1];
char ml_dirp
[RPCMNT_PATHLEN
+1];
struct grouplist
*gr_next
;
char gr_name
[RPCMNT_NAMELEN
+1];
struct exportslist
*ex_next
;
struct grouplist
*ex_groups
;
char ex_dirp
[RPCMNT_PATHLEN
+1];
static struct mountlist
*mntdump
;
static struct exportslist
*exports
;
void print_dump
__P((struct mountlist
*));
int xdr_mntdump
__P((XDR
*, struct mountlist
**));
int xdr_exports
__P((XDR
*, struct exportslist
**));
* This command queries the NFS mount daemon for it's mount list and/or
* it's exports list and prints them out.
* See "NFS: Network File System Protocol Specification, RFC1094, Appendix A"
* for detailed information on the protocol.
while ((ch
= getopt(argc
, argv
, "ade")) != EOF
)
if ((estat
= callrpc(host
, RPCPROG_MNT
, RPCMNT_VER1
,
RPCMNT_DUMP
, xdr_void
, (char *)0,
xdr_mntdump
, (char *)&mntdump
)) != 0) {
fprintf(stderr
, ": Can't do Mountdump rpc\n");
if ((estat
= callrpc(host
, RPCPROG_MNT
, RPCMNT_VER1
,
RPCMNT_EXPORT
, xdr_void
, (char *)0,
xdr_exports
, (char *)&exports
)) != 0) {
fprintf(stderr
, ": Can't do Exports rpc\n");
/* Now just print out the results */
printf("All mount points on %s:\n", host
);
printf("Directories on %s:\n", host
);
printf("Hosts on %s:\n", host
);
printf("Exports list on %s:\n", host
);
printf("%-35s", exp
->ex_dirp
);
printf("%s ", grp
->gr_name
);
* Xdr routine for retrieving the mount dump list
struct mountlist
*mp
, **otp
, *tp
;
*mlp
= (struct mountlist
*)0;
if (!xdr_bool(xdrsp
, &bool))
mp
= (struct mountlist
*)malloc(sizeof(struct mountlist
));
mp
->ml_left
= mp
->ml_right
= (struct mountlist
*)0;
if (!xdr_string(xdrsp
, &strp
, RPCMNT_NAMELEN
))
if (!xdr_string(xdrsp
, &strp
, RPCMNT_PATHLEN
))
* Build a binary tree on sorted order of either host or dirp.
val
= strcmp(mp
->ml_host
, tp
->ml_host
);
val2
= strcmp(mp
->ml_dirp
, tp
->ml_dirp
);
if (!xdr_bool(xdrsp
, &bool))
* Xdr routine to retrieve exports list
struct exportslist
**exp
;
*exp
= (struct exportslist
*)0;
if (!xdr_bool(xdrsp
, &bool))
ep
= (struct exportslist
*)malloc(sizeof(struct exportslist
));
ep
->ex_groups
= (struct grouplist
*)0;
if (!xdr_string(xdrsp
, &strp
, RPCMNT_PATHLEN
))
if (!xdr_bool(xdrsp
, &grpbool
))
gp
= (struct grouplist
*)malloc(sizeof(struct grouplist
));
if (!xdr_string(xdrsp
, &strp
, RPCMNT_NAMELEN
))
gp
->gr_next
= ep
->ex_groups
;
if (!xdr_bool(xdrsp
, &grpbool
))
if (!xdr_bool(xdrsp
, &bool))
fprintf(stderr
, "usage: showmount [-ade] host\n");
* Print the binary tree in inorder so that output is sorted.
printf("%s:%s\n", mp
->ml_host
, mp
->ml_dirp
);
printf("%s\n", mp
->ml_dirp
);
printf("%s\n", mp
->ml_host
);
print_dump(mp
->ml_right
);