Deleted Added
full compact
showmount.c (24825) showmount.c (28068)
1/*
1/*
2 * Copyright (c) 1989, 1993
2 * Copyright (c) 1989, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 19 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 19 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#ifndef lint
38static char copyright[] =
39"@(#) Copyright (c) 1989, 1993\n\
38static const char copyright[] =
39"@(#) Copyright (c) 1989, 1993, 1995\n\
40 The Regents of the University of California. All rights reserved.\n";
41#endif not lint
42
43#ifndef lint
40 The Regents of the University of California. All rights reserved.\n";
41#endif not lint
42
43#ifndef lint
44static char sccsid[] = "@(#)showmount.c 8.1 (Berkeley) 6/6/93";
44#if 0
45static char sccsid[] = "@(#)showmount.c 8.3 (Berkeley) 3/29/95";
46#endif
47static const char rcsid[] =
48 "$Id$";
45#endif not lint
46
47#include <sys/types.h>
48#include <sys/queue.h>
49#include <sys/file.h>
50#include <sys/socket.h>
51#include <sys/socketvar.h>
49#endif not lint
50
51#include <sys/types.h>
52#include <sys/queue.h>
53#include <sys/file.h>
54#include <sys/socket.h>
55#include <sys/socketvar.h>
56
57#include <err.h>
52#include <netdb.h>
53#include <rpc/rpc.h>
54#include <rpc/pmap_clnt.h>
55#include <rpc/pmap_prot.h>
56#include <nfs/rpcv2.h>
58#include <netdb.h>
59#include <rpc/rpc.h>
60#include <rpc/pmap_clnt.h>
61#include <rpc/pmap_prot.h>
62#include <nfs/rpcv2.h>
63
57#include <stdio.h>
64#include <stdio.h>
65#include <stdlib.h>
58#include <string.h>
66#include <string.h>
67#include <unistd.h>
59
60/* Constant defs */
61#define ALL 1
62#define DIRS 2
63
64#define DODUMP 0x1
65#define DOEXPORTS 0x2
66

--- 13 unchanged lines hidden (view full) ---

80 struct exportslist *ex_next;
81 struct grouplist *ex_groups;
82 char ex_dirp[RPCMNT_PATHLEN+1];
83};
84
85static struct mountlist *mntdump;
86static struct exportslist *exports;
87static int type = 0;
68
69/* Constant defs */
70#define ALL 1
71#define DIRS 2
72
73#define DODUMP 0x1
74#define DOEXPORTS 0x2
75

--- 13 unchanged lines hidden (view full) ---

89 struct exportslist *ex_next;
90 struct grouplist *ex_groups;
91 char ex_dirp[RPCMNT_PATHLEN+1];
92};
93
94static struct mountlist *mntdump;
95static struct exportslist *exports;
96static int type = 0;
88int xdr_mntdump(), xdr_exports();
89
97
98void print_dump __P((struct mountlist *));
99static void usage __P((void));
100int xdr_mntdump __P((XDR *, struct mountlist **));
101int xdr_exports __P((XDR *, struct exportslist **));
102
90/*
91 * This command queries the NFS mount daemon for it's mount list and/or
92 * it's exports list and prints them out.
93 * See "NFS: Network File System Protocol Specification, RFC1094, Appendix A"
94 * and the "Network File System Protocol XXX.."
95 * for detailed information on the protocol.
96 */
103/*
104 * This command queries the NFS mount daemon for it's mount list and/or
105 * it's exports list and prints them out.
106 * See "NFS: Network File System Protocol Specification, RFC1094, Appendix A"
107 * and the "Network File System Protocol XXX.."
108 * for detailed information on the protocol.
109 */
110int
97main(argc, argv)
98 int argc;
99 char **argv;
100{
111main(argc, argv)
112 int argc;
113 char **argv;
114{
101 register struct mountlist *mntp;
102 register struct exportslist *exp;
103 register struct grouplist *grp;
115 register struct exportslist *exp;
116 register struct grouplist *grp;
104 extern char *optarg;
105 extern int optind;
106 register int rpcs = 0, mntvers = 1;
107 char ch;
108 char *host;
109 int estat;
110
111 while ((ch = getopt(argc, argv, "ade3")) != -1)
112 switch((char)ch) {
113 case 'a':

--- 31 unchanged lines hidden (view full) ---

145 if (rpcs == 0)
146 rpcs = DODUMP;
147
148 if (rpcs & DODUMP)
149 if ((estat = callrpc(host, RPCPROG_MNT, mntvers,
150 RPCMNT_DUMP, xdr_void, (char *)0,
151 xdr_mntdump, (char *)&mntdump)) != 0) {
152 clnt_perrno(estat);
117 register int rpcs = 0, mntvers = 1;
118 char ch;
119 char *host;
120 int estat;
121
122 while ((ch = getopt(argc, argv, "ade3")) != -1)
123 switch((char)ch) {
124 case 'a':

--- 31 unchanged lines hidden (view full) ---

156 if (rpcs == 0)
157 rpcs = DODUMP;
158
159 if (rpcs & DODUMP)
160 if ((estat = callrpc(host, RPCPROG_MNT, mntvers,
161 RPCMNT_DUMP, xdr_void, (char *)0,
162 xdr_mntdump, (char *)&mntdump)) != 0) {
163 clnt_perrno(estat);
153 fprintf(stderr, "Can't do Mountdump rpc\n");
154 exit(1);
164 errx(1, "can't do mountdump rpc");
155 }
156 if (rpcs & DOEXPORTS)
157 if ((estat = callrpc(host, RPCPROG_MNT, mntvers,
158 RPCMNT_EXPORT, xdr_void, (char *)0,
159 xdr_exports, (char *)&exports)) != 0) {
160 clnt_perrno(estat);
165 }
166 if (rpcs & DOEXPORTS)
167 if ((estat = callrpc(host, RPCPROG_MNT, mntvers,
168 RPCMNT_EXPORT, xdr_void, (char *)0,
169 xdr_exports, (char *)&exports)) != 0) {
170 clnt_perrno(estat);
161 fprintf(stderr, "Can't do Exports rpc\n");
162 exit(1);
171 errx(1, "can't do exports rpc");
163 }
164
165 /* Now just print out the results */
166 if (rpcs & DODUMP) {
167 switch (type) {
168 case ALL:
169 printf("All mount points on %s:\n", host);
170 break;

--- 19 unchanged lines hidden (view full) ---

190 printf("%s ", grp->gr_name);
191 grp = grp->gr_next;
192 }
193 printf("\n");
194 }
195 exp = exp->ex_next;
196 }
197 }
172 }
173
174 /* Now just print out the results */
175 if (rpcs & DODUMP) {
176 switch (type) {
177 case ALL:
178 printf("All mount points on %s:\n", host);
179 break;

--- 19 unchanged lines hidden (view full) ---

199 printf("%s ", grp->gr_name);
200 grp = grp->gr_next;
201 }
202 printf("\n");
203 }
204 exp = exp->ex_next;
205 }
206 }
207 exit(0);
198}
199
200/*
201 * Xdr routine for retrieving the mount dump list
202 */
208}
209
210/*
211 * Xdr routine for retrieving the mount dump list
212 */
213int
203xdr_mntdump(xdrsp, mlp)
204 XDR *xdrsp;
205 struct mountlist **mlp;
206{
207 register struct mountlist *mp;
208 register struct mountlist *tp;
209 register struct mountlist **otp;
210 int val, val2;

--- 65 unchanged lines hidden (view full) ---

276 return (0);
277 }
278 return (1);
279}
280
281/*
282 * Xdr routine to retrieve exports list
283 */
214xdr_mntdump(xdrsp, mlp)
215 XDR *xdrsp;
216 struct mountlist **mlp;
217{
218 register struct mountlist *mp;
219 register struct mountlist *tp;
220 register struct mountlist **otp;
221 int val, val2;

--- 65 unchanged lines hidden (view full) ---

287 return (0);
288 }
289 return (1);
290}
291
292/*
293 * Xdr routine to retrieve exports list
294 */
295int
284xdr_exports(xdrsp, exp)
285 XDR *xdrsp;
286 struct exportslist **exp;
287{
288 register struct exportslist *ep;
289 register struct grouplist *gp;
290 int bool, grpbool;
291 char *strp;

--- 26 unchanged lines hidden (view full) ---

318 ep->ex_next = *exp;
319 *exp = ep;
320 if (!xdr_bool(xdrsp, &bool))
321 return (0);
322 }
323 return (1);
324}
325
296xdr_exports(xdrsp, exp)
297 XDR *xdrsp;
298 struct exportslist **exp;
299{
300 register struct exportslist *ep;
301 register struct grouplist *gp;
302 int bool, grpbool;
303 char *strp;

--- 26 unchanged lines hidden (view full) ---

330 ep->ex_next = *exp;
331 *exp = ep;
332 if (!xdr_bool(xdrsp, &bool))
333 return (0);
334 }
335 return (1);
336}
337
338static void
326usage()
327{
328 fprintf(stderr, "usage: showmount [-ade3] host\n");
329 exit(1);
330}
331
332/*
333 * Print the binary tree in inorder so that output is sorted.
334 */
339usage()
340{
341 fprintf(stderr, "usage: showmount [-ade3] host\n");
342 exit(1);
343}
344
345/*
346 * Print the binary tree in inorder so that output is sorted.
347 */
348void
335print_dump(mp)
336 struct mountlist *mp;
337{
338
339 if (mp == NULL)
340 return;
341 if (mp->ml_left)
342 print_dump(mp->ml_left);

--- 14 unchanged lines hidden ---
349print_dump(mp)
350 struct mountlist *mp;
351{
352
353 if (mp == NULL)
354 return;
355 if (mp->ml_left)
356 print_dump(mp->ml_left);

--- 14 unchanged lines hidden ---