diff options
author | bde <bde@FreeBSD.org> | 1997-07-06 06:54:14 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1997-07-06 06:54:14 +0000 |
commit | 4d7f45e2595cdda6921d9ed62f7ce9ba08453d13 (patch) | |
tree | 8a1e564deb1b54debb4947f8ee448223b4ef4fb3 /usr.bin/showmount/showmount.c | |
parent | e9b5b21c359ab94dbe38c62aa507bd29c30d295c (diff) | |
download | FreeBSD-src-4d7f45e2595cdda6921d9ed62f7ce9ba08453d13.zip FreeBSD-src-4d7f45e2595cdda6921d9ed62f7ce9ba08453d13.tar.gz |
Finish importing Lite2's src/usr.bin, except for ex, diff, grep, mail,
pascal and vmstat.sparc. All changed files on the vendor branch should
already have been imported.
Diffstat (limited to 'usr.bin/showmount/showmount.c')
-rw-r--r-- | usr.bin/showmount/showmount.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/usr.bin/showmount/showmount.c b/usr.bin/showmount/showmount.c index e5a3752..2eb07c2 100644 --- a/usr.bin/showmount/showmount.c +++ b/usr.bin/showmount/showmount.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1989, 1993 + * 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 @@ -36,25 +36,29 @@ #ifndef lint static char copyright[] = -"@(#) Copyright (c) 1989, 1993\n\ +"@(#) Copyright (c) 1989, 1993, 1995\n\ The Regents of the University of California. All rights reserved.\n"; #endif not lint #ifndef lint -static char sccsid[] = "@(#)showmount.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)showmount.c 8.3 (Berkeley) 3/29/95"; #endif not lint #include <sys/types.h> #include <sys/file.h> #include <sys/socket.h> #include <sys/socketvar.h> + #include <netdb.h> #include <rpc/rpc.h> #include <rpc/pmap_clnt.h> #include <rpc/pmap_prot.h> #include <nfs/rpcv2.h> + #include <stdio.h> +#include <stdlib.h> #include <string.h> +#include <unistd.h> /* Constant defs */ #define ALL 1 @@ -84,29 +88,30 @@ struct exportslist { static struct mountlist *mntdump; static struct exportslist *exports; static int type = 0; -int xdr_mntdump(), xdr_exports(); + +void print_dump __P((struct mountlist *)); +void usage __P((void)); +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" + * and the "Network File System Protocol XXX.." * for detailed information on the protocol. */ +int main(argc, argv) int argc; char **argv; { - register struct mountlist *mntp; - register struct exportslist *exp; - register struct grouplist *grp; - extern char *optarg; - extern int optind; - register int rpcs = 0; - char ch; - char *host; - int estat; + struct exportslist *exp; + struct grouplist *grp; + int estat, rpcs = 0, mntvers = 1; + char ch, *host; - while ((ch = getopt(argc, argv, "ade")) != EOF) + while ((ch = getopt(argc, argv, "ade3")) != EOF) switch((char)ch) { case 'a': if (type == 0) { @@ -125,6 +130,9 @@ main(argc, argv) case 'e': rpcs |= DOEXPORTS; break; + case '3': + mntvers = 3; + break; case '?': default: usage(); @@ -141,19 +149,19 @@ main(argc, argv) rpcs = DODUMP; if (rpcs & DODUMP) - if ((estat = callrpc(host, RPCPROG_MNT, RPCMNT_VER1, + if ((estat = callrpc(host, RPCPROG_MNT, mntvers, RPCMNT_DUMP, xdr_void, (char *)0, xdr_mntdump, (char *)&mntdump)) != 0) { clnt_perrno(estat); - fprintf(stderr, "Can't do Mountdump rpc\n"); + fprintf(stderr, ": Can't do Mountdump rpc\n"); exit(1); } if (rpcs & DOEXPORTS) - if ((estat = callrpc(host, RPCPROG_MNT, RPCMNT_VER1, + if ((estat = callrpc(host, RPCPROG_MNT, mntvers, RPCMNT_EXPORT, xdr_void, (char *)0, xdr_exports, (char *)&exports)) != 0) { clnt_perrno(estat); - fprintf(stderr, "Can't do Exports rpc\n"); + fprintf(stderr, ": Can't do Exports rpc\n"); exit(1); } @@ -190,20 +198,20 @@ main(argc, argv) exp = exp->ex_next; } } + + exit(0); } /* * Xdr routine for retrieving the mount dump list */ +int xdr_mntdump(xdrsp, mlp) XDR *xdrsp; struct mountlist **mlp; { - register struct mountlist *mp; - register struct mountlist *tp; - register struct mountlist **otp; - int val, val2; - int bool; + struct mountlist *mp, **otp, *tp; + int bool, val, val2; char *strp; *mlp = (struct mountlist *)0; @@ -276,12 +284,13 @@ next: /* * Xdr routine to retrieve exports list */ +int xdr_exports(xdrsp, exp) XDR *xdrsp; struct exportslist **exp; { - register struct exportslist *ep; - register struct grouplist *gp; + struct exportslist *ep; + struct grouplist *gp; int bool, grpbool; char *strp; @@ -318,8 +327,10 @@ xdr_exports(xdrsp, exp) return (1); } +void usage() { + fprintf(stderr, "usage: showmount [-ade] host\n"); exit(1); } @@ -327,6 +338,7 @@ usage() /* * Print the binary tree in inorder so that output is sorted. */ +void print_dump(mp) struct mountlist *mp; { |