4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1991, 1999-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #ident "%Z%%M% %I% %E% SMI" /* SunOS */
29 #include <sys/types.h>
30 #include <sys/errno.h>
32 #include <sys/tiuser.h>
34 #include <rpc/types.h>
38 #include <rpc/rpc_msg.h>
40 #include <rpcsvc/mount.h>
43 #include "snoop_nfs.h"
46 #define MIN(a, b) ((a) < (b) ? (a) : (b))
49 extern char *dlc_header
;
50 extern jmp_buf xdr_err
;
52 static void mountcall(int, int);
53 static void mountreply(int, int);
55 static void sum_mountstat(char *);
56 static void sum_mountstat3(char *);
57 static char *sum_mountfh(void);
58 static char *sum_mountfh3(void);
59 static char *sum_exports(void);
60 static char *sum_mounts(void);
62 static int detail_mountstat(void);
63 static void detail_mountstat3(void);
64 static void detail_mountfh(void);
65 static void detail_mountfh3(void);
66 static void detail_exports(void);
67 static void detail_mounts(void);
69 static char *statusmsg3(ulong_t
);
71 static char *procnames_short
[] = {
74 "Get mount list", /* 2 */
77 "Get export list", /* 5 */
78 "Get export list", /* 6 */
82 static char *procnames_long
[] = {
83 "Null procedure", /* 0 */
84 "Add mount entry", /* 1 */
85 "Return mount entries", /* 2 */
86 "Remove mount entry", /* 3 */
87 "Remove all mount entries", /* 4 */
88 "Return export list", /* 5 */
89 "Return export list", /* 6 */
90 "Get POSIX Pathconf info", /* 7 */
96 interpret_mount(flags
, type
, xid
, vers
, proc
, data
, len
)
97 int flags
, type
, xid
, vers
, proc
;
102 char buff
[MNTPATHLEN
+ 1];
104 if (proc
< 0 || proc
> MAXPROC
)
108 if (setjmp(xdr_err
)) {
112 line
= get_sum_line();
115 (void) sprintf(line
, "MOUNT%d C %s",
116 vers
, procnames_short
[proc
]);
117 line
+= strlen(line
);
121 (void) sprintf(line
, " %s",
122 getxdr_string(buff
, MNTPATHLEN
));
125 case MOUNTPROC_UMNTALL
:
126 case MOUNTPROC_EXPORT
:
127 case MOUNTPROC_EXPORTALL
:
128 #ifdef MOUNTPROC_PATHCONF
129 case MOUNTPROC_PATHCONF
:
131 (void) sprintf(line
, " %s",
140 check_retransmit(line
, xid
);
142 (void) sprintf(line
, "MOUNT%d R %s ",
143 vers
, procnames_short
[proc
]);
144 line
+= strlen(line
);
148 sum_mountstat3(line
);
153 (void) sprintf(line
, sum_mounts());
156 case MOUNTPROC_UMNTALL
:
157 (void) sprintf(line
, "reply");
159 case MOUNTPROC_EXPORTALL
:
161 * EXPORTALL is the same as EXPORT in v1
162 * and v2, and it doesn't exist in v3.
167 case MOUNTPROC_EXPORT
:
168 (void) sprintf(line
, sum_exports());
170 #ifdef MOUNTPROC_PATHCONF
171 case MOUNTPROC_PATHCONF
:
175 (void) sprintf(line
, sum_ppathcnf());
185 if (flags
& F_DTAIL
) {
186 show_header("MOUNT:", "NFS MOUNT", len
);
188 if (setjmp(xdr_err
)) {
191 (void) sprintf(get_line(0, 0),
193 proc
, procnames_long
[proc
]);
195 mountcall(proc
, vers
);
197 mountreply(proc
, vers
);
203 * Interpret call packets in detail
207 mountcall(proc
, vers
)
214 (void) showxdr_string(MNTPATHLEN
, "Directory = %s");
218 case MOUNTPROC_UMNTALL
:
220 case MOUNTPROC_EXPORTALL
:
224 case MOUNTPROC_EXPORT
:
226 #ifdef MOUNTPROC_PATHCONF
227 case MOUNTPROC_PATHCONF
:
230 (void) showxdr_string(MNTPATHLEN
, "File = %s");
239 * Interpret reply packets in detail
243 mountreply(proc
, vers
)
252 if (detail_mountstat() == 0) {
261 case MOUNTPROC_UMNTALL
:
262 (void) detail_mountstat();
264 case MOUNTPROC_EXPORTALL
:
268 case MOUNTPROC_EXPORT
:
271 #ifdef MOUNTPROC_PATHCONF
272 case MOUNTPROC_PATHCONF
:
274 (void) detail_ppathcnf();
290 status
= getxdr_u_long();
293 else if ((str
= strerror(status
)) == NULL
)
295 (void) strcpy(line
, str
);
297 (void) strcat(line
, sum_mountfh());
307 status
= getxdr_u_long();
310 else if ((str
= strerror(status
)) == NULL
)
313 (void) sprintf(get_line(0, 0), "Status = %d (%s)", status
, str
);
315 return ((int)status
);
324 fh
= sum_filehandle(NFS_FHSIZE
);
325 (void) sprintf(buff
, " FH=%08X", fh
);
336 fh
= sum_filehandle(NFS_FHSIZE
);
338 (void) sprintf(get_line(0, 0), "File handle = [%08X]", fh
);
339 (void) showxdr_hex(NFS_FHSIZE
, " %s");
345 int i
, auth
, flavors
;
347 static char buff
[64];
350 flavors
= getxdr_long();
351 for (i
= 0; i
< flavors
; i
++) {
353 (void) strlcat(buff
, ",", sizeof (buff
));
354 switch (auth
= getxdr_u_long()) {
356 (void) strlcat(buff
, "none", sizeof (buff
));
359 (void) strlcat(buff
, "unix", sizeof (buff
));
362 (void) strlcat(buff
, "short", sizeof (buff
));
365 (void) strlcat(buff
, "des", sizeof (buff
));
368 p
= buff
+ strlen(buff
);
369 if (p
< &buff
[sizeof (buff
)])
370 (void) snprintf(p
, sizeof (buff
) - strlen(buff
),
384 status
= getxdr_u_long();
385 (void) strcpy(line
, statusmsg3(status
));
387 (void) strcat(line
, sum_mountfh3());
388 (void) strcat(line
, " Auth=");
389 (void) strcat(line
, print_auth());
398 status
= getxdr_u_long();
399 (void) sprintf(get_line(0, 0), "Status = %d (%s)", status
,
403 (void) sprintf(get_line(0, 0), "Authentication flavor = %s",
416 fh
= sum_filehandle(len
);
417 (void) sprintf(buff
, " FH=%08X", fh
);
430 fh
= sum_filehandle(len
);
432 (void) sprintf(get_line(0, 0), "File handle = [%08X]", fh
);
435 l
= MIN(len
- i
, 32);
436 (void) showxdr_hex(l
, " %s");
444 static char buff
[MNTPATHLEN
+ 1];
447 if (setjmp(xdr_err
)) {
448 (void) sprintf(buff
, "%d+ entries", entries
);
452 while (getxdr_long()) {
453 (void) getxdr_string(buff
, MNTPATHLEN
);
454 while (getxdr_long()) {
455 (void) getxdr_string(buff
, MNTNAMLEN
);
460 (void) sprintf(buff
, "%d entries", entries
);
468 char *dirpath
, *grpname
;
469 char buff
[MNTPATHLEN
+ 1];
471 if (setjmp(xdr_err
)) {
472 (void) sprintf(get_line(0, 0),
473 " %d+ entries. (Frame is incomplete)",
478 while (getxdr_long()) {
479 dirpath
= (char *)getxdr_string(buff
, MNTPATHLEN
);
480 (void) sprintf(get_line(0, 0), "Directory = %s", dirpath
);
482 while (getxdr_long()) {
483 grpname
= (char *)getxdr_string(buff
, MNTNAMLEN
);
484 (void) sprintf(get_line(0, 0), " Group = %s", grpname
);
493 static char buff
[MNTPATHLEN
+ 1];
495 if (setjmp(xdr_err
)) {
496 (void) sprintf(buff
, "%d+ entries", entries
);
500 while (getxdr_long()) {
501 (void) getxdr_string(buff
, MNTNAMLEN
);
502 (void) getxdr_string(buff
, MNTPATHLEN
);
506 (void) sprintf(buff
, "%d entries", entries
);
514 char *hostname
, *directory
;
515 char buff1
[MNTNAMLEN
+ 1], buff2
[MNTPATHLEN
+ 1];
517 if (setjmp(xdr_err
)) {
518 (void) sprintf(get_line(0, 0),
519 " %d+ entries. (Frame is incomplete)",
524 (void) sprintf(get_line(0, 0), "Mount list");
526 while (getxdr_long()) {
527 hostname
= (char *)getxdr_string(buff1
, MNTNAMLEN
);
528 directory
= (char *)getxdr_string(buff2
, MNTPATHLEN
);
529 (void) sprintf(get_line(0, 0), " %s:%s", hostname
, directory
);
543 return ("Not owner");
545 return ("No such file or directory");
547 return ("I/O error");
549 return ("Permission denied");
551 return ("Not a directory");
553 return ("Invalid argument");
554 case MNT3ERR_NAMETOOLONG
:
555 return ("File name too long");
556 case MNT3ERR_NOTSUPP
:
557 return ("Operation not supported");
558 case MNT3ERR_SERVERFAULT
:
559 return ("Server error");
561 return ("(unknown error)");