1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1991, 1999-2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate * All rights reserved.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" /* SunOS */
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
30*7c478bd9Sstevel@tonic-gate #include <sys/errno.h>
31*7c478bd9Sstevel@tonic-gate #include <setjmp.h>
32*7c478bd9Sstevel@tonic-gate #include <sys/tiuser.h>
33*7c478bd9Sstevel@tonic-gate
34*7c478bd9Sstevel@tonic-gate #include <rpc/types.h>
35*7c478bd9Sstevel@tonic-gate #include <rpc/xdr.h>
36*7c478bd9Sstevel@tonic-gate #include <rpc/auth.h>
37*7c478bd9Sstevel@tonic-gate #include <rpc/clnt.h>
38*7c478bd9Sstevel@tonic-gate #include <rpc/rpc_msg.h>
39*7c478bd9Sstevel@tonic-gate #include <nfs/nfs.h>
40*7c478bd9Sstevel@tonic-gate #include <rpcsvc/mount.h>
41*7c478bd9Sstevel@tonic-gate #include <string.h>
42*7c478bd9Sstevel@tonic-gate #include "snoop.h"
43*7c478bd9Sstevel@tonic-gate #include "snoop_nfs.h"
44*7c478bd9Sstevel@tonic-gate
45*7c478bd9Sstevel@tonic-gate #ifndef MIN
46*7c478bd9Sstevel@tonic-gate #define MIN(a, b) ((a) < (b) ? (a) : (b))
47*7c478bd9Sstevel@tonic-gate #endif
48*7c478bd9Sstevel@tonic-gate
49*7c478bd9Sstevel@tonic-gate extern char *dlc_header;
50*7c478bd9Sstevel@tonic-gate extern jmp_buf xdr_err;
51*7c478bd9Sstevel@tonic-gate
52*7c478bd9Sstevel@tonic-gate static void mountcall(int, int);
53*7c478bd9Sstevel@tonic-gate static void mountreply(int, int);
54*7c478bd9Sstevel@tonic-gate
55*7c478bd9Sstevel@tonic-gate static void sum_mountstat(char *);
56*7c478bd9Sstevel@tonic-gate static void sum_mountstat3(char *);
57*7c478bd9Sstevel@tonic-gate static char *sum_mountfh(void);
58*7c478bd9Sstevel@tonic-gate static char *sum_mountfh3(void);
59*7c478bd9Sstevel@tonic-gate static char *sum_exports(void);
60*7c478bd9Sstevel@tonic-gate static char *sum_mounts(void);
61*7c478bd9Sstevel@tonic-gate
62*7c478bd9Sstevel@tonic-gate static int detail_mountstat(void);
63*7c478bd9Sstevel@tonic-gate static void detail_mountstat3(void);
64*7c478bd9Sstevel@tonic-gate static void detail_mountfh(void);
65*7c478bd9Sstevel@tonic-gate static void detail_mountfh3(void);
66*7c478bd9Sstevel@tonic-gate static void detail_exports(void);
67*7c478bd9Sstevel@tonic-gate static void detail_mounts(void);
68*7c478bd9Sstevel@tonic-gate
69*7c478bd9Sstevel@tonic-gate static char *statusmsg3(ulong_t);
70*7c478bd9Sstevel@tonic-gate
71*7c478bd9Sstevel@tonic-gate static char *procnames_short[] = {
72*7c478bd9Sstevel@tonic-gate "Null", /* 0 */
73*7c478bd9Sstevel@tonic-gate "Mount", /* 1 */
74*7c478bd9Sstevel@tonic-gate "Get mount list", /* 2 */
75*7c478bd9Sstevel@tonic-gate "Unmount", /* 3 */
76*7c478bd9Sstevel@tonic-gate "Unmountall", /* 4 */
77*7c478bd9Sstevel@tonic-gate "Get export list", /* 5 */
78*7c478bd9Sstevel@tonic-gate "Get export list", /* 6 */
79*7c478bd9Sstevel@tonic-gate "PATHCONF", /* 7 */
80*7c478bd9Sstevel@tonic-gate };
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gate static char *procnames_long[] = {
83*7c478bd9Sstevel@tonic-gate "Null procedure", /* 0 */
84*7c478bd9Sstevel@tonic-gate "Add mount entry", /* 1 */
85*7c478bd9Sstevel@tonic-gate "Return mount entries", /* 2 */
86*7c478bd9Sstevel@tonic-gate "Remove mount entry", /* 3 */
87*7c478bd9Sstevel@tonic-gate "Remove all mount entries", /* 4 */
88*7c478bd9Sstevel@tonic-gate "Return export list", /* 5 */
89*7c478bd9Sstevel@tonic-gate "Return export list", /* 6 */
90*7c478bd9Sstevel@tonic-gate "Get POSIX Pathconf info", /* 7 */
91*7c478bd9Sstevel@tonic-gate };
92*7c478bd9Sstevel@tonic-gate
93*7c478bd9Sstevel@tonic-gate #define MAXPROC 7
94*7c478bd9Sstevel@tonic-gate
95*7c478bd9Sstevel@tonic-gate void
interpret_mount(flags,type,xid,vers,proc,data,len)96*7c478bd9Sstevel@tonic-gate interpret_mount(flags, type, xid, vers, proc, data, len)
97*7c478bd9Sstevel@tonic-gate int flags, type, xid, vers, proc;
98*7c478bd9Sstevel@tonic-gate char *data;
99*7c478bd9Sstevel@tonic-gate int len;
100*7c478bd9Sstevel@tonic-gate {
101*7c478bd9Sstevel@tonic-gate char *line;
102*7c478bd9Sstevel@tonic-gate char buff[MNTPATHLEN + 1];
103*7c478bd9Sstevel@tonic-gate
104*7c478bd9Sstevel@tonic-gate if (proc < 0 || proc > MAXPROC)
105*7c478bd9Sstevel@tonic-gate return;
106*7c478bd9Sstevel@tonic-gate
107*7c478bd9Sstevel@tonic-gate if (flags & F_SUM) {
108*7c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
109*7c478bd9Sstevel@tonic-gate return;
110*7c478bd9Sstevel@tonic-gate }
111*7c478bd9Sstevel@tonic-gate
112*7c478bd9Sstevel@tonic-gate line = get_sum_line();
113*7c478bd9Sstevel@tonic-gate
114*7c478bd9Sstevel@tonic-gate if (type == CALL) {
115*7c478bd9Sstevel@tonic-gate (void) sprintf(line, "MOUNT%d C %s",
116*7c478bd9Sstevel@tonic-gate vers, procnames_short[proc]);
117*7c478bd9Sstevel@tonic-gate line += strlen(line);
118*7c478bd9Sstevel@tonic-gate switch (proc) {
119*7c478bd9Sstevel@tonic-gate case MOUNTPROC_MNT:
120*7c478bd9Sstevel@tonic-gate case MOUNTPROC_UMNT:
121*7c478bd9Sstevel@tonic-gate (void) sprintf(line, " %s",
122*7c478bd9Sstevel@tonic-gate getxdr_string(buff, MNTPATHLEN));
123*7c478bd9Sstevel@tonic-gate break;
124*7c478bd9Sstevel@tonic-gate case MOUNTPROC_DUMP:
125*7c478bd9Sstevel@tonic-gate case MOUNTPROC_UMNTALL:
126*7c478bd9Sstevel@tonic-gate case MOUNTPROC_EXPORT:
127*7c478bd9Sstevel@tonic-gate case MOUNTPROC_EXPORTALL:
128*7c478bd9Sstevel@tonic-gate #ifdef MOUNTPROC_PATHCONF
129*7c478bd9Sstevel@tonic-gate case MOUNTPROC_PATHCONF:
130*7c478bd9Sstevel@tonic-gate if (vers != 3)
131*7c478bd9Sstevel@tonic-gate (void) sprintf(line, " %s",
132*7c478bd9Sstevel@tonic-gate getxdr_string(buff,
133*7c478bd9Sstevel@tonic-gate MNTPATHLEN));
134*7c478bd9Sstevel@tonic-gate #endif
135*7c478bd9Sstevel@tonic-gate break;
136*7c478bd9Sstevel@tonic-gate default:
137*7c478bd9Sstevel@tonic-gate break;
138*7c478bd9Sstevel@tonic-gate }
139*7c478bd9Sstevel@tonic-gate
140*7c478bd9Sstevel@tonic-gate check_retransmit(line, xid);
141*7c478bd9Sstevel@tonic-gate } else {
142*7c478bd9Sstevel@tonic-gate (void) sprintf(line, "MOUNT%d R %s ",
143*7c478bd9Sstevel@tonic-gate vers, procnames_short[proc]);
144*7c478bd9Sstevel@tonic-gate line += strlen(line);
145*7c478bd9Sstevel@tonic-gate switch (proc) {
146*7c478bd9Sstevel@tonic-gate case MOUNTPROC_MNT:
147*7c478bd9Sstevel@tonic-gate if (vers == 3)
148*7c478bd9Sstevel@tonic-gate sum_mountstat3(line);
149*7c478bd9Sstevel@tonic-gate else
150*7c478bd9Sstevel@tonic-gate sum_mountstat(line);
151*7c478bd9Sstevel@tonic-gate break;
152*7c478bd9Sstevel@tonic-gate case MOUNTPROC_DUMP:
153*7c478bd9Sstevel@tonic-gate (void) sprintf(line, sum_mounts());
154*7c478bd9Sstevel@tonic-gate break;
155*7c478bd9Sstevel@tonic-gate case MOUNTPROC_UMNT:
156*7c478bd9Sstevel@tonic-gate case MOUNTPROC_UMNTALL:
157*7c478bd9Sstevel@tonic-gate (void) sprintf(line, "reply");
158*7c478bd9Sstevel@tonic-gate break;
159*7c478bd9Sstevel@tonic-gate case MOUNTPROC_EXPORTALL:
160*7c478bd9Sstevel@tonic-gate /*
161*7c478bd9Sstevel@tonic-gate * EXPORTALL is the same as EXPORT in v1
162*7c478bd9Sstevel@tonic-gate * and v2, and it doesn't exist in v3.
163*7c478bd9Sstevel@tonic-gate */
164*7c478bd9Sstevel@tonic-gate if (vers == 3)
165*7c478bd9Sstevel@tonic-gate break;
166*7c478bd9Sstevel@tonic-gate /*FALLTHROUGH*/
167*7c478bd9Sstevel@tonic-gate case MOUNTPROC_EXPORT:
168*7c478bd9Sstevel@tonic-gate (void) sprintf(line, sum_exports());
169*7c478bd9Sstevel@tonic-gate break;
170*7c478bd9Sstevel@tonic-gate #ifdef MOUNTPROC_PATHCONF
171*7c478bd9Sstevel@tonic-gate case MOUNTPROC_PATHCONF:
172*7c478bd9Sstevel@tonic-gate if (vers != 2)
173*7c478bd9Sstevel@tonic-gate break;
174*7c478bd9Sstevel@tonic-gate #ifdef notyet
175*7c478bd9Sstevel@tonic-gate (void) sprintf(line, sum_ppathcnf());
176*7c478bd9Sstevel@tonic-gate #endif
177*7c478bd9Sstevel@tonic-gate break;
178*7c478bd9Sstevel@tonic-gate #endif
179*7c478bd9Sstevel@tonic-gate default:
180*7c478bd9Sstevel@tonic-gate break;
181*7c478bd9Sstevel@tonic-gate }
182*7c478bd9Sstevel@tonic-gate }
183*7c478bd9Sstevel@tonic-gate }
184*7c478bd9Sstevel@tonic-gate
185*7c478bd9Sstevel@tonic-gate if (flags & F_DTAIL) {
186*7c478bd9Sstevel@tonic-gate show_header("MOUNT:", "NFS MOUNT", len);
187*7c478bd9Sstevel@tonic-gate show_space();
188*7c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
189*7c478bd9Sstevel@tonic-gate return;
190*7c478bd9Sstevel@tonic-gate }
191*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
192*7c478bd9Sstevel@tonic-gate "Proc = %d (%s)",
193*7c478bd9Sstevel@tonic-gate proc, procnames_long[proc]);
194*7c478bd9Sstevel@tonic-gate if (type == CALL)
195*7c478bd9Sstevel@tonic-gate mountcall(proc, vers);
196*7c478bd9Sstevel@tonic-gate else
197*7c478bd9Sstevel@tonic-gate mountreply(proc, vers);
198*7c478bd9Sstevel@tonic-gate show_trailer();
199*7c478bd9Sstevel@tonic-gate }
200*7c478bd9Sstevel@tonic-gate }
201*7c478bd9Sstevel@tonic-gate
202*7c478bd9Sstevel@tonic-gate /*
203*7c478bd9Sstevel@tonic-gate * Interpret call packets in detail
204*7c478bd9Sstevel@tonic-gate */
205*7c478bd9Sstevel@tonic-gate
206*7c478bd9Sstevel@tonic-gate static void
mountcall(proc,vers)207*7c478bd9Sstevel@tonic-gate mountcall(proc, vers)
208*7c478bd9Sstevel@tonic-gate int proc, vers;
209*7c478bd9Sstevel@tonic-gate {
210*7c478bd9Sstevel@tonic-gate
211*7c478bd9Sstevel@tonic-gate switch (proc) {
212*7c478bd9Sstevel@tonic-gate case MOUNTPROC_MNT:
213*7c478bd9Sstevel@tonic-gate case MOUNTPROC_UMNT:
214*7c478bd9Sstevel@tonic-gate (void) showxdr_string(MNTPATHLEN, "Directory = %s");
215*7c478bd9Sstevel@tonic-gate break;
216*7c478bd9Sstevel@tonic-gate case MOUNTPROC_DUMP:
217*7c478bd9Sstevel@tonic-gate break;
218*7c478bd9Sstevel@tonic-gate case MOUNTPROC_UMNTALL:
219*7c478bd9Sstevel@tonic-gate break;
220*7c478bd9Sstevel@tonic-gate case MOUNTPROC_EXPORTALL:
221*7c478bd9Sstevel@tonic-gate if (vers == 3)
222*7c478bd9Sstevel@tonic-gate break;
223*7c478bd9Sstevel@tonic-gate break;
224*7c478bd9Sstevel@tonic-gate case MOUNTPROC_EXPORT:
225*7c478bd9Sstevel@tonic-gate break;
226*7c478bd9Sstevel@tonic-gate #ifdef MOUNTPROC_PATHCONF
227*7c478bd9Sstevel@tonic-gate case MOUNTPROC_PATHCONF:
228*7c478bd9Sstevel@tonic-gate if (vers != 2)
229*7c478bd9Sstevel@tonic-gate break;
230*7c478bd9Sstevel@tonic-gate (void) showxdr_string(MNTPATHLEN, "File = %s");
231*7c478bd9Sstevel@tonic-gate #endif
232*7c478bd9Sstevel@tonic-gate break;
233*7c478bd9Sstevel@tonic-gate default:
234*7c478bd9Sstevel@tonic-gate break;
235*7c478bd9Sstevel@tonic-gate }
236*7c478bd9Sstevel@tonic-gate }
237*7c478bd9Sstevel@tonic-gate
238*7c478bd9Sstevel@tonic-gate /*
239*7c478bd9Sstevel@tonic-gate * Interpret reply packets in detail
240*7c478bd9Sstevel@tonic-gate */
241*7c478bd9Sstevel@tonic-gate
242*7c478bd9Sstevel@tonic-gate static void
mountreply(proc,vers)243*7c478bd9Sstevel@tonic-gate mountreply(proc, vers)
244*7c478bd9Sstevel@tonic-gate int proc, vers;
245*7c478bd9Sstevel@tonic-gate {
246*7c478bd9Sstevel@tonic-gate
247*7c478bd9Sstevel@tonic-gate switch (proc) {
248*7c478bd9Sstevel@tonic-gate case MOUNTPROC_MNT:
249*7c478bd9Sstevel@tonic-gate if (vers == 3) {
250*7c478bd9Sstevel@tonic-gate detail_mountstat3();
251*7c478bd9Sstevel@tonic-gate } else {
252*7c478bd9Sstevel@tonic-gate if (detail_mountstat() == 0) {
253*7c478bd9Sstevel@tonic-gate detail_mountfh();
254*7c478bd9Sstevel@tonic-gate }
255*7c478bd9Sstevel@tonic-gate }
256*7c478bd9Sstevel@tonic-gate break;
257*7c478bd9Sstevel@tonic-gate case MOUNTPROC_DUMP:
258*7c478bd9Sstevel@tonic-gate detail_mounts();
259*7c478bd9Sstevel@tonic-gate break;
260*7c478bd9Sstevel@tonic-gate case MOUNTPROC_UMNT:
261*7c478bd9Sstevel@tonic-gate case MOUNTPROC_UMNTALL:
262*7c478bd9Sstevel@tonic-gate (void) detail_mountstat();
263*7c478bd9Sstevel@tonic-gate break;
264*7c478bd9Sstevel@tonic-gate case MOUNTPROC_EXPORTALL:
265*7c478bd9Sstevel@tonic-gate if (vers == 3)
266*7c478bd9Sstevel@tonic-gate break;
267*7c478bd9Sstevel@tonic-gate /*FALLTHROUGH*/
268*7c478bd9Sstevel@tonic-gate case MOUNTPROC_EXPORT:
269*7c478bd9Sstevel@tonic-gate detail_exports();
270*7c478bd9Sstevel@tonic-gate break;
271*7c478bd9Sstevel@tonic-gate #ifdef MOUNTPROC_PATHCONF
272*7c478bd9Sstevel@tonic-gate case MOUNTPROC_PATHCONF:
273*7c478bd9Sstevel@tonic-gate #ifdef notyet
274*7c478bd9Sstevel@tonic-gate (void) detail_ppathcnf();
275*7c478bd9Sstevel@tonic-gate #endif
276*7c478bd9Sstevel@tonic-gate break;
277*7c478bd9Sstevel@tonic-gate #endif
278*7c478bd9Sstevel@tonic-gate default:
279*7c478bd9Sstevel@tonic-gate break;
280*7c478bd9Sstevel@tonic-gate }
281*7c478bd9Sstevel@tonic-gate }
282*7c478bd9Sstevel@tonic-gate
283*7c478bd9Sstevel@tonic-gate static void
sum_mountstat(line)284*7c478bd9Sstevel@tonic-gate sum_mountstat(line)
285*7c478bd9Sstevel@tonic-gate char *line;
286*7c478bd9Sstevel@tonic-gate {
287*7c478bd9Sstevel@tonic-gate ulong_t status;
288*7c478bd9Sstevel@tonic-gate char *str;
289*7c478bd9Sstevel@tonic-gate
290*7c478bd9Sstevel@tonic-gate status = getxdr_u_long();
291*7c478bd9Sstevel@tonic-gate if (status == 0)
292*7c478bd9Sstevel@tonic-gate str = "OK";
293*7c478bd9Sstevel@tonic-gate else if ((str = strerror(status)) == (char *)NULL)
294*7c478bd9Sstevel@tonic-gate str = "";
295*7c478bd9Sstevel@tonic-gate (void) strcpy(line, str);
296*7c478bd9Sstevel@tonic-gate if (status == 0) {
297*7c478bd9Sstevel@tonic-gate (void) strcat(line, sum_mountfh());
298*7c478bd9Sstevel@tonic-gate }
299*7c478bd9Sstevel@tonic-gate }
300*7c478bd9Sstevel@tonic-gate
301*7c478bd9Sstevel@tonic-gate static int
detail_mountstat()302*7c478bd9Sstevel@tonic-gate detail_mountstat()
303*7c478bd9Sstevel@tonic-gate {
304*7c478bd9Sstevel@tonic-gate ulong_t status;
305*7c478bd9Sstevel@tonic-gate char *str;
306*7c478bd9Sstevel@tonic-gate
307*7c478bd9Sstevel@tonic-gate status = getxdr_u_long();
308*7c478bd9Sstevel@tonic-gate if (status == 0)
309*7c478bd9Sstevel@tonic-gate str = "OK";
310*7c478bd9Sstevel@tonic-gate else if ((str = strerror(status)) == (char *)NULL)
311*7c478bd9Sstevel@tonic-gate str = "";
312*7c478bd9Sstevel@tonic-gate
313*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Status = %d (%s)", status, str);
314*7c478bd9Sstevel@tonic-gate
315*7c478bd9Sstevel@tonic-gate return ((int)status);
316*7c478bd9Sstevel@tonic-gate }
317*7c478bd9Sstevel@tonic-gate
318*7c478bd9Sstevel@tonic-gate char *
sum_mountfh()319*7c478bd9Sstevel@tonic-gate sum_mountfh()
320*7c478bd9Sstevel@tonic-gate {
321*7c478bd9Sstevel@tonic-gate int fh;
322*7c478bd9Sstevel@tonic-gate static char buff[8];
323*7c478bd9Sstevel@tonic-gate
324*7c478bd9Sstevel@tonic-gate fh = sum_filehandle(NFS_FHSIZE);
325*7c478bd9Sstevel@tonic-gate (void) sprintf(buff, " FH=%04X", fh & 0xFFFF);
326*7c478bd9Sstevel@tonic-gate return (buff);
327*7c478bd9Sstevel@tonic-gate }
328*7c478bd9Sstevel@tonic-gate
329*7c478bd9Sstevel@tonic-gate static void
detail_mountfh()330*7c478bd9Sstevel@tonic-gate detail_mountfh()
331*7c478bd9Sstevel@tonic-gate {
332*7c478bd9Sstevel@tonic-gate int pos;
333*7c478bd9Sstevel@tonic-gate int fh;
334*7c478bd9Sstevel@tonic-gate
335*7c478bd9Sstevel@tonic-gate pos = getxdr_pos();
336*7c478bd9Sstevel@tonic-gate fh = sum_filehandle(NFS_FHSIZE);
337*7c478bd9Sstevel@tonic-gate setxdr_pos(pos);
338*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "File handle = [%04X]", fh & 0xFFFF);
339*7c478bd9Sstevel@tonic-gate (void) showxdr_hex(NFS_FHSIZE, " %s");
340*7c478bd9Sstevel@tonic-gate }
341*7c478bd9Sstevel@tonic-gate
342*7c478bd9Sstevel@tonic-gate static char *
print_auth()343*7c478bd9Sstevel@tonic-gate print_auth()
344*7c478bd9Sstevel@tonic-gate {
345*7c478bd9Sstevel@tonic-gate int i, auth, flavors;
346*7c478bd9Sstevel@tonic-gate char *p;
347*7c478bd9Sstevel@tonic-gate static char buff[64];
348*7c478bd9Sstevel@tonic-gate
349*7c478bd9Sstevel@tonic-gate buff[0] = '\0';
350*7c478bd9Sstevel@tonic-gate flavors = getxdr_long();
351*7c478bd9Sstevel@tonic-gate for (i = 0; i < flavors; i++) {
352*7c478bd9Sstevel@tonic-gate if (i > 0)
353*7c478bd9Sstevel@tonic-gate (void) strlcat(buff, ",", sizeof (buff));
354*7c478bd9Sstevel@tonic-gate switch (auth = getxdr_u_long()) {
355*7c478bd9Sstevel@tonic-gate case AUTH_NONE:
356*7c478bd9Sstevel@tonic-gate (void) strlcat(buff, "none", sizeof (buff));
357*7c478bd9Sstevel@tonic-gate break;
358*7c478bd9Sstevel@tonic-gate case AUTH_UNIX:
359*7c478bd9Sstevel@tonic-gate (void) strlcat(buff, "unix", sizeof (buff));
360*7c478bd9Sstevel@tonic-gate break;
361*7c478bd9Sstevel@tonic-gate case AUTH_SHORT:
362*7c478bd9Sstevel@tonic-gate (void) strlcat(buff, "short", sizeof (buff));
363*7c478bd9Sstevel@tonic-gate break;
364*7c478bd9Sstevel@tonic-gate case AUTH_DES:
365*7c478bd9Sstevel@tonic-gate (void) strlcat(buff, "des", sizeof (buff));
366*7c478bd9Sstevel@tonic-gate break;
367*7c478bd9Sstevel@tonic-gate default:
368*7c478bd9Sstevel@tonic-gate p = buff + strlen(buff);
369*7c478bd9Sstevel@tonic-gate if (p < &buff[sizeof (buff)])
370*7c478bd9Sstevel@tonic-gate (void) snprintf(p, sizeof (buff) - strlen(buff),
371*7c478bd9Sstevel@tonic-gate "%d", auth);
372*7c478bd9Sstevel@tonic-gate break;
373*7c478bd9Sstevel@tonic-gate }
374*7c478bd9Sstevel@tonic-gate }
375*7c478bd9Sstevel@tonic-gate return (buff);
376*7c478bd9Sstevel@tonic-gate }
377*7c478bd9Sstevel@tonic-gate
378*7c478bd9Sstevel@tonic-gate static void
sum_mountstat3(line)379*7c478bd9Sstevel@tonic-gate sum_mountstat3(line)
380*7c478bd9Sstevel@tonic-gate char *line;
381*7c478bd9Sstevel@tonic-gate {
382*7c478bd9Sstevel@tonic-gate ulong_t status;
383*7c478bd9Sstevel@tonic-gate
384*7c478bd9Sstevel@tonic-gate status = getxdr_u_long();
385*7c478bd9Sstevel@tonic-gate (void) strcpy(line, statusmsg3(status));
386*7c478bd9Sstevel@tonic-gate if (status == 0) {
387*7c478bd9Sstevel@tonic-gate (void) strcat(line, sum_mountfh3());
388*7c478bd9Sstevel@tonic-gate (void) strcat(line, " Auth=");
389*7c478bd9Sstevel@tonic-gate (void) strcat(line, print_auth());
390*7c478bd9Sstevel@tonic-gate }
391*7c478bd9Sstevel@tonic-gate }
392*7c478bd9Sstevel@tonic-gate
393*7c478bd9Sstevel@tonic-gate static void
detail_mountstat3()394*7c478bd9Sstevel@tonic-gate detail_mountstat3()
395*7c478bd9Sstevel@tonic-gate {
396*7c478bd9Sstevel@tonic-gate ulong_t status;
397*7c478bd9Sstevel@tonic-gate
398*7c478bd9Sstevel@tonic-gate status = getxdr_u_long();
399*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Status = %d (%s)", status,
400*7c478bd9Sstevel@tonic-gate statusmsg3(status));
401*7c478bd9Sstevel@tonic-gate if (status == 0) {
402*7c478bd9Sstevel@tonic-gate detail_mountfh3();
403*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Authentication flavor = %s",
404*7c478bd9Sstevel@tonic-gate print_auth());
405*7c478bd9Sstevel@tonic-gate }
406*7c478bd9Sstevel@tonic-gate }
407*7c478bd9Sstevel@tonic-gate
408*7c478bd9Sstevel@tonic-gate char *
sum_mountfh3()409*7c478bd9Sstevel@tonic-gate sum_mountfh3()
410*7c478bd9Sstevel@tonic-gate {
411*7c478bd9Sstevel@tonic-gate int len;
412*7c478bd9Sstevel@tonic-gate int fh;
413*7c478bd9Sstevel@tonic-gate static char buff[8];
414*7c478bd9Sstevel@tonic-gate
415*7c478bd9Sstevel@tonic-gate len = getxdr_long();
416*7c478bd9Sstevel@tonic-gate fh = sum_filehandle(len);
417*7c478bd9Sstevel@tonic-gate (void) sprintf(buff, " FH=%04X", fh & 0xFFFF);
418*7c478bd9Sstevel@tonic-gate return (buff);
419*7c478bd9Sstevel@tonic-gate }
420*7c478bd9Sstevel@tonic-gate
421*7c478bd9Sstevel@tonic-gate static void
detail_mountfh3()422*7c478bd9Sstevel@tonic-gate detail_mountfh3()
423*7c478bd9Sstevel@tonic-gate {
424*7c478bd9Sstevel@tonic-gate int pos;
425*7c478bd9Sstevel@tonic-gate int i, l, len;
426*7c478bd9Sstevel@tonic-gate int fh;
427*7c478bd9Sstevel@tonic-gate
428*7c478bd9Sstevel@tonic-gate len = getxdr_long();
429*7c478bd9Sstevel@tonic-gate pos = getxdr_pos();
430*7c478bd9Sstevel@tonic-gate fh = sum_filehandle(len);
431*7c478bd9Sstevel@tonic-gate setxdr_pos(pos);
432*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "File handle = [%04X]", fh & 0xFFFF);
433*7c478bd9Sstevel@tonic-gate i = 0;
434*7c478bd9Sstevel@tonic-gate while (i < len) {
435*7c478bd9Sstevel@tonic-gate l = MIN(len - i, 32);
436*7c478bd9Sstevel@tonic-gate (void) showxdr_hex(l, " %s");
437*7c478bd9Sstevel@tonic-gate i += l;
438*7c478bd9Sstevel@tonic-gate }
439*7c478bd9Sstevel@tonic-gate }
440*7c478bd9Sstevel@tonic-gate
441*7c478bd9Sstevel@tonic-gate static char *
sum_exports()442*7c478bd9Sstevel@tonic-gate sum_exports()
443*7c478bd9Sstevel@tonic-gate {
444*7c478bd9Sstevel@tonic-gate static char buff[MNTPATHLEN + 1];
445*7c478bd9Sstevel@tonic-gate int entries = 0;
446*7c478bd9Sstevel@tonic-gate
447*7c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
448*7c478bd9Sstevel@tonic-gate (void) sprintf(buff, "%d+ entries", entries);
449*7c478bd9Sstevel@tonic-gate return (buff);
450*7c478bd9Sstevel@tonic-gate }
451*7c478bd9Sstevel@tonic-gate
452*7c478bd9Sstevel@tonic-gate while (getxdr_long()) {
453*7c478bd9Sstevel@tonic-gate (void) getxdr_string(buff, MNTPATHLEN);
454*7c478bd9Sstevel@tonic-gate while (getxdr_long()) {
455*7c478bd9Sstevel@tonic-gate (void) getxdr_string(buff, MNTNAMLEN);
456*7c478bd9Sstevel@tonic-gate }
457*7c478bd9Sstevel@tonic-gate entries++;
458*7c478bd9Sstevel@tonic-gate }
459*7c478bd9Sstevel@tonic-gate
460*7c478bd9Sstevel@tonic-gate (void) sprintf(buff, "%d entries", entries);
461*7c478bd9Sstevel@tonic-gate return (buff);
462*7c478bd9Sstevel@tonic-gate }
463*7c478bd9Sstevel@tonic-gate
464*7c478bd9Sstevel@tonic-gate static void
detail_exports()465*7c478bd9Sstevel@tonic-gate detail_exports()
466*7c478bd9Sstevel@tonic-gate {
467*7c478bd9Sstevel@tonic-gate int entries = 0;
468*7c478bd9Sstevel@tonic-gate char *dirpath, *grpname;
469*7c478bd9Sstevel@tonic-gate char buff[MNTPATHLEN + 1];
470*7c478bd9Sstevel@tonic-gate
471*7c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
472*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
473*7c478bd9Sstevel@tonic-gate " %d+ entries. (Frame is incomplete)",
474*7c478bd9Sstevel@tonic-gate entries);
475*7c478bd9Sstevel@tonic-gate return;
476*7c478bd9Sstevel@tonic-gate }
477*7c478bd9Sstevel@tonic-gate
478*7c478bd9Sstevel@tonic-gate while (getxdr_long()) {
479*7c478bd9Sstevel@tonic-gate dirpath = (char *)getxdr_string(buff, MNTPATHLEN);
480*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Directory = %s", dirpath);
481*7c478bd9Sstevel@tonic-gate entries++;
482*7c478bd9Sstevel@tonic-gate while (getxdr_long()) {
483*7c478bd9Sstevel@tonic-gate grpname = (char *)getxdr_string(buff, MNTNAMLEN);
484*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " Group = %s", grpname);
485*7c478bd9Sstevel@tonic-gate }
486*7c478bd9Sstevel@tonic-gate }
487*7c478bd9Sstevel@tonic-gate }
488*7c478bd9Sstevel@tonic-gate
489*7c478bd9Sstevel@tonic-gate static char *
sum_mounts()490*7c478bd9Sstevel@tonic-gate sum_mounts()
491*7c478bd9Sstevel@tonic-gate {
492*7c478bd9Sstevel@tonic-gate int entries = 0;
493*7c478bd9Sstevel@tonic-gate static char buff[MNTPATHLEN + 1];
494*7c478bd9Sstevel@tonic-gate
495*7c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
496*7c478bd9Sstevel@tonic-gate (void) sprintf(buff, "%d+ entries", entries);
497*7c478bd9Sstevel@tonic-gate return (buff);
498*7c478bd9Sstevel@tonic-gate }
499*7c478bd9Sstevel@tonic-gate
500*7c478bd9Sstevel@tonic-gate while (getxdr_long()) {
501*7c478bd9Sstevel@tonic-gate (void) getxdr_string(buff, MNTNAMLEN);
502*7c478bd9Sstevel@tonic-gate (void) getxdr_string(buff, MNTPATHLEN);
503*7c478bd9Sstevel@tonic-gate entries++;
504*7c478bd9Sstevel@tonic-gate }
505*7c478bd9Sstevel@tonic-gate
506*7c478bd9Sstevel@tonic-gate (void) sprintf(buff, "%d entries", entries);
507*7c478bd9Sstevel@tonic-gate return (buff);
508*7c478bd9Sstevel@tonic-gate }
509*7c478bd9Sstevel@tonic-gate
510*7c478bd9Sstevel@tonic-gate static void
detail_mounts()511*7c478bd9Sstevel@tonic-gate detail_mounts()
512*7c478bd9Sstevel@tonic-gate {
513*7c478bd9Sstevel@tonic-gate int entries = 0;
514*7c478bd9Sstevel@tonic-gate char *hostname, *directory;
515*7c478bd9Sstevel@tonic-gate char buff1[MNTNAMLEN + 1], buff2[MNTPATHLEN + 1];
516*7c478bd9Sstevel@tonic-gate
517*7c478bd9Sstevel@tonic-gate if (setjmp(xdr_err)) {
518*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0),
519*7c478bd9Sstevel@tonic-gate " %d+ entries. (Frame is incomplete)",
520*7c478bd9Sstevel@tonic-gate entries);
521*7c478bd9Sstevel@tonic-gate return;
522*7c478bd9Sstevel@tonic-gate }
523*7c478bd9Sstevel@tonic-gate
524*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), "Mount list");
525*7c478bd9Sstevel@tonic-gate
526*7c478bd9Sstevel@tonic-gate while (getxdr_long()) {
527*7c478bd9Sstevel@tonic-gate hostname = (char *)getxdr_string(buff1, MNTNAMLEN);
528*7c478bd9Sstevel@tonic-gate directory = (char *)getxdr_string(buff2, MNTPATHLEN);
529*7c478bd9Sstevel@tonic-gate (void) sprintf(get_line(0, 0), " %s:%s", hostname, directory);
530*7c478bd9Sstevel@tonic-gate entries++;
531*7c478bd9Sstevel@tonic-gate }
532*7c478bd9Sstevel@tonic-gate }
533*7c478bd9Sstevel@tonic-gate
534*7c478bd9Sstevel@tonic-gate char *
statusmsg3(status)535*7c478bd9Sstevel@tonic-gate statusmsg3(status)
536*7c478bd9Sstevel@tonic-gate ulong_t status;
537*7c478bd9Sstevel@tonic-gate {
538*7c478bd9Sstevel@tonic-gate
539*7c478bd9Sstevel@tonic-gate switch (status) {
540*7c478bd9Sstevel@tonic-gate case MNT_OK:
541*7c478bd9Sstevel@tonic-gate return ("OK");
542*7c478bd9Sstevel@tonic-gate case MNT3ERR_PERM:
543*7c478bd9Sstevel@tonic-gate return ("Not owner");
544*7c478bd9Sstevel@tonic-gate case MNT3ERR_NOENT:
545*7c478bd9Sstevel@tonic-gate return ("No such file or directory");
546*7c478bd9Sstevel@tonic-gate case MNT3ERR_IO:
547*7c478bd9Sstevel@tonic-gate return ("I/O error");
548*7c478bd9Sstevel@tonic-gate case MNT3ERR_ACCES:
549*7c478bd9Sstevel@tonic-gate return ("Permission denied");
550*7c478bd9Sstevel@tonic-gate case MNT3ERR_NOTDIR:
551*7c478bd9Sstevel@tonic-gate return ("Not a directory");
552*7c478bd9Sstevel@tonic-gate case MNT3ERR_INVAL:
553*7c478bd9Sstevel@tonic-gate return ("Invalid argument");
554*7c478bd9Sstevel@tonic-gate case MNT3ERR_NAMETOOLONG:
555*7c478bd9Sstevel@tonic-gate return ("File name too long");
556*7c478bd9Sstevel@tonic-gate case MNT3ERR_NOTSUPP:
557*7c478bd9Sstevel@tonic-gate return ("Operation not supported");
558*7c478bd9Sstevel@tonic-gate case MNT3ERR_SERVERFAULT:
559*7c478bd9Sstevel@tonic-gate return ("Server error");
560*7c478bd9Sstevel@tonic-gate default:
561*7c478bd9Sstevel@tonic-gate return ("(unknown error)");
562*7c478bd9Sstevel@tonic-gate }
563*7c478bd9Sstevel@tonic-gate }
564