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