4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
27 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
35 #include <sys/types.h>
36 #include <sys/errno.h>
37 #include <sys/tiuser.h>
40 #include <rpc/types.h>
44 #include <rpc/rpc_msg.h>
48 #include <sys/param.h>
49 #include <rpcsvc/nfs_prot.h>
50 /* use the same nfs4_prot.h as the xdr code */
51 #include "rpcsvc/nfs4_prot.h"
54 * XXX With NFS v2 and v3, we only need to xdr the pieces that we care
55 * about. Anything else we can ignore and just skip to the next packet.
56 * So all the stuff that deals directly with XDR lives in snoop_display.c
57 * With v4, we need to XDR entire structures so that we can skip over
58 * uninteresting bits in a compound array, so we call XDR directly from
59 * here. We need to rethink how we're going to structure XDR access. Do
60 * we continue to hide it all in snoop_display.c, or do we expose it to all
61 * the protocol modules?
66 #define MIN(a, b) ((a) < (b) ? (a) : (b))
70 * Maximum number of characters to display in compound4 summary line.
72 #define SUM_COMPND_MAX 100
75 * Maximum number of recognized attributes.
77 #define MAX_ATTRIBUTES 56
80 * This data structure provides a more convenient way to access an
81 * attribute bitmask. map[N] = value of bit N in a bitmap4.
82 * It's defined as a struct so as to step around all the weird rules in C
83 * about arrays, pointers, passing them as arguments, etc.
87 char map
[MAX_ATTRIBUTES
];
91 static void sumarg_cb_getattr(char *buf
, size_t buflen
, void *obj
);
92 static void dtlarg_cb_getattr(void *obj
);
93 static void sumarg_cb_recall(char *buf
, size_t buflen
, void *obj
);
94 static void dtlarg_cb_recall(void *obj
);
97 static void sumarg_access(char *buf
, size_t buflen
, void *obj
);
98 static void dtlarg_access(void *obj
);
99 static void sumarg_close(char *buf
, size_t buflen
, void *obj
);
100 static void dtlarg_close(void *obj
);
101 static void sumarg_commit(char *buf
, size_t buflen
, void *obj
);
102 static void dtlarg_commit(void *obj
);
103 static void sumarg_compnt(char *buf
, size_t buflen
, void *obj
);
104 static void dtlarg_compnt(void *obj
);
105 static void sumarg_create(char *buf
, size_t buflen
, void *obj
);
106 static void dtlarg_create(void *obj
);
107 static void sumarg_delprge(char *buf
, size_t buflen
, void *obj
);
108 static void dtlarg_delprge(void *obj
);
109 static void sumarg_delret(char *buf
, size_t buflen
, void *obj
);
110 static void dtlarg_delret(void *obj
);
111 static void sumarg_getattr(char *buf
, size_t buflen
, void *obj
);
112 static void dtlarg_getattr(void *obj
);
113 static void sumarg_link(char *buf
, size_t buflen
, void *obj
);
114 static void dtlarg_link(void *obj
);
115 static void sum_open_to_lock_owner(char *buf
, int buflen
,
116 open_to_lock_owner4
*own
);
117 static void sum_exist_lock_owner(char *buf
, int buflen
,
118 exist_lock_owner4
*own
);
119 static void sum_locker(char *buf
, size_t buflen
, locker4
*lk
);
120 static void sumarg_lock(char *buf
, size_t buflen
, void *obj
);
121 static void detail_open_to_lock_owner(open_to_lock_owner4
*own
);
122 static void detail_exist_lock_owner(exist_lock_owner4
*own
);
123 static void detail_locker(locker4
*lk
);
124 static void dtlarg_lock(void *obj
);
125 static void sumarg_lockt(char *buf
, size_t buflen
, void *obj
);
126 static void dtlarg_lockt(void *obj
);
127 static void sumarg_locku(char *buf
, size_t buflen
, void *obj
);
128 static void dtlarg_locku(void *obj
);
129 static void sumarg_lookup(char *buf
, size_t buflen
, void *obj
);
130 static void dtlarg_lookup(void *obj
);
131 static void sumarg_open(char *buf
, size_t buflen
, void *obj
);
132 static void dtlarg_open(void *obj
);
133 static void sumarg_openattr(char *buf
, size_t buflen
, void *obj
);
134 static void dtlarg_openattr(void *obj
);
135 static void sumarg_open_confirm(char *buf
, size_t buflen
, void *obj
);
136 static void dtlarg_open_confirm(void *obj
);
137 static void sumarg_open_downgrd(char *buf
, size_t buflen
, void *obj
);
138 static void dtlarg_open_downgrd(void *obj
);
139 static void sumarg_putfh(char *buf
, size_t buflen
, void *obj
);
140 static void dtlarg_putfh(void *obj
);
141 static void sumarg_read(char *buf
, size_t buflen
, void *obj
);
142 static void dtlarg_read(void *obj
);
143 static void sumarg_readdir(char *buf
, size_t buflen
, void *obj
);
144 static void dtlarg_readdir(void *obj
);
145 static void sumarg_release_lkown(char *buf
, size_t buflen
, void *obj
);
146 static void dtlarg_release_lkown(void *obj
);
147 static void sumarg_rename(char *buf
, size_t buflen
, void *obj
);
148 static void dtlarg_rename(void *obj
);
149 static void sumarg_renew(char *buf
, size_t buflen
, void *obj
);
150 static void dtlarg_renew(void *buf
);
151 static void sumarg_secinfo(char *buf
, size_t buflen
, void *obj
);
152 static void dtlarg_secinfo(void *obj
);
153 static void sumarg_setattr(char *buf
, size_t buflen
, void *obj
);
154 static void dtlarg_setattr(void *obj
);
155 static void sumarg_setclid(char *buf
, size_t buflen
, void *obj
);
156 static void dtlarg_setclid(void *obj
);
157 static void sumarg_setclid_cfm(char *buf
, size_t buflen
, void *obj
);
158 static void dtlarg_setclid_cfm(void *obj
);
159 static void dtlarg_verify(void *obj
);
160 static void sumarg_write(char *buf
, size_t buflen
, void *obj
);
161 static void dtlarg_write(void *obj
);
163 static void sumres_cb_getattr(char *buf
, size_t buflen
, void *obj
);
164 static void dtlres_cb_getattr(void *obj
);
166 static void sumres_access(char *buf
, size_t buflen
, void *obj
);
167 static void dtlres_access(void *obj
);
168 static void sumres_close(char *buf
, size_t buflen
, void *obj
);
169 static void dtlres_close(void *obj
);
170 static void sumres_commit(char *buf
, size_t buflen
, void *obj
);
171 static void dtlres_commit(void *obj
);
172 static void dtlres_create(void *obj
);
173 static void sumres_getattr(char *buf
, size_t buflen
, void *obj
);
174 static void dtlres_getattr(void *obj
);
175 static void sumres_getfh(char *buf
, size_t buflen
, void *obj
);
176 static void dtlres_getfh(void *obj
);
177 static void dtlres_link(void *obj
);
178 static void sumres_lock(char *buf
, size_t buflen
, void *obj
);
179 static void dtlres_lock(void *obj
);
180 static void sumres_lockt(char *buf
, size_t buflen
, void *obj
);
181 static void dtlres_lockt(void *obj
);
182 static void sumres_locku(char *buf
, size_t buflen
, void *obj
);
183 static void dtlres_locku(void *obj
);
184 static void sumres_open(char *buf
, size_t buflen
, void *obj
);
185 static void dtlres_open(void *obj
);
186 static void sumres_open_confirm(char *buf
, size_t buflen
, void *obj
);
187 static void dtlres_open_confirm(void *obj
);
188 static void sumres_open_downgrd(char *buf
, size_t buflen
, void *obj
);
189 static void dtlres_open_downgrd(void *obj
);
190 static void sumres_read(char *buf
, size_t buflen
, void *obj
);
191 static void dtlres_read(void *obj
);
192 static void sumres_readdir(char *buf
, size_t buflen
, void *obj
);
193 static void dtlres_readdir(void *obj
);
194 static void sumres_readlnk(char *buf
, size_t buflen
, void *obj
);
195 static void dtlres_readlnk(void *obj
);
196 static void dtlres_remove(void *obj
);
197 static void dtlres_rename(void *obj
);
198 static void sumres_secinfo(char *buf
, size_t buflen
, void *obj
);
199 static void dtlres_secinfo(void *obj
);
200 static void sumres_setattr(char *buf
, size_t buflen
, void *obj
);
201 static void dtlres_setattr(void *obj
);
202 static void sumres_setclid(char *buf
, size_t buflen
, void *obj
);
203 static void dtlres_setclid(void *obj
);
204 static void sumres_write(char *buf
, size_t buflen
, void *obj
);
205 static void dtlres_write(void *obj
);
206 static void sum_nfsstat4(char *buf
, size_t buflen
, void *obj
);
207 static void dtl_nfsstat4(void *obj
);
208 static uint32_t adler16(void *, int);
209 static void nfs4_xdr_skip(int nbytes
);
210 static char *sum_lock_type_name(enum nfs_lock_type4 type
);
215 int nfs4_fragged_rpc
;
216 char *nfs4err_fragrpc
= "<Fragmented RPC>";
217 char *nfs4err_xdrfrag
= "<XDR Error or Fragmented RPC>";
220 * need a way to enable this if current testcases are parsing snoop
221 * error text. -- maybe an env var would do as temp workaround until
222 * testcases changed to grep for new error text.
224 int nfs4_use_old_error_text
= 0;
227 * Information about each operation that can appear in a compound call.
228 * The function pointers are to formatting functions for summary arguments
229 * and results, and detail arguments & results.
234 void (*sumarg
)(char *, size_t, void *);
235 void (*sumres
)(char *, size_t, void *);
236 void (*dtlarg
)(void *);
237 void (*dtlres
)(void *);
240 static op_info_t cb_opcode_info
[] = {
241 {"OP_ZERO", NULL
, NULL
, NULL
, NULL
}, /* 0 */
242 {"OP_ONE", NULL
, NULL
, NULL
, NULL
},
243 {"OP_TWO", NULL
, NULL
, NULL
, NULL
}, /* minor vers */
245 sumarg_cb_getattr
, sumres_cb_getattr
,
246 dtlarg_cb_getattr
, dtlres_cb_getattr
},
248 sumarg_cb_recall
, sum_nfsstat4
,
249 dtlarg_cb_recall
, dtl_nfsstat4
},
251 static uint_t cb_num_opcodes
= sizeof (cb_opcode_info
) / sizeof (op_info_t
*);
253 static op_info_t opcode_info
[] = {
254 {"OP_ZERO", NULL
, NULL
, NULL
, NULL
}, /* 0 */
255 {"OP_ONE", NULL
, NULL
, NULL
, NULL
},
256 {"OP_TWO", NULL
, NULL
, NULL
, NULL
}, /* minor vers */
258 sumarg_access
, sumres_access
, dtlarg_access
, dtlres_access
},
260 sumarg_close
, sumres_close
, dtlarg_close
, dtlres_close
},
262 sumarg_commit
, sumres_commit
, dtlarg_commit
, dtlres_commit
},
264 sumarg_create
, sum_nfsstat4
, dtlarg_create
, dtlres_create
},
266 sumarg_delprge
, sum_nfsstat4
, dtlarg_delprge
, dtl_nfsstat4
},
268 sumarg_delret
, sum_nfsstat4
, dtlarg_delret
, dtl_nfsstat4
},
270 sumarg_getattr
, sumres_getattr
, dtlarg_getattr
, dtlres_getattr
},
272 NULL
, sumres_getfh
, NULL
, dtlres_getfh
},
274 sumarg_link
, sum_nfsstat4
, dtlarg_link
, dtlres_link
},
276 sumarg_lock
, sumres_lock
, dtlarg_lock
, dtlres_lock
},
278 sumarg_lockt
, sumres_lockt
, dtlarg_lockt
, dtlres_lockt
},
280 sumarg_locku
, sumres_locku
, dtlarg_locku
, dtlres_locku
},
282 sumarg_lookup
, sum_nfsstat4
, dtlarg_lookup
, dtl_nfsstat4
},
284 NULL
, sum_nfsstat4
, NULL
, dtl_nfsstat4
},
286 NULL
, sum_nfsstat4
, dtlarg_verify
, dtl_nfsstat4
},
288 sumarg_open
, sumres_open
, dtlarg_open
, dtlres_open
},
290 sumarg_openattr
, sum_nfsstat4
, dtlarg_openattr
, dtl_nfsstat4
},
295 dtlres_open_confirm
},
300 dtlres_open_downgrd
},
302 sumarg_putfh
, sum_nfsstat4
, dtlarg_putfh
, dtl_nfsstat4
},
303 {"PUTPUBFH", /* 20 */
304 NULL
, sum_nfsstat4
, NULL
, dtl_nfsstat4
},
306 NULL
, sum_nfsstat4
, NULL
, dtl_nfsstat4
},
308 sumarg_read
, sumres_read
, dtlarg_read
, dtlres_read
},
310 sumarg_readdir
, sumres_readdir
, dtlarg_readdir
, dtlres_readdir
},
312 NULL
, sumres_readlnk
, NULL
, dtlres_readlnk
},
314 sumarg_compnt
, sum_nfsstat4
, dtlarg_compnt
, dtlres_remove
},
316 sumarg_rename
, sum_nfsstat4
, dtlarg_rename
, dtlres_rename
},
318 sumarg_renew
, sum_nfsstat4
, dtlarg_renew
, dtl_nfsstat4
},
320 NULL
, sum_nfsstat4
, NULL
, dtl_nfsstat4
},
322 NULL
, sum_nfsstat4
, NULL
, dtl_nfsstat4
},
324 sumarg_secinfo
, sumres_secinfo
, dtlarg_secinfo
, dtlres_secinfo
},
326 sumarg_setattr
, sumres_setattr
, dtlarg_setattr
, dtlres_setattr
},
328 sumarg_setclid
, sumres_setclid
, dtlarg_setclid
, dtlres_setclid
},
329 {"SETCLIENTID_CONFIRM",
335 NULL
, sum_nfsstat4
, dtlarg_verify
, dtl_nfsstat4
},
337 sumarg_write
, sumres_write
, dtlarg_write
, dtlres_write
},
338 {"RELEASE_LOCKOWNER",
339 sumarg_release_lkown
, sum_nfsstat4
,
340 dtlarg_release_lkown
, dtl_nfsstat4
},
342 static uint_t num_opcodes
= sizeof (opcode_info
) / sizeof (op_info_t
*);
349 char *short_name
; /* for summary output */
350 char *long_name
; /* for detail output */
353 static ftype_names_t ftype_names
[] = {
354 {"Type 0", "Type 0"},
355 {"REG", "Regular File"},
356 {"DIR", "Directory"},
357 {"BLK", "Block Device"},
358 {"CHR", "Character Device"},
359 {"LNK", "Symbolic Link"}, /* 5 */
362 {"ATTRDIR", "Attribute Directory"},
363 {"NAMEDATTR", "Named Attribute"},
365 static uint_t num_ftypes
= sizeof (ftype_names
) / sizeof (ftype_names_t
);
367 static ftype_names_t open_rflags
[] = {
368 {"?", "UNKNOWN"}, /* 0 */
369 {"CF", "CONFIRM"}, /* 1 */
370 {"PL", "POSIX LOCK"}, /* 2 */
373 static uint_t num_open_rflags
=
374 sizeof (open_rflags
) / sizeof (ftype_names_t
) - 1;
376 static char *get_flags(uint_t
, ftype_names_t
*, uint_t
, int, char *);
378 #define sum_open_rflags(flag) \
379 get_flags((flag), open_rflags, num_open_rflags, 1, " RF=")
381 #define detail_open_rflags(flag) \
382 get_flags((flag), open_rflags, num_open_rflags, 0, NULL)
384 static void prt_supported_attrs(XDR
*);
385 static void prt_type(XDR
*);
386 static void prt_fh_expire_type(XDR
*);
387 static void prt_change(XDR
*);
388 static void prt_size(XDR
*);
389 static void prt_link_support(XDR
*);
390 static void prt_symlink_support(XDR
*);
391 static void prt_named_attr(XDR
*);
392 static void prt_fsid(XDR
*);
393 static void prt_unique_handles(XDR
*);
394 static void prt_lease_time(XDR
*);
395 static void prt_rdattr_error(XDR
*);
396 static void prt_acl(XDR
*);
397 static void prt_aclsupport(XDR
*);
398 static void prt_archive(XDR
*);
399 static void prt_cansettime(XDR
*);
400 static void prt_case_insensitive(XDR
*);
401 static void prt_case_preserving(XDR
*);
402 static void prt_chown_restricted(XDR
*);
403 static void prt_filehandle(XDR
*);
404 static void prt_fileid(XDR
*);
405 static void prt_mounted_on_fileid(XDR
*);
406 static void prt_files_avail(XDR
*);
407 static void prt_files_free(XDR
*);
408 static void prt_files_total(XDR
*);
409 static void prt_fs_locations(XDR
*);
410 static void prt_hidden(XDR
*);
411 static void prt_homogeneous(XDR
*);
412 static void prt_maxfilesize(XDR
*);
413 static void prt_maxlink(XDR
*);
414 static void prt_maxname(XDR
*);
415 static void prt_maxread(XDR
*);
416 static void prt_maxwrite(XDR
*);
417 static void prt_mimetype(XDR
*);
418 static void prt_mode(XDR
*);
419 static void prt_no_trunc(XDR
*);
420 static void prt_numlinks(XDR
*);
421 static void prt_owner(XDR
*);
422 static void prt_owner_group(XDR
*);
423 static void prt_quota_avail_hard(XDR
*);
424 static void prt_quota_avail_soft(XDR
*);
425 static void prt_quota_used(XDR
*);
426 static void prt_rawdev(XDR
*);
427 static void prt_space_avail(XDR
*);
428 static void prt_space_free(XDR
*);
429 static void prt_space_total(XDR
*);
430 static void prt_space_used(XDR
*);
431 static void prt_system(XDR
*);
432 static void prt_time_access(XDR
*);
433 static void prt_time_access_set(XDR
*);
434 static void prt_time_backup(XDR
*);
435 static void prt_time_create(XDR
*);
436 static void prt_time_delta(XDR
*);
437 static void prt_time_metadata(XDR
*);
438 static void prt_time_modify(XDR
*);
439 static void prt_time_modify_set(XDR
*);
444 * Information for attributes.
445 * name name of the attribute.
446 * prt_details function to XDR decode the attribute and print it.
448 * XXX If this table ever gets extensively changed (including
449 * reorganization to track changes to the spec), it would probably be a
450 * good idea to change to a scheme where the table is mechanically
451 * generated. Look at $SRC/uts/common/rpcsvc for how this is done in the
457 void (*prt_details
)(XDR
*);
460 static attr_info_t attr_info
[MAX_ATTRIBUTES
] = {
461 {"SUPPORTED_ATTRS", prt_supported_attrs
},
463 {"FH_EXPIRE_TYPE", prt_fh_expire_type
},
464 {"CHANGE", prt_change
},
466 {"LINK_SUPPORT", prt_link_support
}, /* 5 */
467 {"SYMLINK_SUPPORT", prt_symlink_support
},
468 {"NAMED_ATTR", prt_named_attr
},
470 {"UNIQUE_HANDLES", prt_unique_handles
},
471 {"LEASE_TIME", prt_lease_time
}, /* 10 */
472 {"RDATTR_ERROR", prt_rdattr_error
},
474 {"ACLSUPPORT", prt_aclsupport
},
475 {"ARCHIVE", prt_archive
},
476 {"CANSETTIME", prt_cansettime
}, /* 15 */
477 {"CASE_INSENSITIVE", prt_case_insensitive
},
478 {"CASE_PRESERVING", prt_case_preserving
},
479 {"CHOWN_RESTRICTED", prt_chown_restricted
},
480 {"FILEHANDLE", prt_filehandle
},
481 {"FILEID", prt_fileid
}, /* 20 */
482 {"FILES_AVAIL", prt_files_avail
},
483 {"FILES_FREE", prt_files_free
},
484 {"FILES_TOTAL", prt_files_total
},
485 {"FS_LOCATIONS", prt_fs_locations
},
486 {"HIDDEN", prt_hidden
}, /* 25 */
487 {"HOMOGENEOUS", prt_homogeneous
},
488 {"MAXFILESIZE", prt_maxfilesize
},
489 {"MAXLINK", prt_maxlink
},
490 {"MAXNAME", prt_maxname
},
491 {"MAXREAD", prt_maxread
}, /* 30 */
492 {"MAXWRITE", prt_maxwrite
},
493 {"MIMETYPE", prt_mimetype
},
495 {"NO_TRUNC", prt_no_trunc
},
496 {"NUMLINKS", prt_numlinks
}, /* 35 */
497 {"OWNER", prt_owner
},
498 {"OWNER_GROUP", prt_owner_group
},
499 {"QUOTA_AVAIL_HARD", prt_quota_avail_hard
},
500 {"QUOTA_AVAIL_SOFT", prt_quota_avail_soft
},
501 {"QUOTA_USED", prt_quota_used
}, /* 40 */
502 {"RAWDEV", prt_rawdev
},
503 {"SPACE_AVAIL", prt_space_avail
},
504 {"SPACE_FREE", prt_space_free
},
505 {"SPACE_TOTAL", prt_space_total
},
506 {"SPACE_USED", prt_space_used
}, /* 45 */
507 {"SYSTEM", prt_system
},
508 {"TIME_ACCESS", prt_time_access
},
509 {"TIME_ACCESS_SET", prt_time_access_set
},
510 {"TIME_BACKUP", prt_time_backup
},
511 {"TIME_CREATE", prt_time_create
}, /* 50 */
512 {"TIME_DELTA", prt_time_delta
},
513 {"TIME_METADATA", prt_time_metadata
},
514 {"TIME_MODIFY", prt_time_modify
},
515 {"TIME_MODIFY_SET", prt_time_modify_set
},
516 {"MOUNTED_ON_FILEID", prt_mounted_on_fileid
},
519 extern char *get_sum_line();
521 extern jmp_buf xdr_err
;
523 static void sum_comp4res(char *, char *(*)(void));
524 static char *sum_compound4args(void);
525 static char *sum_compound4res(void);
526 static char *sum_operand(nfs_argop4
*opp
);
527 static char *sum_result(nfs_resop4
*resp
);
529 static char *sum_cb_compound4args(void);
530 static char *sum_cb_compound4res(void);
531 static char *sum_cb_operand(nfs_cb_argop4
*opp
);
532 static char *sum_cb_result(nfs_cb_resop4
*resp
);
534 static void detail_acetype4(acetype4
);
535 static void detail_uint32_bitmap(uint32_t, char *[], int);
536 static void detail_aceflag4(aceflag4
);
537 static void detail_acemask4(acemask4
);
538 static void detail_nfs_argop4(void);
539 static void detail_nfs_resop4(void);
540 static void detail_cb_argop4(void);
541 static void detail_cb_resop4(void);
543 static char *attr_name(uint_t
);
544 static char *claim_name(enum open_claim_type4 claim_type
);
545 static char *delegation_type_name(enum open_delegation_type4 type
);
546 static char *flavor_name(uint_t flavor
);
547 static char *gss_svc_name(rpc_gss_svc_t svc
);
548 static char *limitby_name(enum limit_by4 limitby
);
549 static char *lock_type_name(enum nfs_lock_type4
);
550 static char *opcode_name(uint_t
);
551 static char *cb_opcode_name(uint_t opnum
);
552 static char *status_name(int);
553 static char *status_name_compat(int);
554 static char *status_name_pcol(int);
555 static char *sum_type_name(nfs_ftype4
);
556 static void sum_access4(char *buf
, size_t buflen
, uint32_t bits
);
557 static void detail_access4(char *, uint32_t);
558 static void sum_claim(char *buf
, size_t buflen
, open_claim4
*claim
);
559 static void detail_claim(open_claim4
*claim
);
560 static char *sum_clientid(clientid4 client
);
561 static void detail_clientid(clientid4 client
);
562 static char *_sum_stateid(stateid4
*, char *prefix
);
563 static void sum_delegation(char *buf
, size_t buflen
, open_delegation4
*delp
);
564 static void detail_delegation(open_delegation4
*delp
);
565 static void detail_lock_owner(lock_owner4
*owner
);
566 static void detail_open_owner(open_owner4
*owner
);
567 static void sum_openflag(char *bufp
, int buflen
, openflag4
*flagp
);
568 static char *get_deleg_typestr(open_delegation_type4 dt
);
569 static void detail_openflag(openflag4
*flagp
);
570 static void sum_name(char *buf
, size_t buflen
, open_claim4
*claim
);
571 static void detail_rpcsec_gss(rpcsec_gss_info
*);
572 static void detail_secinfo4(secinfo4
*infop
);
573 static char *sum_space_limit(nfs_space_limit4
*limitp
);
574 static void detail_space_limit(nfs_space_limit4
*limitp
);
575 static char *detail_type_name(nfs_ftype4
);
576 static char *createhow4_name(createhow4
*crtp
);
579 static void showxdr_utf8string(char *);
580 static char *utf8localize(utf8string
*);
581 static void utf8free(void);
582 static void sum_pathname4(char *, size_t, pathname4
*);
583 static void detail_pathname4(pathname4
*pathp
, char *);
584 static void sum_compname4(char *buf
, size_t buflen
, component4
*comp
);
585 static void detail_compname4(component4
*comp
);
587 static void detail_fattr4(fattr4
*attrp
);
588 static void detail_attr_bitmap(char *, bitmap4
*, unpkd_attrmap_t
*);
589 static void sum_attr_bitmap(char *buf
, size_t buflen
, bitmap4
*mapp
);
590 static void detail_fattr4_change(char *msg
, fattr4_change chg
);
591 static char *sum_fh4(nfs_fh4
*fhp
);
592 static void detail_fh4(nfs_fh4
*fh
);
594 #define fh4_hash(fh) adler16((fh)->nfs_fh4_val, (fh)->nfs_fh4_len)
595 #define stateid_hash(st) adler16((st)->other, sizeof ((st)->other))
596 #define owner_hash(own) adler16((own)->owner_val, (own)->owner_len)
598 #define sum_deleg_stateid(st) _sum_stateid((st), "DST=")
599 #define sum_open_stateid(st) _sum_stateid((st), "OST=")
600 #define sum_lock_stateid(st) _sum_stateid((st), "LST=")
601 #define sum_stateid(st) _sum_stateid((st), "ST=")
603 #define detail_deleg_stateid(st) _detail_stateid((st), "Delegation ")
604 #define detail_open_stateid(st) _detail_stateid((st), "Open ")
605 #define detail_lock_stateid(st) _detail_stateid((st), "Lock ")
606 #define detail_stateid(st) _detail_stateid((st), "")
608 #define SPECIAL_STATEID0 "SPC0"
609 #define SPECIAL_STATEID1 "SPC1"
611 #define DONT_CHANGE 0
612 #define SET_TO_SERVER_TIME 1
613 #define SET_TO_CLIENT_TIME 2
615 static stateid4 spec_stateid_0
=
616 {0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
617 static stateid4 spec_stateid_1
=
618 {0xFFFFFFFF, {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};
620 static char *procnames_short
[] = {
625 static char *procnames_long
[] = {
626 "Null procedure", /* 0 */
630 static char *cb_procnames_short
[] = {
632 "CB_COMPOUND" /* 1 */
635 static char *cb_procnames_long
[] = {
636 "Null CallBack procedure", /* 0 */
637 "CallBack compound", /* 1 */
640 static char *acetype4_names
[] = {
641 "ACE4_ACCESS_ALLOWED_ACE_TYPE",
642 "ACE4_ACCESS_DENIED_ACE_TYPE",
643 "ACE4_SYSTEM_AUDIT_ACE_TYPE",
644 "ACE4_SYSTEM_ALARM_ACE_TYPE"
646 #define ACETYPE4_NAMES_MAX (sizeof (acetype4_names) / sizeof (char *))
648 static char *aceflag4_names
[] = {
649 "ACE4_FILE_INHERIT_ACE",
650 "ACE4_DIRECTORY_INHERIT_ACE",
651 "ACE4_NO_PROPAGATE_INHERIT_ACE",
652 "ACE4_INHERIT_ONLY_ACE",
653 "ACE4_SUCCESSFUL_ACCESS_ACE_FLAG",
654 "ACE4_FAILED_ACCESS_ACE_FLAG",
655 "ACE4_IDENTIFIER_GROUP"
657 #define ACEFLAG4_NAMES_MAX (sizeof (aceflag4_names) / sizeof (char *))
659 static char *acemask4_names
[] = {
660 "ACE4_READ_DATA/ACE4_LIST_DIRECTORY",
661 "ACE4_WRITE_DATA/ACE4_ADD_FILE",
662 "ACE4_APPEND_DATA/ACE4_ADD_SUBDIRECTORY",
663 "ACE4_READ_NAMED_ATTRS",
664 "ACE4_WRITE_NAMED_ATTRS",
667 "ACE4_READ_ATTRIBUTES",
668 "ACE4_WRITE_ATTRIBUTES",
669 "UNDEFINED", /* 0x00000200 */
670 "UNDEFINED", /* 0x00000400 */
671 "UNDEFINED", /* 0x00000800 */
672 "UNDEFINED", /* 0x00001000 */
673 "UNDEFINED", /* 0x00002000 */
674 "UNDEFINED", /* 0x00004000 */
675 "UNDEFINED", /* 0x00008000 */
682 #define ACEMASK4_NAMES_MAX (sizeof (acemask4_names) / sizeof (char *))
688 interpret_nfs4_cb(int flags
, int type
, int xid
, int vers
, int proc
,
693 if (proc
< 0 || proc
> MAXPROC
)
697 line
= get_sum_line();
700 (void) sprintf(line
, "NFS C %s",
701 proc
== CB_COMPOUND
? "CB4" :
702 cb_procnames_short
[proc
]);
703 line
+= strlen(line
);
705 if (proc
== CB_COMPOUND
) {
706 static utf8string tag
;
708 if (!xdr_utf8string(&xdrm
, &tag
))
710 sprintf(line
, " (%.20s) %s",
712 sum_cb_compound4args());
713 xdr_free(xdr_utf8string
, (char *)&tag
);
715 check_retransmit(line
, xid
);
717 (void) sprintf(line
, "NFS R %s ",
718 proc
== CB_COMPOUND
? "CB4" :
719 cb_procnames_short
[proc
]);
720 line
+= strlen(line
);
721 if (proc
== CB_COMPOUND
)
722 sum_comp4res(line
, sum_cb_compound4res
);
726 if (flags
& F_DTAIL
) {
727 show_header("NFS: ", "Sun NFS4 CallBack", len
);
729 (void) sprintf(get_line(0, 0), "Proc = %d (%s)",
730 proc
, cb_procnames_long
[proc
]);
731 if (proc
== CB_COMPOUND
) {
733 showxdr_utf8string("Tag = %s");
738 status
= getxdr_long();
739 showxdr_utf8string("Tag = %s");
740 sprintf(get_line(0, 0), "Status = %d (%s)",
741 status
, status_name(status
));
748 utf8free(); /* cf. utf8localize() */
754 interpret_nfs4(int flags
, int type
, int xid
, int vers
, int proc
,
759 if (proc
< 0 || proc
> MAXPROC
)
762 nfs4_fragged_rpc
= 0;
764 nfs4_pkt_start
= xdr_getpos(&xdrm
);
767 line
= get_sum_line();
770 (void) sprintf(line
, "NFS C %s",
771 proc
== NFSPROC4_COMPOUND
? "4" :
772 procnames_short
[proc
]);
773 line
+= strlen(line
);
775 if (proc
== NFSPROC4_COMPOUND
) {
776 static utf8string tag
;
778 if (!xdr_utf8string(&xdrm
, &tag
))
780 sprintf(line
, " (%.20s) %s",
782 sum_compound4args());
783 xdr_free(xdr_utf8string
, (char *)&tag
);
785 check_retransmit(line
, xid
);
787 (void) sprintf(line
, "NFS R %s ",
788 proc
== NFSPROC4_COMPOUND
? "4" :
789 procnames_short
[proc
]);
790 line
+= strlen(line
);
792 if (proc
== NFSPROC4_COMPOUND
)
793 sum_comp4res(line
, sum_compound4res
);
797 if (flags
& F_DTAIL
) {
798 show_header("NFS: ", "Sun NFS", len
);
800 (void) sprintf(get_line(0, 0), "Proc = %d (%s)",
801 proc
, procnames_long
[proc
]);
802 if (proc
== NFSPROC4_COMPOUND
) {
804 showxdr_utf8string("Tag = %s");
809 status
= getxdr_long();
810 showxdr_utf8string("Tag = %s");
811 sprintf(get_line(0, 0), "Status = %d (%s)",
812 status
, status_name(status
));
819 utf8free(); /* cf. utf8localize() */
825 * Return the names and arguments of the oplist elements, up to
826 * SUM_COMPND_MAX characters. If the elements don't fit, include a "..."
827 * at the end of the string.
831 sum_compound4args(void)
833 static char buf
[SUM_COMPND_MAX
+ 2]; /* 1 for null, 1 for overflow */
835 const size_t buflen
= sizeof (buf
);
838 uint32_t minor_version
;
842 if (setjmp(xdr_err
)) {
843 bp
= buf
+ strlen(buf
);
844 snprintf(bp
, buflen
- (bp
- buf
),
845 nfs4_fragged_rpc
? nfs4err_fragrpc
: nfs4err_xdrfrag
);
850 * might be nice to print minor version, but doesn't
851 * seem like very useful info for summary mode
853 if (!xdr_uint32_t(&xdrm
, &minor_version
))
856 numops
= getxdr_long();
858 while (numops
-- > 0) {
861 bzero(&one_op
, sizeof (one_op
));
863 if (!xdr_nfs_argop4(&xdrm
, &one_op
)) {
864 xdr_free(xdr_nfs_argop4
, (char *)&one_op
);
867 snprintf(bp
, buflen
- (bp
- buf
), "%s ",
868 opcode_name(one_op
.argop
));
871 operand
= sum_operand(&one_op
);
872 if (strlen(operand
) > 0) {
873 snprintf(bp
, buflen
- (bp
- buf
), "%s ", operand
);
877 /* nfs4_skip_bytes set by xdr_nfs4_argop4 */
878 if (nfs4_skip_bytes
!= 0)
879 nfs4_xdr_skip(nfs4_skip_bytes
);
881 xdr_free(xdr_nfs_argop4
, (char *)&one_op
);
883 /* add "..." if past the "end" of the buffer */
884 if (bp
- buf
> SUM_COMPND_MAX
) {
885 strcpy(buf
+ SUM_COMPND_MAX
- strlen("..."),
895 nfs4_xdr_skip(int nbytes
)
897 int resid
, off
, len
, cur_pos
, new_pos
;
900 cur_pos
= xdr_getpos(&xdrm
);
903 * Time to skip over the rd/wr data. If the
904 * rd/wr data is completely contained in the first
905 * frag, we must skip over it to process the rest of
908 * nfs4_pkt_start: XDR position of start of NFS4 compound
909 * nfs4_pkt_len: number of bytes in pkt relative to
912 * cur_pos: current XDR position
913 * off: current XDR position relative to nfs4_pkt_start
914 * resid: number of unprocessed bytes in current pkt
915 * (relative to cur_pos/off)
917 * If nbytes <= resid, then we must skip over the rd/wr
918 * bytes so we can read the next op/compound in this
919 * packet. Otherwise, set the fragged flag so we can
920 * display the fragged_rpc message.
922 off
= cur_pos
- nfs4_pkt_start
;
923 resid
= nfs4_pkt_len
- off
;
926 * set nfs4_fragged_rpc if the requested number of "skip"
927 * bytes is larger than the bytes remaining in the XDR
928 * stream/current packet. The global is reset to 0 at
929 * start of interpret_nfs4.
931 new_pos
= cur_pos
+ ((nfs4_fragged_rpc
= len
> resid
) ? resid
: len
);
933 /* there's nothing to do for error case (if it fails pkt is doomed) */
934 xdr_setpos(&xdrm
, new_pos
);
939 * Return the names and arguments of the oplist elements, up to
940 * SUM_COMPND_MAX characters. If the elements don't fit, include a "..."
941 * at the end of the string.
944 sum_cb_compound4args(void)
946 static char buf
[SUM_COMPND_MAX
+ 2]; /* 1 for null, 1 for overflow */
948 const size_t buflen
= sizeof (buf
);
950 nfs_cb_argop4 one_op
;
951 uint32_t minor_version
, callback_ident
;
954 if (setjmp(xdr_err
)) {
955 bp
= buf
+ strlen(buf
);
956 snprintf(bp
, buflen
- (bp
- buf
), "<XDR Error or Fragmented"
962 * might be nice to print minor version, but doesn't
963 * seem like very useful info for summary mode
965 if (!xdr_uint32_t(&xdrm
, &minor_version
))
968 /* print callback_ident */
969 if (!xdr_uint32_t(&xdrm
, &callback_ident
))
971 snprintf(buf
, buflen
, "CBID=%u ", callback_ident
);
973 bp
= buf
+ strlen(buf
);
974 numops
= getxdr_long();
976 while (numops
-- > 0) {
979 bzero(&one_op
, sizeof (one_op
));
980 if (!xdr_nfs_cb_argop4(&xdrm
, &one_op
)) {
981 xdr_free(xdr_nfs_cb_argop4
, (char *)&one_op
);
985 snprintf(bp
, buflen
- (bp
- buf
), "%s ",
986 cb_opcode_name(one_op
.argop
));
988 operand
= sum_cb_operand(&one_op
);
989 if (strlen(operand
) > 0) {
990 snprintf(bp
, buflen
- (bp
- buf
), "%s ", operand
);
994 xdr_free(xdr_nfs_cb_argop4
, (char *)&one_op
);
996 /* add "..." if past the "end" of the buffer */
997 if (bp
- buf
> SUM_COMPND_MAX
) {
998 strcpy(buf
+ SUM_COMPND_MAX
- strlen("..."),
1008 * Return the summarized argument list for the given nfs_argop4.
1012 sum_operand(nfs_argop4
*opp
)
1014 static char buf
[1024];
1015 void (*fmtproc
)(char *, size_t, void *);
1018 if (opp
->argop
< num_opcodes
) {
1019 fmtproc
= opcode_info
[opp
->argop
].sumarg
;
1020 if (fmtproc
!= NULL
)
1021 fmtproc(buf
, sizeof (buf
), &opp
->nfs_argop4_u
);
1028 * Return the summarized argument list for the given nfs_argop4.
1032 sum_cb_operand(nfs_cb_argop4
*opp
)
1034 static char buf
[1024];
1035 void (*fmtproc
)(char *, size_t, void *);
1038 if (opp
->argop
< cb_num_opcodes
) {
1039 fmtproc
= cb_opcode_info
[opp
->argop
].sumarg
;
1040 if (fmtproc
!= NULL
)
1041 fmtproc(buf
, sizeof (buf
), &opp
->nfs_cb_argop4_u
);
1048 * Print details about the nfs_argop4 that is next in the XDR stream.
1052 detail_nfs_argop4(void)
1056 void (*fmtproc
)(void *);
1057 uint32_t minor_version
;
1059 if (!xdr_uint32_t(&xdrm
, &minor_version
))
1060 longjmp(xdr_err
, 1);
1062 (void) sprintf(get_line(0, 0), "Minor version = %u",
1065 numops
= getxdr_long();
1066 (void) sprintf(get_line(0, 0), "Number of operations = %d",
1069 while (numops
-- > 0) {
1070 bzero(&one_op
, sizeof (one_op
));
1072 if (!xdr_nfs_argop4(&xdrm
, &one_op
)) {
1073 xdr_free(xdr_nfs_argop4
, (char *)&one_op
);
1074 longjmp(xdr_err
, 1);
1077 get_line(0, 0); /* blank line to separate ops */
1078 sprintf(get_line(0, 0), "Op = %d (%s)",
1079 one_op
.argop
, opcode_name(one_op
.argop
));
1080 if (one_op
.argop
< num_opcodes
) {
1081 fmtproc
= opcode_info
[one_op
.argop
].dtlarg
;
1082 if (fmtproc
!= NULL
)
1083 fmtproc(&one_op
.nfs_argop4_u
);
1086 /* nfs4_skip_bytes set by xdr_nfs_argop4() */
1087 if (nfs4_skip_bytes
)
1088 nfs4_xdr_skip(nfs4_skip_bytes
);
1090 xdr_free(xdr_nfs_argop4
, (char *)&one_op
);
1096 * Print details about the nfs_argop4 that is next in the XDR stream.
1099 detail_cb_argop4(void)
1102 nfs_cb_argop4 one_op
;
1103 void (*fmtproc
)(void *);
1104 uint32_t minor_version
, callback_ident
;
1106 if (!xdr_uint32_t(&xdrm
, &minor_version
))
1107 longjmp(xdr_err
, 1);
1108 (void) sprintf(get_line(0, 0), "Minor version = %u",
1111 if (!xdr_uint32_t(&xdrm
, &callback_ident
))
1112 longjmp(xdr_err
, 1);
1113 (void) sprintf(get_line(0, 0), "Callback Ident = %u",
1116 numops
= getxdr_long();
1117 (void) sprintf(get_line(0, 0), "Number of operations = %d",
1120 while (numops
-- > 0) {
1121 bzero(&one_op
, sizeof (one_op
));
1122 if (!xdr_nfs_cb_argop4(&xdrm
, &one_op
)) {
1123 xdr_free(xdr_nfs_cb_argop4
, (char *)&one_op
);
1124 longjmp(xdr_err
, 1);
1127 get_line(0, 0); /* blank line to separate ops */
1128 sprintf(get_line(0, 0), "Op = %d (%s)",
1129 one_op
.argop
, cb_opcode_name(one_op
.argop
));
1130 if (one_op
.argop
< cb_num_opcodes
) {
1131 fmtproc
= cb_opcode_info
[one_op
.argop
].dtlarg
;
1132 if (fmtproc
!= NULL
)
1133 fmtproc(&one_op
.nfs_cb_argop4_u
);
1136 xdr_free(xdr_nfs_cb_argop4
, (char *)&one_op
);
1141 * component_name: return a printable string for the given component4. I'm
1142 * leaving this as a separate function (as opposed to having the callers
1143 * call utf8localize() directly) in case the definition of component4
1148 component_name(component4
*cp
)
1150 return (utf8localize(cp
));
1154 * linktext_name. cf. component_name().
1158 linktext_name(linktext4
*lp
)
1160 return (utf8localize((utf8string
*)lp
));
1164 * stable_how4_name: return a string for "how".
1168 stable_how4_name(stable_how4 how
)
1191 * sum_open_share_access: return a string corresponding to the
1192 * given OPEN share access bitmask.
1196 sum_open_share_access(int32_t mask
)
1204 case OPEN4_SHARE_ACCESS_READ
:
1207 case OPEN4_SHARE_ACCESS_WRITE
:
1210 case OPEN4_SHARE_ACCESS_BOTH
:
1222 * sum_open_share_deny: return a string corresponding to the
1223 * given OPEN share deny bitmask.
1227 sum_open_share_deny(int32_t mask
)
1232 case OPEN4_SHARE_DENY_NONE
:
1235 case OPEN4_SHARE_DENY_READ
:
1238 case OPEN4_SHARE_DENY_WRITE
:
1241 case OPEN4_SHARE_DENY_BOTH
:
1253 special_stateid(stateid4
*stateid
)
1256 if (! memcmp(stateid
, &spec_stateid_0
, sizeof (*stateid
)))
1259 if (! memcmp(stateid
, &spec_stateid_1
, sizeof (*stateid
)))
1266 _sum_stateid(stateid4
*stateid
, char *prefix
)
1268 static char buf
[32];
1271 if ((spec
= special_stateid(stateid
)) < 0)
1272 snprintf(buf
, sizeof (buf
), "%s%04X:%u", prefix
,
1273 stateid_hash(stateid
), stateid
->seqid
);
1275 snprintf(buf
, sizeof (buf
), "%s%s", prefix
,
1276 spec
== 0 ? "SPC0" : (spec
== 1 ? "SPC1" : "SPC?"));
1281 _detail_stateid(stateid4
*stateid
, char *prefix
)
1284 char seqstr
[32] = {0};
1286 spec
= special_stateid(stateid
);
1289 sprintf(get_line(0, 0), "%sState ID hash = %04X",
1290 prefix
, stateid_hash(stateid
));
1292 sprintf(get_line(0, 0), "%sState ID hash = %s", prefix
,
1293 spec
== 0 ? "SPECIAL_0" :
1294 (spec
== 1 ? "SPECIAL_1" : "SPECIAL_?"));
1296 sprintf(get_line(0, 0), " len = %u val = %s",
1297 sizeof (stateid
->other
),
1298 tohex(stateid
->other
, sizeof (stateid
->other
)));
1301 * If spec 0/1 stateid, print seqid in hex; otherwise,
1302 * use decimal. This makes it more clear how spec stateids
1303 * are constructed [obvious that either all bits are 0, or all
1307 sprintf(seqstr
, "%d", stateid
->seqid
);
1309 sprintf(seqstr
, "%08X", stateid
->seqid
);
1311 sprintf(get_line(0, 0), " %sState ID Sequence ID = %s",
1317 sum_lock_denied(LOCK4denied
*denied
)
1319 static char buf
[64];
1321 sprintf(buf
, "%s %llu:%llu LO=%04X",
1322 sum_lock_type_name(denied
->locktype
),
1323 denied
->offset
, denied
->length
,
1324 owner_hash(&denied
->owner
.owner
));
1330 detail_lock_denied(LOCK4denied
*denied
)
1332 sprintf(get_line(0, 0), "Type = %s", lock_type_name(denied
->locktype
));
1333 detail_lock_owner(&denied
->owner
);
1334 sprintf(get_line(0, 0), "Offset = %llu", denied
->offset
);
1335 sprintf(get_line(0, 0), "Length = %llu", denied
->length
);
1339 * sum_createhow4: return the string name of "how".
1343 createhow4_name(createhow4
*crtp
)
1347 switch (crtp
->mode
) {
1349 result
= "UNCHECKED";
1355 result
= "EXCLUSIVE";
1366 * detail_createhow4: print detail information about "how".
1370 detail_createhow4(createhow4
*crtp
)
1372 sprintf(get_line(0, 0), "Method = %s",
1373 createhow4_name(crtp
));
1375 switch (crtp
->mode
) {
1378 detail_fattr4(&crtp
->createhow4_u
.createattrs
);
1381 sprintf(get_line(0, 0), " Verifier = %s",
1382 tohex(crtp
->createhow4_u
.createverf
,
1383 NFS4_VERIFIER_SIZE
));
1389 detail_createtype4(createtype4
*crtp
)
1391 sprintf(get_line(0, 0), "Type = %s",
1392 detail_type_name(crtp
->type
));
1393 switch (crtp
->type
) {
1395 sprintf(get_line(0, 0), "Linkdata = %s",
1396 utf8localize((utf8string
*)&crtp
->createtype4_u
.linkdata
));
1400 sprintf(get_line(0, 0), "Specdata1 = %04x Specdata2 = %04x",
1401 crtp
->createtype4_u
.devdata
.specdata1
,
1402 crtp
->createtype4_u
.devdata
.specdata2
);
1410 sumarg_access(char *buf
, size_t buflen
, void *obj
)
1412 ACCESS4args
*args
= (ACCESS4args
*)obj
;
1414 sum_access4(buf
, buflen
, args
->access
);
1418 dtlarg_access(void *obj
)
1420 ACCESS4args
*args
= (ACCESS4args
*)obj
;
1422 detail_access4("Access bits", args
->access
);
1426 sumarg_close(char *buf
, size_t buflen
, void *obj
)
1428 CLOSE4args
*args
= (CLOSE4args
*)obj
;
1430 snprintf(buf
, buflen
, "SQ=%u %s",
1431 args
->seqid
, sum_open_stateid(&args
->open_stateid
));
1435 dtlarg_close(void *obj
)
1437 CLOSE4args
*args
= (CLOSE4args
*)obj
;
1439 detail_open_stateid(&args
->open_stateid
);
1440 sprintf(get_line(0, 0), "Sequence ID = %u", args
->seqid
);
1444 sumarg_commit(char *buf
, size_t buflen
, void *obj
)
1446 COMMIT4args
*args
= (COMMIT4args
*)obj
;
1448 snprintf(buf
, buflen
, "at %llu for %u ", args
->offset
,
1453 dtlarg_commit(void *obj
)
1455 COMMIT4args
*args
= (COMMIT4args
*)obj
;
1457 sprintf(get_line(0, 0), "Offset = %llu", args
->offset
);
1458 sprintf(get_line(0, 0), "Count = %u", args
->count
);
1462 sumarg_compnt(char *buf
, size_t buflen
, void *obj
)
1464 component4
*comp
= (component4
*)obj
;
1466 snprintf(buf
, buflen
, "%s", component_name(comp
));
1470 dtlarg_compnt(void *obj
)
1472 component4
*comp
= (component4
*)obj
;
1474 sprintf(get_line(0, 0), "Name = %s", component_name(comp
));
1478 sumarg_create(char *buf
, size_t buflen
, void *obj
)
1480 CREATE4args
*args
= (CREATE4args
*)obj
;
1482 snprintf(buf
, buflen
, "%s %s ", component_name(&args
->objname
),
1483 sum_type_name(args
->objtype
.type
));
1487 dtlarg_create(void *obj
)
1489 CREATE4args
*args
= (CREATE4args
*)obj
;
1491 sprintf(get_line(0, 0), "Name = %s", component_name(&args
->objname
));
1492 detail_createtype4(&args
->objtype
);
1493 detail_fattr4(&args
->createattrs
);
1497 sumarg_delprge(char *buf
, size_t buflen
, void *obj
)
1499 DELEGPURGE4args
*args
= (DELEGPURGE4args
*)obj
;
1501 snprintf(buf
, buflen
, "%s", sum_clientid(args
->clientid
));
1505 dtlarg_delprge(void *obj
)
1507 DELEGPURGE4args
*args
= (DELEGPURGE4args
*)obj
;
1509 detail_clientid(args
->clientid
);
1513 sumarg_delret(char *buf
, size_t buflen
, void *obj
)
1515 DELEGRETURN4args
*args
= (DELEGRETURN4args
*)obj
;
1517 snprintf(buf
, buflen
, "%s", sum_deleg_stateid(&args
->deleg_stateid
));
1521 dtlarg_delret(void *obj
)
1523 DELEGRETURN4args
*args
= (DELEGRETURN4args
*)obj
;
1525 detail_deleg_stateid(&args
->deleg_stateid
);
1529 sumarg_getattr(char *buf
, size_t buflen
, void *obj
)
1531 GETATTR4args
*args
= (GETATTR4args
*)obj
;
1533 sum_attr_bitmap(buf
, buflen
, &args
->attr_request
);
1537 dtlarg_getattr(void *obj
)
1539 GETATTR4args
*args
= (GETATTR4args
*)obj
;
1541 detail_attr_bitmap("", &args
->attr_request
, NULL
);
1545 sumarg_cb_getattr(char *buf
, size_t buflen
, void *obj
)
1547 CB_GETATTR4args
*args
= (CB_GETATTR4args
*)obj
;
1550 snprintf(bp
, buflen
, "%s ", sum_fh4(&args
->fh
));
1552 sum_attr_bitmap(bp
, buflen
- (bp
- buf
), &args
->attr_request
);
1556 dtlarg_cb_getattr(void *obj
)
1558 CB_GETATTR4args
*args
= (CB_GETATTR4args
*)obj
;
1560 detail_fh4(&args
->fh
);
1561 detail_attr_bitmap("", &args
->attr_request
, NULL
);
1565 sumarg_cb_recall(char *buf
, size_t buflen
, void *obj
)
1567 CB_RECALL4args
*args
= (CB_RECALL4args
*)obj
;
1570 snprintf(bp
, buflen
, "%s %s TR=%s", sum_fh4(&args
->fh
),
1571 sum_stateid(&args
->stateid
), args
->truncate
? "T" : "F");
1575 dtlarg_cb_recall(void *obj
)
1577 CB_RECALL4args
*args
= (CB_RECALL4args
*)obj
;
1579 detail_fh4(&args
->fh
);
1580 detail_stateid(&args
->stateid
);
1581 sprintf(get_line(0, 0), "Truncate = %s",
1582 args
->truncate
? "True" : "False");
1587 * name openhow seqid claim access deny owner
1590 sumarg_open(char *buf
, size_t buflen
, void *obj
)
1592 OPEN4args
*args
= (OPEN4args
*)obj
;
1594 int blen
= buflen
, len
;
1596 sum_name(bp
, buflen
, &args
->claim
);
1597 bp
+= (len
= strlen(bp
));
1600 sum_openflag(bp
, blen
, &args
->openhow
);
1601 bp
+= (len
= strlen(bp
));
1604 snprintf(bp
, blen
, " SQ=%u", args
->seqid
);
1605 bp
+= (len
= strlen(bp
));
1608 sum_claim(bp
, blen
, &args
->claim
);
1609 bp
+= (len
= strlen(bp
));
1612 snprintf(bp
, blen
, " AC=%s DN=%s OO=%04X",
1613 sum_open_share_access(args
->share_access
),
1614 sum_open_share_deny(args
->share_deny
),
1615 owner_hash(&args
->owner
.owner
));
1619 dtlarg_open(void *obj
)
1621 OPEN4args
*args
= (OPEN4args
*)obj
;
1623 detail_claim(&args
->claim
);
1624 detail_openflag(&args
->openhow
);
1625 detail_open_owner(&args
->owner
);
1626 sprintf(get_line(0, 0), "Sequence ID = %u", args
->seqid
);
1627 sprintf(get_line(0, 0), "Access = 0x%x (%s)",
1628 args
->share_access
, sum_open_share_access(args
->share_access
));
1629 sprintf(get_line(0, 0), "Deny = 0x%x (%s)",
1630 args
->share_deny
, sum_open_share_access(args
->share_deny
));
1634 sumarg_openattr(char *buf
, size_t buflen
, void *obj
)
1636 OPENATTR4args
*args
= (OPENATTR4args
*)obj
;
1638 snprintf(buf
, buflen
, "CD=%s",
1639 args
->createdir
? "T" : "F");
1643 dtlarg_openattr(void *obj
)
1645 OPENATTR4args
*args
= (OPENATTR4args
*)obj
;
1647 sprintf(get_line(0, 0), "CreateDir = %s",
1648 args
->createdir
? "True" : "False");
1652 sumarg_open_confirm(char *buf
, size_t buflen
, void *obj
)
1655 OPEN_CONFIRM4args
*args
= (OPEN_CONFIRM4args
*)obj
;
1657 snprintf(bp
, buflen
, "SQ=%u %s", args
->seqid
,
1658 sum_open_stateid(&args
->open_stateid
));
1662 dtlarg_open_confirm(void *obj
)
1664 OPEN_CONFIRM4args
*args
= (OPEN_CONFIRM4args
*)obj
;
1666 sprintf(get_line(0, 0), "Sequence ID = %u", args
->seqid
);
1667 detail_open_stateid(&args
->open_stateid
);
1671 sumarg_open_downgrd(char *buf
, size_t buflen
, void *obj
)
1673 OPEN_DOWNGRADE4args
*args
= (OPEN_DOWNGRADE4args
*)obj
;
1675 snprintf(buf
, buflen
, "SQ=%u %s AC=%s DN=%s",
1676 args
->seqid
, sum_open_stateid(&args
->open_stateid
),
1677 sum_open_share_access(args
->share_access
),
1678 sum_open_share_deny(args
->share_deny
));
1682 dtlarg_open_downgrd(void *obj
)
1684 OPEN_DOWNGRADE4args
*args
= (OPEN_DOWNGRADE4args
*)obj
;
1686 sprintf(get_line(0, 0), "Open Sequence ID = %u", args
->seqid
);
1687 detail_open_stateid(&args
->open_stateid
);
1688 sprintf(get_line(0, 0), "Access = 0x%x (%s)",
1689 args
->share_access
, sum_open_share_access(args
->share_access
));
1690 sprintf(get_line(0, 0), "Deny = 0x%x (%s)",
1691 args
->share_deny
, sum_open_share_access(args
->share_deny
));
1695 sumarg_putfh(char *buf
, size_t buflen
, void *obj
)
1697 PUTFH4args
*args
= (PUTFH4args
*)obj
;
1699 snprintf(buf
, buflen
, "%s", sum_fh4(&args
->object
));
1703 dtlarg_putfh(void *obj
)
1705 PUTFH4args
*args
= (PUTFH4args
*)obj
;
1707 detail_fh4(&args
->object
);
1711 sumarg_link(char *buf
, size_t buflen
, void *obj
)
1713 LINK4args
*args
= (LINK4args
*)obj
;
1715 snprintf(buf
, buflen
, "%s", component_name(&args
->newname
));
1719 dtlarg_link(void *obj
)
1721 LINK4args
*args
= (LINK4args
*)obj
;
1723 sprintf(get_line(0, 0), "New name = %s",
1724 component_name(&args
->newname
));
1728 sum_open_to_lock_owner(char *buf
, int buflen
, open_to_lock_owner4
*own
)
1730 snprintf(buf
, buflen
, " OSQ=%u %s LSQ=%u LO=%04X", own
->open_seqid
,
1731 sum_open_stateid(&own
->open_stateid
), own
->lock_seqid
,
1732 owner_hash(&own
->lock_owner
.owner
));
1736 sum_exist_lock_owner(char *buf
, int buflen
, exist_lock_owner4
*own
)
1738 snprintf(buf
, buflen
, " LSQ=%u %s", own
->lock_seqid
,
1739 sum_lock_stateid(&own
->lock_stateid
));
1743 sum_locker(char *buf
, size_t len
, locker4
*lk
)
1745 if (lk
->new_lock_owner
== TRUE
)
1746 sum_open_to_lock_owner(buf
, len
, &lk
->locker4_u
.open_owner
);
1748 sum_exist_lock_owner(buf
, len
, &lk
->locker4_u
.lock_owner
);
1752 sum_lock_type_name(enum nfs_lock_type4 type
)
1778 sumarg_lock(char *buf
, size_t buflen
, void *obj
)
1780 LOCK4args
*args
= (LOCK4args
*)obj
;
1783 snprintf(buf
, buflen
, "%s%s%llu:%llu",
1784 sum_lock_type_name(args
->locktype
),
1785 args
->reclaim
? " reclaim " : " ",
1786 args
->offset
, args
->length
);
1789 sum_locker(bp
, buflen
- (bp
- buf
), &args
->locker
);
1793 detail_open_to_lock_owner(open_to_lock_owner4
*own
)
1795 sprintf(get_line(0, 0), "Open Sequence ID = %u", own
->open_seqid
);
1796 detail_open_stateid(&own
->open_stateid
);
1797 sprintf(get_line(0, 0), "Lock Sequence ID = %u", own
->lock_seqid
);
1798 detail_lock_owner(&own
->lock_owner
);
1802 detail_exist_lock_owner(exist_lock_owner4
*own
)
1804 detail_lock_stateid(&own
->lock_stateid
);
1805 sprintf(get_line(0, 0), "Lock Sequence ID = %u", own
->lock_seqid
);
1809 detail_locker(locker4
*lk
)
1811 if (lk
->new_lock_owner
== TRUE
)
1812 detail_open_to_lock_owner(&lk
->locker4_u
.open_owner
);
1814 detail_exist_lock_owner(&lk
->locker4_u
.lock_owner
);
1818 dtlarg_lock(void *obj
)
1820 LOCK4args
*args
= (LOCK4args
*)obj
;
1822 sprintf(get_line(0, 0), "Type = %s", lock_type_name(args
->locktype
));
1823 sprintf(get_line(0, 0), "Reclaim = %s",
1824 args
->reclaim
? "TRUE" : "FALSE");
1825 sprintf(get_line(0, 0), "Offset = %llu", args
->offset
);
1826 sprintf(get_line(0, 0), "Length = %llu", args
->length
);
1827 detail_locker(&args
->locker
);
1831 sumarg_lockt(char *buf
, size_t buflen
, void *obj
)
1833 LOCKT4args
*args
= (LOCKT4args
*)obj
;
1835 snprintf(buf
, buflen
, "%s %llu:%llu",
1836 sum_lock_type_name(args
->locktype
),
1837 args
->offset
, args
->length
);
1841 dtlarg_lockt(void *obj
)
1843 LOCKT4args
*args
= (LOCKT4args
*)obj
;
1845 sprintf(get_line(0, 0), "Type = %s", lock_type_name(args
->locktype
));
1846 detail_lock_owner(&args
->owner
);
1847 sprintf(get_line(0, 0), "Offset = %llu", args
->offset
);
1848 sprintf(get_line(0, 0), "Length = %llu", args
->length
);
1852 sumarg_locku(char *buf
, size_t buflen
, void *obj
)
1854 LOCKU4args
*args
= (LOCKU4args
*)obj
;
1856 snprintf(buf
, buflen
, "%llu:%llu LSQ=%u %s",
1857 args
->offset
, args
->length
, args
->seqid
,
1858 sum_lock_stateid(&args
->lock_stateid
));
1863 dtlarg_locku(void *obj
)
1865 LOCKU4args
*args
= (LOCKU4args
*)obj
;
1867 sprintf(get_line(0, 0), "Type = %s", lock_type_name(args
->locktype
));
1868 sprintf(get_line(0, 0), "Sequence ID = %u", args
->seqid
);
1869 detail_lock_stateid(&args
->lock_stateid
);
1870 sprintf(get_line(0, 0), "Offset = %llu", args
->offset
);
1871 sprintf(get_line(0, 0), "Length = %llu", args
->length
);
1875 sumarg_lookup(char *buf
, size_t buflen
, void *obj
)
1877 LOOKUP4args
*args
= (LOOKUP4args
*)obj
;
1879 sum_compname4(buf
, buflen
, &args
->objname
);
1883 dtlarg_lookup(void *obj
)
1885 LOOKUP4args
*args
= (LOOKUP4args
*)obj
;
1887 detail_compname4(&args
->objname
);
1891 sumarg_read(char *buf
, size_t buflen
, void *obj
)
1893 READ4args
*args
= (READ4args
*)obj
;
1895 snprintf(buf
, buflen
, "%s at %llu for %u",
1896 sum_stateid(&args
->stateid
), args
->offset
, args
->count
);
1900 dtlarg_read(void *obj
)
1902 READ4args
*args
= (READ4args
*)obj
;
1904 sprintf(get_line(0, 0), "Offset = %llu", args
->offset
);
1905 sprintf(get_line(0, 0), "Count = %u", args
->count
);
1906 detail_stateid(&args
->stateid
);
1910 sumarg_readdir(char *buf
, size_t buflen
, void *obj
)
1912 READDIR4args
*args
= (READDIR4args
*)obj
;
1914 snprintf(buf
, buflen
, "Cookie=%llu (%s) for %u/%u",
1915 args
->cookie
, tohex(args
->cookieverf
, NFS4_VERIFIER_SIZE
),
1916 args
->dircount
, args
->maxcount
);
1920 dtlarg_readdir(void *obj
)
1922 READDIR4args
*args
= (READDIR4args
*)obj
;
1924 sprintf(get_line(0, 0), "Cookie = %llu", args
->cookie
);
1925 sprintf(get_line(0, 0), "Verifier = %s",
1926 tohex(args
->cookieverf
, NFS4_VERIFIER_SIZE
));
1927 sprintf(get_line(0, 0), "Dircount = %u", args
->dircount
);
1928 sprintf(get_line(0, 0), "Maxcount = %u", args
->maxcount
);
1929 detail_attr_bitmap("", &args
->attr_request
, NULL
);
1933 dtlarg_release_lkown(void *obj
)
1935 RELEASE_LOCKOWNER4args
*args
= (RELEASE_LOCKOWNER4args
*)obj
;
1937 detail_lock_owner(&args
->lock_owner
);
1941 sumarg_release_lkown(char *buf
, size_t buflen
, void *obj
)
1943 RELEASE_LOCKOWNER4args
*args
= (RELEASE_LOCKOWNER4args
*)obj
;
1945 snprintf(buf
, buflen
, "LO=%04X", owner_hash(&args
->lock_owner
.owner
));
1949 sumarg_rename(char *buf
, size_t buflen
, void *obj
)
1951 RENAME4args
*args
= (RENAME4args
*)obj
;
1953 snprintf(buf
, buflen
, "%s to %s",
1954 component_name(&args
->oldname
),
1955 component_name(&args
->newname
));
1959 dtlarg_rename(void *obj
)
1961 RENAME4args
*args
= (RENAME4args
*)obj
;
1963 sprintf(get_line(0, 0), "Old name = %s",
1964 component_name(&args
->oldname
));
1965 sprintf(get_line(0, 0), "New name = %s",
1966 component_name(&args
->newname
));
1970 sumarg_renew(char *buf
, size_t buflen
, void *obj
)
1972 RENEW4args
*args
= (RENEW4args
*)obj
;
1974 snprintf(buf
, buflen
, "%s", sum_clientid(args
->clientid
));
1977 dtlarg_renew(void *obj
)
1979 RENEW4args
*args
= (RENEW4args
*)obj
;
1981 detail_clientid(args
->clientid
);
1985 sumarg_secinfo(char *buf
, size_t buflen
, void *obj
)
1987 SECINFO4args
*args
= (SECINFO4args
*)obj
;
1989 snprintf(buf
, buflen
, "%s",
1990 component_name(&args
->name
));
1994 dtlarg_secinfo(void *obj
)
1996 SECINFO4args
*args
= (SECINFO4args
*)obj
;
1998 sprintf(get_line(0, 0), "Name = %s",
1999 component_name(&args
->name
));
2003 sumarg_setattr(char *buf
, size_t buflen
, void *obj
)
2005 SETATTR4args
*args
= (SETATTR4args
*)obj
;
2007 snprintf(buf
, buflen
, "%s", sum_stateid(&args
->stateid
));
2011 dtlarg_setattr(void *obj
)
2013 SETATTR4args
*args
= (SETATTR4args
*)obj
;
2015 detail_stateid(&args
->stateid
);
2016 detail_fattr4(&args
->obj_attributes
);
2020 sumarg_setclid(char *buf
, size_t buflen
, void *obj
)
2022 SETCLIENTID4args
*args
= (SETCLIENTID4args
*)obj
;
2024 snprintf(buf
, buflen
, "Prog=%u ID=%s Addr=%s CBID=%u",
2025 args
->callback
.cb_program
,
2026 args
->callback
.cb_location
.r_netid
,
2027 args
->callback
.cb_location
.r_addr
, args
->callback_ident
);
2031 dtlarg_setclid(void *obj
)
2033 SETCLIENTID4args
*args
= (SETCLIENTID4args
*)obj
;
2035 sprintf(get_line(0, 0), "Verifier=%s",
2036 tohex(args
->client
.verifier
, NFS4_VERIFIER_SIZE
));
2037 sprintf(get_line(0, 0), "ID = (%d) %s",
2038 args
->client
.id
.id_len
,
2039 tohex(args
->client
.id
.id_val
, args
->client
.id
.id_len
));
2041 sprintf(get_line(0, 0), "Callback Program = %u",
2042 args
->callback
.cb_program
);
2043 sprintf(get_line(0, 0), "Callback Net ID = %s",
2044 args
->callback
.cb_location
.r_netid
);
2045 sprintf(get_line(0, 0), "Callback Addr = %s",
2046 args
->callback
.cb_location
.r_addr
);
2047 sprintf(get_line(0, 0), "Callback Ident = %u", args
->callback_ident
);
2051 sumarg_setclid_cfm(char *buf
, size_t buflen
, void *obj
)
2053 SETCLIENTID_CONFIRM4args
*args
= (SETCLIENTID_CONFIRM4args
*)obj
;
2055 snprintf(buf
, buflen
, "%s CFV=%s", sum_clientid(args
->clientid
),
2056 tohex(args
->setclientid_confirm
, NFS4_VERIFIER_SIZE
));
2060 dtlarg_setclid_cfm(void *obj
)
2062 SETCLIENTID_CONFIRM4args
*args
= (SETCLIENTID_CONFIRM4args
*)obj
;
2064 detail_clientid(args
->clientid
);
2065 sprintf(get_line(0, 0), "Set Client ID Confirm Verifier = %s",
2066 tohex(args
->setclientid_confirm
, NFS4_VERIFIER_SIZE
));
2071 dtlarg_verify(void *obj
)
2073 NVERIFY4args
*args
= (NVERIFY4args
*)obj
;
2075 detail_fattr4(&args
->obj_attributes
);
2079 sumarg_write(char *buf
, size_t buflen
, void *obj
)
2081 WRITE4args
*args
= (WRITE4args
*)obj
;
2083 snprintf(buf
, buflen
, "%s at %llu for %u",
2084 sum_stateid(&args
->stateid
), args
->offset
, args
->data
.data_len
);
2088 dtlarg_write(void *obj
)
2090 WRITE4args
*args
= (WRITE4args
*)obj
;
2092 sprintf(get_line(0, 0), "Offset = %llu", args
->offset
);
2093 sprintf(get_line(0, 0), "Count = %u", args
->data
.data_len
);
2094 sprintf(get_line(0, 0), "Stable = %s", stable_how4_name(args
->stable
));
2095 detail_stateid(&args
->stateid
);
2099 sum_fh4(nfs_fh4
*fh
)
2101 static char buf
[20];
2103 sprintf(buf
, "FH=%04X", fh4_hash(fh
));
2109 detail_fh4(nfs_fh4
*fh
)
2115 sprintf(get_line(0, 0), "File handle = [%04X]", fh4_hash(fh
));
2116 bufp
= get_line(0, 0);
2117 sprintf(bufp
, "(%d) ", fh
->nfs_fh4_len
);
2118 bufp
+= strlen(bufp
);
2119 /* XXX use tohex()? */
2120 for (i
= 0, cp
= (uchar_t
*)fh
->nfs_fh4_val
;
2121 i
< fh
->nfs_fh4_len
;
2123 if (i
!= 0 && i
% 32 == 0)
2124 bufp
= get_line(0, 0);
2125 sprintf(bufp
, "%02x", *cp
);
2126 bufp
+= strlen(bufp
);
2131 detail_fattr4(fattr4
*attrp
)
2133 unpkd_attrmap_t provided
;
2138 xdrmem_create(&attrxdr
, attrp
->attr_vals
.attrlist4_val
,
2139 attrp
->attr_vals
.attrlist4_len
, XDR_DECODE
);
2141 bcopy(xdr_err
, old_errbuf
, sizeof (old_errbuf
));
2142 if (setjmp(xdr_err
)) {
2143 sprintf(get_line(0, 0), "<attr_vals too short>");
2147 detail_attr_bitmap("", &attrp
->attrmask
, &provided
);
2148 for (attrnum
= 0; attrnum
< MAX_ATTRIBUTES
; attrnum
++) {
2149 if (provided
.map
[attrnum
]) {
2150 attr_info
[attrnum
].prt_details(&attrxdr
);
2155 bcopy(old_errbuf
, xdr_err
, sizeof (old_errbuf
));
2159 sum_attr_bitmap(char *buf
, size_t buflen
, bitmap4
*mapp
)
2163 size_t curlen
, remaining
;
2166 for (num_words
= 0; num_words
< mapp
->bitmap4_len
; num_words
++) {
2167 curlen
= strlen(buf
);
2168 if (curlen
+ sizeof ("<Too Long>") >= buflen
) {
2169 strcpy(buf
+ buflen
- sizeof ("<Too Long>"),
2174 remaining
= buflen
- curlen
;
2175 snprintf(bp
, remaining
,
2176 num_words
== 0 ? "%x" : " %x",
2177 mapp
->bitmap4_val
[num_words
]);
2182 * Print detail information for the given attribute bitmap, and fill in the
2183 * unpacked version of the map if "unpacked" is non-null. Returns the
2184 * number of bytes in the bitmap. "prefix" is an initial string that is
2185 * printed at the front of each line.
2189 detail_attr_bitmap(char *prefix
, bitmap4
*bitp
, unpkd_attrmap_t
*unpacked
)
2195 if (unpacked
!= NULL
)
2196 memset(unpacked
, 0, sizeof (unpkd_attrmap_t
));
2199 * Break the bitmap into octets, then print in hex and
2203 for (num_words
= 0, wp
= bitp
->bitmap4_val
;
2204 num_words
< bitp
->bitmap4_len
;
2205 num_words
++, wp
++) {
2206 for (byte_num
= 0; byte_num
< 4; byte_num
++) {
2207 uchar_t val
= (*wp
) >> (byte_num
* 8);
2208 char *buf
= get_line(0, 0);
2212 sprintf(buf
, "%s 0x%02x ", prefix
, val
);
2213 attrnum
= num_words
* 32 + byte_num
* 8;
2214 for (bit
= 7; bit
>= 0; bit
--) {
2215 if (val
& (1 << bit
)) {
2218 attr_name(attrnum
+ bit
));
2219 if (unpacked
!= NULL
)
2220 unpacked
->map
[attrnum
+ bit
] =
2229 * Format the summary line results from a COMPOUND4 call.
2233 sum_comp4res(char *line
, char *(*sumres_fn
)(void))
2236 static utf8string tag
;
2238 status
= getxdr_long();
2239 if (!xdr_utf8string(&xdrm
, &tag
))
2240 longjmp(xdr_err
, 1);
2242 sprintf(line
, "(%.20s) %s %s", utf8localize(&tag
),
2243 status_name(status
), sumres_fn());
2245 xdr_free(xdr_utf8string
, (char *)&tag
);
2250 * Return a set of summary strings for the result data that's next in the
2251 * XDR stream, up to SUM_COMPND_MAX characters. If the strings don't fit,
2252 * include a "..." at the end of the string.
2256 sum_compound4res(void)
2258 static char buf
[SUM_COMPND_MAX
+ 2]; /* 1 for null, 1 for overflow */
2260 const size_t buflen
= sizeof (buf
);
2265 if (setjmp(xdr_err
)) {
2266 bp
= buf
+ strlen(buf
);
2267 snprintf(bp
, buflen
- (bp
- buf
),
2268 nfs4_fragged_rpc
? nfs4err_fragrpc
: nfs4err_xdrfrag
);
2272 numres
= getxdr_long();
2274 while (numres
-- > 0) {
2277 bzero(&one_res
, sizeof (one_res
));
2279 if (!xdr_nfs_resop4(&xdrm
, &one_res
)) {
2280 xdr_free(xdr_nfs_resop4
, (char *)&one_res
);
2281 longjmp(xdr_err
, 1);
2284 snprintf(bp
, buflen
- (bp
- buf
), "%s ",
2285 opcode_name(one_res
.resop
));
2288 result
= sum_result(&one_res
);
2289 if (strlen(result
) > 0) {
2290 snprintf(bp
, buflen
- (bp
- buf
), "%s ", result
);
2294 /* nfs4_skip_bytes set by xdr_nfs4_argop4() */
2295 if (nfs4_skip_bytes
!= 0)
2296 nfs4_xdr_skip(nfs4_skip_bytes
);
2298 xdr_free(xdr_nfs_resop4
, (char *)&one_res
);
2299 /* add "..." if past the "end" of the buffer */
2300 if (bp
- buf
> SUM_COMPND_MAX
) {
2301 strcpy(buf
+ SUM_COMPND_MAX
- strlen("..."),
2312 * Return a set of summary strings for the result data that's next in the
2313 * XDR stream, up to SUM_COMPND_MAX characters. If the strings don't fit,
2314 * include a "..." at the end of the string.
2318 sum_cb_compound4res(void)
2320 static char buf
[SUM_COMPND_MAX
+ 2]; /* 1 for null, 1 for overflow */
2322 const size_t buflen
= sizeof (buf
);
2324 nfs_cb_resop4 one_res
;
2327 if (setjmp(xdr_err
)) {
2328 bp
= buf
+ strlen(buf
);
2329 snprintf(bp
, buflen
- (bp
- buf
), "<XDR Error or Fragmented"
2334 numres
= getxdr_long();
2336 while (numres
-- > 0) {
2337 bzero(&one_res
, sizeof (one_res
));
2338 if (!xdr_nfs_cb_resop4(&xdrm
, &one_res
)) {
2339 xdr_free(xdr_nfs_cb_resop4
, (char *)&one_res
);
2340 longjmp(xdr_err
, 1);
2342 snprintf(bp
, buflen
- (bp
- buf
), "%s %s ",
2343 cb_opcode_name(one_res
.resop
),
2344 sum_cb_result(&one_res
));
2347 xdr_free(xdr_nfs_cb_resop4
, (char *)&one_res
);
2349 /* add "..." if past the "end" of the buffer */
2350 if (bp
- buf
> SUM_COMPND_MAX
) {
2351 strcpy(buf
+ SUM_COMPND_MAX
- strlen("..."),
2362 * Return the summarized results for the given resultdata.
2366 sum_result(nfs_resop4
*resp
)
2368 static char buf
[1024];
2369 void (*fmtproc
)(char *, size_t, void *);
2372 if (resp
->resop
< num_opcodes
)
2373 fmtproc
= opcode_info
[resp
->resop
].sumres
;
2374 else if (resp
->resop
== OP_ILLEGAL
)
2375 fmtproc
= sum_nfsstat4
;
2379 if (fmtproc
!= NULL
)
2380 fmtproc(buf
, sizeof (buf
), &resp
->nfs_resop4_u
);
2386 * Return the summarized results for the given resultdata.
2390 sum_cb_result(nfs_cb_resop4
*resp
)
2392 static char buf
[1024];
2393 void (*fmtproc
)(char *, size_t, void *);
2396 if (resp
->resop
< cb_num_opcodes
)
2397 fmtproc
= cb_opcode_info
[resp
->resop
].sumres
;
2398 else if (resp
->resop
== OP_CB_ILLEGAL
)
2399 fmtproc
= sum_nfsstat4
;
2403 if (fmtproc
!= NULL
)
2404 fmtproc(buf
, sizeof (buf
), &resp
->nfs_cb_resop4_u
);
2411 dtl_change_info(char *msg
, change_info4
*infop
)
2413 sprintf(get_line(0, 0), "%s:", msg
);
2414 sprintf(get_line(0, 0), " Atomic = %s",
2415 infop
->atomic
? "TRUE" : "FALSE");
2416 detail_fattr4_change(" Before", infop
->before
);
2417 detail_fattr4_change(" After", infop
->after
);
2421 detail_fattr4_change(char *msg
, fattr4_change chg
)
2423 sprintf(get_line(0, 0), "%s: 0x%llx", msg
, chg
);
2424 /* XXX print as time_t, too? */
2428 sum_nfsstat4(char *buf
, size_t buflen
, void *obj
)
2430 nfsstat4 status
= *(nfsstat4
*)obj
;
2432 strncpy(buf
, status_name(status
), buflen
);
2436 dtl_nfsstat4(void *obj
)
2438 nfsstat4 status
= *(nfsstat4
*)obj
;
2440 sprintf(get_line(0, 0), "Status = %d (%s)", status
,
2441 status_name(status
));
2445 sumres_access(char *buf
, size_t buflen
, void *obj
)
2447 ACCESS4res
*res
= (ACCESS4res
*)obj
;
2449 int len
, blen
= buflen
;
2451 strcpy(bp
, status_name(res
->status
));
2452 if (res
->status
== NFS4_OK
) {
2453 bp
+= (len
= strlen(bp
));
2456 snprintf(bp
, blen
, " Supp=");
2457 bp
+= (len
= strlen(bp
));
2460 sum_access4(bp
, blen
, res
->ACCESS4res_u
.resok4
.supported
);
2461 bp
+= (len
= strlen(bp
));
2464 snprintf(bp
, blen
, " Allow=");
2465 bp
+= (len
= strlen(bp
));
2468 sum_access4(bp
, blen
, res
->ACCESS4res_u
.resok4
.access
);
2473 dtlres_access(void *obj
)
2475 ACCESS4res
*res
= (ACCESS4res
*)obj
;
2478 if (res
->status
== NFS4_OK
) {
2479 detail_access4("Supported Attributes",
2480 res
->ACCESS4res_u
.resok4
.supported
);
2481 detail_access4("Allowed Attributes",
2482 res
->ACCESS4res_u
.resok4
.access
);
2487 sumres_close(char *buf
, size_t buflen
, void *obj
)
2489 CLOSE4res
*res
= (CLOSE4res
*)obj
;
2491 if (res
->status
== NFS4_OK
)
2492 snprintf(buf
, buflen
, "%s",
2493 sum_open_stateid(&res
->CLOSE4res_u
.open_stateid
));
2497 dtlres_close(void *obj
)
2499 CLOSE4res
*res
= (CLOSE4res
*)obj
;
2502 if (res
->status
== NFS4_OK
) {
2503 detail_open_stateid(&res
->CLOSE4res_u
.open_stateid
);
2508 sumres_commit(char *buf
, size_t buflen
, void *obj
)
2510 COMMIT4res
*res
= (COMMIT4res
*)obj
;
2512 if (res
->status
== NFS4_OK
)
2513 snprintf(buf
, buflen
, "Verf=%s",
2514 tohex(res
->COMMIT4res_u
.resok4
.writeverf
,
2515 NFS4_VERIFIER_SIZE
));
2519 dtlres_commit(void *obj
)
2521 COMMIT4res
*res
= (COMMIT4res
*)obj
;
2524 if (res
->status
== NFS4_OK
) {
2525 sprintf(get_line(0, 0), "Verifier = %s",
2526 tohex(res
->COMMIT4res_u
.resok4
.writeverf
,
2527 NFS4_VERIFIER_SIZE
));
2532 dtlres_create(void *obj
)
2534 CREATE4res
*res
= (CREATE4res
*)obj
;
2537 if (res
->status
== NFS4_OK
) {
2538 dtl_change_info("Change Information",
2539 &res
->CREATE4res_u
.resok4
.cinfo
);
2540 detail_attr_bitmap("", &res
->CREATE4res_u
.resok4
.attrset
,
2546 sumres_getattr(char *buf
, size_t buflen
, void *obj
)
2548 GETATTR4res
*res
= (GETATTR4res
*)obj
;
2550 strncpy(buf
, status_name(res
->status
), buflen
);
2554 dtlres_getattr(void *obj
)
2556 GETATTR4res
*res
= (GETATTR4res
*)obj
;
2559 if (res
->status
== NFS4_OK
) {
2560 detail_fattr4(&res
->GETATTR4res_u
.resok4
.obj_attributes
);
2565 sumres_cb_getattr(char *buf
, size_t buflen
, void *obj
)
2567 CB_GETATTR4res
*res
= (CB_GETATTR4res
*)obj
;
2569 strncpy(buf
, status_name(res
->status
), buflen
);
2573 dtlres_cb_getattr(void *obj
)
2575 CB_GETATTR4res
*res
= (CB_GETATTR4res
*)obj
;
2578 if (res
->status
== NFS4_OK
) {
2579 detail_fattr4(&res
->CB_GETATTR4res_u
.resok4
.obj_attributes
);
2585 sumres_getfh(char *buf
, size_t buflen
, void *obj
)
2588 GETFH4res
*res
= (GETFH4res
*)obj
;
2590 strncpy(buf
, status_name(res
->status
), buflen
);
2591 if (res
->status
== NFS4_OK
) {
2592 bp
= buf
+ strlen(buf
);
2593 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2594 sum_fh4(&res
->GETFH4res_u
.resok4
.object
));
2599 dtlres_getfh(void *obj
)
2601 GETFH4res
*res
= (GETFH4res
*)obj
;
2604 if (res
->status
== NFS4_OK
) {
2605 detail_fh4(&res
->GETFH4res_u
.resok4
.object
);
2610 dtlres_link(void *obj
)
2612 LINK4res
*res
= (LINK4res
*)obj
;
2615 if (res
->status
== NFS4_OK
) {
2616 dtl_change_info("Change Information",
2617 &res
->LINK4res_u
.resok4
.cinfo
);
2622 sumres_lock(char *buf
, size_t buflen
, void *obj
)
2625 LOCK4res
*res
= (LOCK4res
*)obj
;
2627 strncpy(buf
, status_name(res
->status
), buflen
);
2628 if (res
->status
== NFS4_OK
) {
2629 bp
= buf
+ strlen(buf
);
2630 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2631 sum_lock_stateid(&res
->LOCK4res_u
.resok4
.lock_stateid
));
2633 if (res
->status
== NFS4ERR_DENIED
) {
2634 bp
= buf
+ strlen(buf
);
2635 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2636 sum_lock_denied(&res
->LOCK4res_u
.denied
));
2641 dtlres_lock(void *obj
)
2643 LOCK4res
*res
= (LOCK4res
*)obj
;
2646 if (res
->status
== NFS4_OK
) {
2647 detail_lock_stateid(&res
->LOCK4res_u
.resok4
.lock_stateid
);
2649 if (res
->status
== NFS4ERR_DENIED
) {
2650 detail_lock_denied(&res
->LOCK4res_u
.denied
);
2655 sumres_lockt(char *buf
, size_t buflen
, void *obj
)
2658 LOCKT4res
*res
= (LOCKT4res
*)obj
;
2660 strcpy(buf
, status_name(res
->status
));
2661 if (res
->status
== NFS4ERR_DENIED
) {
2662 bp
= buf
+ strlen(buf
);
2663 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2664 sum_lock_denied(&res
->LOCKT4res_u
.denied
));
2669 dtlres_lockt(void *obj
)
2671 LOCKT4res
*res
= (LOCKT4res
*)obj
;
2674 if (res
->status
== NFS4ERR_DENIED
) {
2675 detail_lock_denied(&res
->LOCKT4res_u
.denied
);
2680 sumres_locku(char *buf
, size_t buflen
, void *obj
)
2683 LOCKU4res
*res
= (LOCKU4res
*)obj
;
2685 strncpy(buf
, status_name(res
->status
), buflen
);
2686 bp
= buf
+ strlen(buf
);
2687 if (res
->status
== NFS4_OK
)
2688 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2689 sum_lock_stateid(&res
->LOCKU4res_u
.lock_stateid
));
2693 dtlres_locku(void *obj
)
2695 LOCKU4res
*res
= (LOCKU4res
*)obj
;
2698 if (res
->status
== NFS4_OK
)
2699 detail_lock_stateid(&res
->LOCKU4res_u
.lock_stateid
);
2703 sumres_open(char *buf
, size_t buflen
, void *obj
)
2706 OPEN4res
*res
= (OPEN4res
*)obj
;
2708 int len
, blen
= buflen
;
2710 strncpy(bp
, status_name(res
->status
), blen
);
2712 if (res
->status
== NFS4_OK
) {
2713 bp
+= (len
= strlen(bp
));
2716 snprintf(bp
, blen
, " %s",
2717 sum_stateid(&res
->OPEN4res_u
.resok4
.stateid
));
2718 bp
+= (len
= strlen(bp
));
2721 if ((rflags
= res
->OPEN4res_u
.resok4
.rflags
) != 0) {
2722 snprintf(bp
, blen
, "%s", sum_open_rflags(rflags
));
2723 bp
+= (len
= strlen(bp
));
2727 sum_delegation(bp
, blen
, &res
->OPEN4res_u
.resok4
.delegation
);
2732 dtlres_open(void *obj
)
2734 OPEN4res
*res
= (OPEN4res
*)obj
;
2737 if (res
->status
== NFS4_OK
) {
2738 detail_stateid(&res
->OPEN4res_u
.resok4
.stateid
);
2739 dtl_change_info("Change Information",
2740 &res
->OPEN4res_u
.resok4
.cinfo
);
2741 sprintf(get_line(0, 0), "Flags = 0x%x (%s)",
2742 res
->OPEN4res_u
.resok4
.rflags
,
2743 detail_open_rflags(res
->OPEN4res_u
.resok4
.rflags
));
2744 detail_attr_bitmap("", &res
->OPEN4res_u
.resok4
.attrset
,
2746 detail_delegation(&res
->OPEN4res_u
.resok4
.delegation
);
2751 sumres_open_confirm(char *buf
, size_t buflen
, void *obj
)
2754 OPEN_CONFIRM4res
*res
= (OPEN_CONFIRM4res
*)obj
;
2756 strncpy(buf
, status_name(res
->status
), buflen
);
2757 if (res
->status
== NFS4_OK
) {
2758 bp
= buf
+ strlen(buf
);
2759 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2760 sum_open_stateid(&res
->OPEN_CONFIRM4res_u
.resok4
.
2766 dtlres_open_confirm(void *obj
)
2768 OPEN_CONFIRM4res
*res
= (OPEN_CONFIRM4res
*)obj
;
2771 if (res
->status
== NFS4_OK
) {
2772 detail_open_stateid(&res
->OPEN_CONFIRM4res_u
.resok4
.
2778 sumres_open_downgrd(char *buf
, size_t buflen
, void *obj
)
2781 OPEN_DOWNGRADE4res
*res
= (OPEN_DOWNGRADE4res
*)obj
;
2783 strncpy(buf
, status_name(res
->status
), buflen
);
2784 if (res
->status
== NFS4_OK
) {
2785 bp
= buf
+ strlen(buf
);
2786 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2787 sum_open_stateid(&res
->OPEN_DOWNGRADE4res_u
.resok4
.
2793 dtlres_open_downgrd(void *obj
)
2795 OPEN_DOWNGRADE4res
*res
= (OPEN_DOWNGRADE4res
*)obj
;
2798 if (res
->status
== NFS4_OK
) {
2799 detail_open_stateid(&res
->OPEN_DOWNGRADE4res_u
.resok4
.
2805 sumres_read(char *buf
, size_t buflen
, void *obj
)
2808 READ4res
*res
= (READ4res
*)obj
;
2810 strncpy(buf
, status_name(res
->status
), buflen
);
2811 if (res
->status
== NFS4_OK
) {
2812 bp
= buf
+ strlen(buf
);
2813 snprintf(bp
, buflen
- (bp
- buf
), " (%u bytes) %s",
2814 res
->READ4res_u
.resok4
.data
.data_len
,
2815 res
->READ4res_u
.resok4
.eof
? "EOF" : "");
2820 dtlres_read(void *obj
)
2822 READ4res
*res
= (READ4res
*)obj
;
2825 if (res
->status
== NFS4_OK
) {
2826 sprintf(get_line(0, 0), "Count = %u bytes read",
2827 res
->READ4res_u
.resok4
.data
.data_len
);
2828 sprintf(get_line(0, 0), "End of file = %s",
2829 res
->READ4res_u
.resok4
.eof
? "TRUE" : "FALSE");
2834 sumres_readdir(char *buf
, size_t buflen
, void *obj
)
2837 READDIR4res
*res
= (READDIR4res
*)obj
;
2838 int num_entries
= 0;
2841 strncpy(buf
, status_name(res
->status
), buflen
);
2842 if (res
->status
== NFS4_OK
) {
2843 for (ep
= res
->READDIR4res_u
.resok4
.reply
.entries
;
2847 bp
= buf
+ strlen(buf
);
2848 snprintf(bp
, buflen
- (bp
- buf
), " %d entries (%s)",
2850 res
->READDIR4res_u
.resok4
.reply
.eof
2851 ? "No more" : "More");
2856 dtlres_readdir(void *obj
)
2858 READDIR4res
*res
= (READDIR4res
*)obj
;
2859 int num_entries
= 0;
2863 if (res
->status
== NFS4_OK
) {
2864 for (ep
= res
->READDIR4res_u
.resok4
.reply
.entries
;
2866 ep
= ep
->nextentry
) {
2868 sprintf(get_line(0, 0),
2869 "------------------ entry #%d",
2871 sprintf(get_line(0, 0), "Cookie = %llu",
2873 sprintf(get_line(0, 0), "Name = %s",
2874 component_name(&ep
->name
));
2875 detail_fattr4(&ep
->attrs
);
2877 if (num_entries
== 0)
2878 sprintf(get_line(0, 0), "(No entries)");
2879 sprintf(get_line(0, 0), "EOF = %s",
2880 res
->READDIR4res_u
.resok4
.reply
.eof
? "TRUE" : "FALSE");
2881 sprintf(get_line(0, 0), "Verifer = %s",
2882 tohex(res
->READDIR4res_u
.resok4
.cookieverf
,
2883 NFS4_VERIFIER_SIZE
));
2888 sumres_readlnk(char *buf
, size_t buflen
, void *obj
)
2891 READLINK4res
*res
= (READLINK4res
*)obj
;
2893 strncpy(buf
, status_name(res
->status
), buflen
);
2894 if (res
->status
== NFS4_OK
) {
2895 bp
= buf
+ strlen(buf
);
2896 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2897 linktext_name(&res
->READLINK4res_u
.resok4
.link
));
2902 dtlres_readlnk(void *obj
)
2904 READLINK4res
*res
= (READLINK4res
*)obj
;
2907 if (res
->status
== NFS4_OK
) {
2908 sprintf(get_line(0, 0), "Link = %s",
2909 linktext_name(&res
->READLINK4res_u
.resok4
.link
));
2914 dtlres_remove(void *obj
)
2916 REMOVE4res
*res
= (REMOVE4res
*)obj
;
2919 if (res
->status
== NFS4_OK
) {
2920 dtl_change_info("Change Information",
2921 &res
->REMOVE4res_u
.resok4
.cinfo
);
2926 dtlres_rename(void *obj
)
2928 RENAME4res
*res
= (RENAME4res
*)obj
;
2931 if (res
->status
== NFS4_OK
) {
2932 dtl_change_info("Source Change Information",
2933 &res
->RENAME4res_u
.resok4
.source_cinfo
);
2934 dtl_change_info("Target Change Information",
2935 &res
->RENAME4res_u
.resok4
.target_cinfo
);
2940 sumres_secinfo(char *buf
, size_t buflen
, void *obj
)
2943 SECINFO4res
*res
= (SECINFO4res
*)obj
;
2945 strncpy(buf
, status_name(res
->status
), buflen
);
2946 bp
= buf
+ strlen(buf
);
2947 if (res
->status
== NFS4_OK
) {
2948 uint_t numinfo
= res
->SECINFO4res_u
.resok4
.SECINFO4resok_len
;
2951 for (infop
= res
->SECINFO4res_u
.resok4
.SECINFO4resok_val
;
2953 infop
++, numinfo
--) {
2954 snprintf(bp
, buflen
- (bp
- buf
), " %s",
2955 flavor_name(infop
->flavor
));
2962 dtlres_secinfo(void *obj
)
2964 SECINFO4res
*res
= (SECINFO4res
*)obj
;
2967 if (res
->status
== NFS4_OK
) {
2969 res
->SECINFO4res_u
.resok4
.SECINFO4resok_len
;
2972 for (infop
= res
->SECINFO4res_u
.resok4
.SECINFO4resok_val
;
2974 infop
++, numinfo
--) {
2975 detail_secinfo4(infop
);
2981 sumres_setattr(char *buf
, size_t buflen
, void *obj
)
2983 SETATTR4res
*res
= (SETATTR4res
*)obj
;
2986 (void) snprintf(buf
, buflen
, "%s ", status_name(res
->status
));
2988 sum_attr_bitmap(buf
+ len
, buflen
- len
, &res
->attrsset
);
2992 dtlres_setattr(void *obj
)
2994 SETATTR4res
*res
= (SETATTR4res
*)obj
;
2997 detail_attr_bitmap("", &res
->attrsset
, NULL
);
3001 sumres_setclid(char *buf
, size_t buflen
, void *obj
)
3004 SETCLIENTID4res
*res
= (SETCLIENTID4res
*)obj
;
3006 strncpy(buf
, status_name(res
->status
), buflen
);
3007 switch (res
->status
) {
3009 bp
= buf
+ strlen(buf
);
3010 snprintf(bp
, buflen
- (bp
- buf
), " %s CFV=%s",
3011 sum_clientid(res
->SETCLIENTID4res_u
.resok4
.clientid
),
3012 tohex(res
->SETCLIENTID4res_u
.resok4
.setclientid_confirm
,
3013 NFS4_VERIFIER_SIZE
));
3015 case NFS4ERR_CLID_INUSE
:
3016 bp
= buf
+ strlen(buf
);
3017 snprintf(bp
, buflen
- (bp
- buf
), " ID=%s Addr=%s",
3018 res
->SETCLIENTID4res_u
.client_using
.r_netid
,
3019 res
->SETCLIENTID4res_u
.client_using
.r_addr
);
3025 dtlres_setclid(void *obj
)
3027 SETCLIENTID4res
*res
= (SETCLIENTID4res
*)obj
;
3030 switch (res
->status
) {
3032 detail_clientid(res
->SETCLIENTID4res_u
.resok4
.clientid
);
3033 sprintf(get_line(0, 0), "Set Client ID Confirm Verifier = %s",
3034 tohex(res
->SETCLIENTID4res_u
.resok4
.setclientid_confirm
,
3035 NFS4_VERIFIER_SIZE
));
3037 case NFS4ERR_CLID_INUSE
:
3038 sprintf(get_line(0, 0), "Used by Net ID = %s",
3039 res
->SETCLIENTID4res_u
.client_using
.r_netid
);
3040 sprintf(get_line(0, 0), "Used by Addr = %s",
3041 res
->SETCLIENTID4res_u
.client_using
.r_addr
);
3047 sumres_write(char *buf
, size_t buflen
, void *obj
)
3050 WRITE4res
*res
= (WRITE4res
*)obj
;
3052 strncpy(buf
, status_name(res
->status
), buflen
);
3053 if (res
->status
== NFS4_OK
) {
3054 bp
= buf
+ strlen(buf
);
3055 snprintf(bp
, buflen
- (bp
- buf
), " %u (%s)",
3056 res
->WRITE4res_u
.resok4
.count
,
3057 stable_how4_name(res
->WRITE4res_u
.resok4
.committed
));
3062 dtlres_write(void *obj
)
3064 WRITE4res
*res
= (WRITE4res
*)obj
;
3067 if (res
->status
== NFS4_OK
) {
3068 sprintf(get_line(0, 0), "Count = %u bytes written",
3069 res
->WRITE4res_u
.resok4
.count
);
3070 sprintf(get_line(0, 0), "Stable = %s",
3071 stable_how4_name(res
->WRITE4res_u
.resok4
.committed
));
3072 sprintf(get_line(0, 0), "Verifier = %s",
3073 tohex(res
->WRITE4res_u
.resok4
.writeverf
,
3074 NFS4_VERIFIER_SIZE
));
3079 * Print details about the nfs_resop4 that is next in the XDR stream.
3083 detail_nfs_resop4(void)
3087 void (*fmtproc
)(void *);
3089 numres
= getxdr_long();
3090 (void) sprintf(get_line(0, 0), "Number of results = %d",
3093 while (numres
-- > 0) {
3094 bzero(&one_res
, sizeof (one_res
));
3096 if (!xdr_nfs_resop4(&xdrm
, &one_res
)) {
3097 xdr_free(xdr_nfs_resop4
, (char *)&one_res
);
3098 longjmp(xdr_err
, 1);
3101 get_line(0, 0); /* blank line to separate ops */
3102 sprintf(get_line(0, 0), "Op = %d (%s)",
3103 one_res
.resop
, opcode_name(one_res
.resop
));
3104 if (one_res
.resop
< num_opcodes
)
3105 fmtproc
= opcode_info
[one_res
.resop
].dtlres
;
3106 else if (one_res
.resop
== OP_ILLEGAL
)
3107 fmtproc
= dtl_nfsstat4
;
3111 if (fmtproc
!= NULL
)
3112 fmtproc(&one_res
.nfs_resop4_u
);
3114 /* nfs4_skip_bytes set by xdr_nfs_resop4()() */
3115 if (nfs4_skip_bytes
)
3116 nfs4_xdr_skip(nfs4_skip_bytes
);
3118 xdr_free(xdr_nfs_resop4
, (char *)&one_res
);
3124 * Print details about the nfs_cb_resop4 that is next in the XDR stream.
3128 detail_cb_resop4(void)
3131 nfs_cb_resop4 one_res
;
3132 void (*fmtproc
)(void *);
3134 numres
= getxdr_long();
3135 (void) sprintf(get_line(0, 0), "Number of results = %d",
3138 while (numres
-- > 0) {
3139 bzero(&one_res
, sizeof (one_res
));
3140 if (!xdr_nfs_cb_resop4(&xdrm
, &one_res
))
3141 longjmp(xdr_err
, 1);
3143 get_line(0, 0); /* blank line to separate ops */
3144 sprintf(get_line(0, 0), "Op = %d (%s)",
3145 one_res
.resop
, cb_opcode_name(one_res
.resop
));
3146 if (one_res
.resop
< cb_num_opcodes
)
3147 fmtproc
= cb_opcode_info
[one_res
.resop
].dtlres
;
3148 else if (one_res
.resop
== OP_CB_ILLEGAL
)
3149 fmtproc
= dtl_nfsstat4
;
3153 if (fmtproc
!= NULL
)
3154 fmtproc(&one_res
.nfs_cb_resop4_u
);
3156 xdr_free(xdr_nfs_cb_resop4
, (char *)&one_res
);
3162 * Return the name of a lock type.
3165 lock_type_name(enum nfs_lock_type4 type
)
3191 * Return the name of an opcode.
3195 opcode_name(uint_t opnum
)
3197 static char buf
[20];
3199 if (opnum
< num_opcodes
)
3200 return (opcode_info
[opnum
].name
);
3202 if (opnum
== OP_ILLEGAL
)
3205 sprintf(buf
, "op %d", opnum
);
3210 * Return the name of an opcode.
3213 cb_opcode_name(uint_t opnum
)
3215 static char buf
[20];
3217 if (opnum
< cb_num_opcodes
)
3218 return (cb_opcode_info
[opnum
].name
);
3220 if (opnum
== OP_CB_ILLEGAL
)
3221 return ("CB_ILLEGAL");
3223 sprintf(buf
, "op %d", opnum
);
3229 * Fill in a summary string for the given access bitmask.
3233 sum_access4(char *buf
, size_t buflen
, uint32_t bits
)
3237 if (bits
& ACCESS4_READ
)
3238 (void) strncat(buf
, "rd,", buflen
);
3239 if (bits
& ACCESS4_LOOKUP
)
3240 (void) strncat(buf
, "lk,", buflen
);
3241 if (bits
& ACCESS4_MODIFY
)
3242 (void) strncat(buf
, "mo,", buflen
);
3243 if (bits
& ACCESS4_EXTEND
)
3244 (void) strncat(buf
, "ext,", buflen
);
3245 if (bits
& ACCESS4_DELETE
)
3246 (void) strncat(buf
, "dl,", buflen
);
3247 if (bits
& ACCESS4_EXECUTE
)
3248 (void) strncat(buf
, "exc,", buflen
);
3250 buf
[strlen(buf
) - 1] = '\0';
3254 * Print detail information about the given access bitmask.
3258 detail_access4(char *descrip
, uint32_t bits
)
3260 sprintf(get_line(0, 0), "%s = 0x%08x", descrip
, bits
);
3262 (void) sprintf(get_line(0, 0), " %s",
3263 getflag(bits
, ACCESS4_READ
, "Read", "(no read)"));
3264 (void) sprintf(get_line(0, 0), " %s",
3265 getflag(bits
, ACCESS4_LOOKUP
, "Lookup", "(no lookup)"));
3266 (void) sprintf(get_line(0, 0), " %s",
3267 getflag(bits
, ACCESS4_MODIFY
, "Modify", "(no modify)"));
3268 (void) sprintf(get_line(0, 0), " %s",
3269 getflag(bits
, ACCESS4_EXTEND
, "Extend", "(no extend)"));
3270 (void) sprintf(get_line(0, 0), " %s",
3271 getflag(bits
, ACCESS4_DELETE
, "Delete", "(no delete)"));
3272 (void) sprintf(get_line(0, 0), " %s",
3273 getflag(bits
, ACCESS4_EXECUTE
, "Execute", "(no execute)"));
3278 * Fill in a summary string for the given open_claim4.
3281 sum_name(char *buf
, size_t buflen
, open_claim4
*claim
)
3285 switch (claim
->claim
) {
3287 snprintf(bp
, buflen
, "%s ",
3288 component_name(&claim
->open_claim4_u
.file
));
3290 case CLAIM_PREVIOUS
:
3292 case CLAIM_DELEGATE_CUR
:
3293 snprintf(bp
, buflen
, "%s ",
3294 component_name(&claim
->open_claim4_u
.
3295 delegate_cur_info
.file
));
3297 case CLAIM_DELEGATE_PREV
:
3298 snprintf(bp
, buflen
, "%s ",
3299 component_name(&claim
->open_claim4_u
.
3300 file_delegate_prev
));
3306 * Fill in a summary string for the given open_claim4.
3309 sum_claim(char *buf
, size_t buflen
, open_claim4
*claim
)
3313 switch (claim
->claim
) {
3315 snprintf(bp
, buflen
, " CT=N");
3317 case CLAIM_PREVIOUS
:
3318 snprintf(bp
, buflen
, " CT=P DT=%s",
3319 get_deleg_typestr(claim
->open_claim4_u
.delegate_type
));
3321 case CLAIM_DELEGATE_CUR
:
3322 snprintf(bp
, buflen
, " CT=DC %s",
3323 sum_deleg_stateid(&claim
->open_claim4_u
.
3324 delegate_cur_info
.delegate_stateid
));
3326 case CLAIM_DELEGATE_PREV
:
3327 snprintf(bp
, buflen
, " CT=DP");
3330 snprintf(bp
, buflen
, " CT=?");
3336 get_deleg_typestr(open_delegation_type4 dt
)
3341 case OPEN_DELEGATE_NONE
:
3344 case OPEN_DELEGATE_READ
:
3347 case OPEN_DELEGATE_WRITE
:
3358 * Print detail information for the given open_claim4.
3362 detail_claim(open_claim4
*claim
)
3364 sprintf(get_line(0, 0), "Claim Type = %d (%s)",
3365 claim
->claim
, claim_name(claim
->claim
));
3367 switch (claim
->claim
) {
3369 detail_compname4(&claim
->open_claim4_u
.file
);
3371 case CLAIM_PREVIOUS
:
3372 sprintf(get_line(0, 0), "Delegate Type = %s (val = %d)",
3373 get_deleg_typestr(claim
->open_claim4_u
.delegate_type
),
3374 claim
->open_claim4_u
.delegate_type
);
3376 case CLAIM_DELEGATE_CUR
:
3377 detail_compname4(&claim
->open_claim4_u
.delegate_cur_info
.file
);
3378 detail_deleg_stateid(&claim
->open_claim4_u
.delegate_cur_info
.
3381 case CLAIM_DELEGATE_PREV
:
3382 detail_compname4(&claim
->open_claim4_u
.file_delegate_prev
);
3388 * Return a summary string for the given clientid4.
3391 sum_clientid(clientid4 client
)
3393 static char buf
[50];
3395 snprintf(buf
, sizeof (buf
), "CL=%llx", client
);
3401 * Print a detail string for the given clientid4.
3404 detail_clientid(clientid4 client
)
3406 sprintf(get_line(0, 0), "Client ID = %llx", client
);
3410 * Write a summary string for the given delegation into buf.
3414 sum_delegation(char *buf
, size_t buflen
, open_delegation4
*delp
)
3416 switch (delp
->delegation_type
) {
3417 case OPEN_DELEGATE_NONE
:
3418 snprintf(buf
, buflen
, " DT=N");
3420 case OPEN_DELEGATE_READ
:
3421 snprintf(buf
, buflen
, " DT=R %s",
3422 sum_deleg_stateid(&delp
->open_delegation4_u
.write
.
3425 case OPEN_DELEGATE_WRITE
:
3426 snprintf(buf
, buflen
, " DT=W %s %s",
3427 sum_deleg_stateid(&delp
->open_delegation4_u
.write
.
3429 sum_space_limit(&delp
->open_delegation4_u
.write
.
3433 snprintf(buf
, buflen
, " DT=?");
3439 detail_delegation(open_delegation4
*delp
)
3441 sprintf(get_line(0, 0), "Delegation Type = %d (%s)",
3442 delp
->delegation_type
,
3443 delegation_type_name(delp
->delegation_type
));
3445 switch (delp
->delegation_type
) {
3446 case OPEN_DELEGATE_NONE
:
3449 case OPEN_DELEGATE_READ
:
3450 detail_deleg_stateid(&delp
->open_delegation4_u
.read
.stateid
);
3451 sprintf(get_line(0, 0), "Recall = %s",
3452 delp
->open_delegation4_u
.read
.recall
?
3454 sprintf(get_line(0, 0), "[nfsacl4]");
3456 case OPEN_DELEGATE_WRITE
:
3457 detail_deleg_stateid(&delp
->open_delegation4_u
.write
.stateid
);
3458 sprintf(get_line(0, 0), "Recall = %s",
3459 delp
->open_delegation4_u
.write
.recall
?
3461 detail_space_limit(&delp
->open_delegation4_u
.write
.
3463 sprintf(get_line(0, 0), "[nfsacl4]");
3470 detail_open_owner(open_owner4
*owner
)
3472 sprintf(get_line(0, 0), "Open Owner hash = [%04X] ",
3473 owner_hash(&owner
->owner
));
3474 sprintf(get_line(0, 0), " len = %u val = %s ",
3475 owner
->owner
.owner_len
,
3476 tohex(owner
->owner
.owner_val
, owner
->owner
.owner_len
));
3477 detail_clientid(owner
->clientid
);
3481 detail_lock_owner(lock_owner4
*owner
)
3483 sprintf(get_line(0, 0), "Lock Owner hash = [%04X] ",
3484 owner_hash(&owner
->owner
));
3485 sprintf(get_line(0, 0), " len = %u val = %s ",
3486 owner
->owner
.owner_len
,
3487 tohex(owner
->owner
.owner_val
, owner
->owner
.owner_len
));
3488 detail_clientid(owner
->clientid
);
3492 sum_openflag(char *bufp
, int buflen
, openflag4
*flagp
)
3494 if (flagp
->opentype
== OPEN4_CREATE
) {
3495 switch (flagp
->openflag4_u
.how
.mode
) {
3497 snprintf(bufp
, buflen
, "OT=CR(U)");
3500 snprintf(bufp
, buflen
, "OT=CR(G)");
3503 snprintf(bufp
, buflen
, "OT=CR(E)");
3506 snprintf(bufp
, buflen
, "OT=CR(?:%d)",
3507 flagp
->openflag4_u
.how
.mode
);
3511 snprintf(bufp
, buflen
, "OT=NC");
3515 detail_openflag(openflag4
*flagp
)
3517 sprintf(get_line(0, 0), "Open Type = %s",
3518 flagp
->opentype
== OPEN4_CREATE
? "CREATE" : "NOCREATE");
3519 if (flagp
->opentype
== OPEN4_CREATE
)
3520 detail_createhow4(&flagp
->openflag4_u
.how
);
3524 * Fill in buf with the given path.
3527 sum_pathname4(char *buf
, size_t buflen
, pathname4
*pathp
)
3532 for (component
= 0; component
< pathp
->pathname4_len
;
3534 snprintf(bp
, buflen
- (bp
- buf
),
3535 component
== 0 ? "%s" : "/%s",
3536 component_name(&pathp
->pathname4_val
[component
]));
3542 sum_compname4(char *buf
, size_t buflen
, component4
*comp
)
3544 snprintf(buf
, buflen
, "%s", component_name(comp
));
3548 detail_compname4(component4
*comp
)
3550 sprintf(get_line(0, 0), "%s", component_name(comp
));
3554 detail_pathname4(pathname4
*pathp
, char *what
)
3556 char *bp
= get_line(0, 0);
3562 for (component
= 0; component
< pathp
->pathname4_len
; component
++) {
3563 sprintf(bp
, component
== 0 ? "%s" : "/%s",
3564 component_name(&pathp
->pathname4_val
[component
]));
3570 * Print detail information about the rpcsec_gss_info that is XDR-encoded
3575 detail_rpcsec_gss(rpcsec_gss_info
*info
)
3577 sprintf(get_line(0, 0), "OID = %s",
3578 tohex(info
->oid
.sec_oid4_val
, info
->oid
.sec_oid4_len
));
3579 sprintf(get_line(0, 0), "QOP = %u", info
->qop
);
3580 sprintf(get_line(0, 0), "Service = %d (%s)",
3581 info
->service
, gss_svc_name(info
->service
));
3585 * Print detail information about the given secinfo4.
3589 detail_secinfo4(secinfo4
*infop
)
3591 sprintf(get_line(0, 0), "Flavor = %d (%s)",
3592 infop
->flavor
, flavor_name(infop
->flavor
));
3593 switch (infop
->flavor
) {
3595 detail_rpcsec_gss(&infop
->secinfo4_u
.flavor_info
);
3602 * Return a summary string corresponding to the given nfs_space_limit4.
3606 sum_space_limit(nfs_space_limit4
*limitp
)
3608 static char buf
[64];
3609 int buflen
= sizeof (buf
);
3612 switch (limitp
->limitby
) {
3613 case NFS_LIMIT_SIZE
:
3614 snprintf(buf
, buflen
, "LB=SZ(%llu)",
3615 limitp
->nfs_space_limit4_u
.filesize
);
3617 case NFS_LIMIT_BLOCKS
:
3618 snprintf(buf
, buflen
, "LB=BL(%u*%u)",
3619 limitp
->nfs_space_limit4_u
.mod_blocks
.num_blocks
,
3620 limitp
->nfs_space_limit4_u
.mod_blocks
.bytes_per_block
);
3623 snprintf(buf
, buflen
, "LB=?(%d)", limitp
->limitby
);
3631 * Print detail information about the given nfs_space_limit4.
3635 detail_space_limit(nfs_space_limit4
*limitp
)
3637 sprintf(get_line(0, 0), "LimitBy = %d (%s)",
3639 limitby_name(limitp
->limitby
));
3641 switch (limitp
->limitby
) {
3642 case NFS_LIMIT_SIZE
:
3643 sprintf(get_line(0, 0), "Bytes = %llu",
3644 limitp
->nfs_space_limit4_u
.filesize
);
3646 case NFS_LIMIT_BLOCKS
:
3647 sprintf(get_line(0, 0), "Blocks = %u",
3648 limitp
->nfs_space_limit4_u
.mod_blocks
.num_blocks
);
3649 sprintf(get_line(0, 0), "Bytes Per Block = %u",
3650 limitp
->nfs_space_limit4_u
.mod_blocks
.bytes_per_block
);
3657 * Return the short name of a file type.
3661 sum_type_name(nfs_ftype4 type
)
3663 static char buf
[20];
3665 if (type
< num_ftypes
)
3666 return (ftype_names
[type
].short_name
);
3668 sprintf(buf
, "type %d", type
);
3675 * Return string with long/short flag names
3679 get_flags(uint_t flag
, ftype_names_t
*names
, uint_t num_flags
, int shortname
,
3682 static char buf
[200];
3683 char *bp
= buf
, *str
;
3684 int i
, len
, blen
= sizeof (buf
);
3685 ftype_names_t
*fn
= NULL
;
3690 snprintf(bp
, blen
, "%s", prefix
);
3691 bp
+= (len
= sizeof (bp
));
3695 for (i
= 0; i
< 32; i
++)
3696 if (flag
& (1 << i
)) {
3697 fn
= names
+ (i
< num_flags
? i
: num_flags
);
3698 str
= (shortname
? fn
->short_name
: fn
->long_name
);
3700 snprintf(bp
, blen
, "%s,", str
);
3701 bp
+= (len
= strlen(bp
));
3715 * Return the long name of a file type.
3719 detail_type_name(nfs_ftype4 type
)
3721 static char buf
[20];
3723 if (type
< num_ftypes
)
3724 return (ftype_names
[type
].long_name
);
3726 sprintf(buf
, "type %d", type
);
3732 * Return the name of an attribute.
3736 attr_name(uint_t attrnum
)
3738 static char buf
[20];
3740 if (attrnum
< MAX_ATTRIBUTES
)
3741 return (attr_info
[attrnum
].name
);
3743 sprintf(buf
, "attr #%d", attrnum
);
3749 * Return the name of the given open_claim_type4.
3753 claim_name(enum open_claim_type4 claim_type
)
3757 switch (claim_type
) {
3761 case CLAIM_PREVIOUS
:
3762 result
= "PREVIOUS";
3764 case CLAIM_DELEGATE_CUR
:
3765 result
= "DELEGATE CURRENT";
3767 case CLAIM_DELEGATE_PREV
:
3768 result
= "DELEGATE PREVIOUS";
3779 * Return a string naming the given delegation.
3783 delegation_type_name(enum open_delegation_type4 type
)
3788 case OPEN_DELEGATE_NONE
:
3791 case OPEN_DELEGATE_READ
:
3794 case OPEN_DELEGATE_WRITE
:
3806 * Return the name of the given authentication flavor.
3810 flavor_name(uint_t flavor
)
3813 static char buf
[50];
3817 result
= "AUTH_SYS";
3820 result
= "AUTH_NONE";
3826 result
= "RPCSEC_GSS";
3829 sprintf(buf
, "[flavor %d]", flavor
);
3838 * Return the name of the given rpc_gss_svc_t.
3842 gss_svc_name(rpc_gss_svc_t svc
)
3845 static char buf
[50];
3848 case RPC_GSS_SVC_NONE
:
3851 case RPC_GSS_SVC_INTEGRITY
:
3852 result
= "INTEGRITY";
3854 case RPC_GSS_SVC_PRIVACY
:
3858 sprintf(buf
, "Service %d", svc
);
3867 * Return a string name for the given limit_by4.
3871 limitby_name(enum limit_by4 limitby
)
3876 case NFS_LIMIT_SIZE
:
3879 case NFS_LIMIT_BLOCKS
:
3891 status_name(int status
)
3896 case NFS4_OK
: p
= "NFS4_OK"; break;
3897 case NFS4ERR_PERM
: p
= "NFS4ERR_PERM"; break;
3898 case NFS4ERR_NOENT
: p
= "NFS4ERR_NOENT"; break;
3899 case NFS4ERR_IO
: p
= "NFS4ERR_IO"; break;
3900 case NFS4ERR_NXIO
: p
= "NFS4ERR_NXIO"; break;
3901 case NFS4ERR_ACCESS
: p
= "NFS4ERR_ACCESS"; break;
3902 case NFS4ERR_EXIST
: p
= "NFS4ERR_EXIST"; break;
3903 case NFS4ERR_XDEV
: p
= "NFS4ERR_XDEV"; break;
3904 case NFS4ERR_NOTDIR
: p
= "NFS4ERR_NOTDIR"; break;
3905 case NFS4ERR_ISDIR
: p
= "NFS4ERR_ISDIR"; break;
3906 case NFS4ERR_INVAL
: p
= "NFS4ERR_INVAL"; break;
3907 case NFS4ERR_FBIG
: p
= "NFS4ERR_FBIG"; break;
3908 case NFS4ERR_NOSPC
: p
= "NFS4ERR_NOSPC"; break;
3909 case NFS4ERR_ROFS
: p
= "NFS4ERR_ROFS"; break;
3910 case NFS4ERR_MLINK
: p
= "NFS4ERR_MLINK"; break;
3911 case NFS4ERR_NAMETOOLONG
:p
= "NFS4ERR_NAMETOOLONG"; break;
3912 case NFS4ERR_NOTEMPTY
: p
= "NFS4ERR_NOTEMPTY"; break;
3913 case NFS4ERR_DQUOT
: p
= "NFS4ERR_DQUOT"; break;
3914 case NFS4ERR_STALE
: p
= "NFS4ERR_STALE"; break;
3915 case NFS4ERR_BADHANDLE
: p
= "NFS4ERR_BADHANDLE"; break;
3916 case NFS4ERR_BAD_COOKIE
:p
= "NFS4ERR_BAD_COOKIE"; break;
3917 case NFS4ERR_NOTSUPP
: p
= "NFS4ERR_NOTSUPP"; break;
3918 case NFS4ERR_TOOSMALL
: p
= "NFS4ERR_TOOSMALL"; break;
3919 case NFS4ERR_SERVERFAULT
:p
= "NFS4ERR_SERVERFAULT"; break;
3920 case NFS4ERR_BADTYPE
: p
= "NFS4ERR_BADTYPE"; break;
3921 case NFS4ERR_DELAY
: p
= "NFS4ERR_DELAY"; break;
3922 case NFS4ERR_SAME
: p
= "NFS4ERR_SAME"; break;
3923 case NFS4ERR_DENIED
: p
= "NFS4ERR_DENIED"; break;
3924 case NFS4ERR_EXPIRED
: p
= "NFS4ERR_EXPIRED"; break;
3925 case NFS4ERR_LOCKED
: p
= "NFS4ERR_LOCKED"; break;
3926 case NFS4ERR_GRACE
: p
= "NFS4ERR_GRACE"; break;
3927 case NFS4ERR_FHEXPIRED
: p
= "NFS4ERR_FHEXPIRED"; break;
3928 case NFS4ERR_SHARE_DENIED
: p
= "NFS4ERR_SHARE_DENIED"; break;
3929 case NFS4ERR_WRONGSEC
: p
= "NFS4ERR_WRONGSEC"; break;
3930 case NFS4ERR_CLID_INUSE
: p
= "NFS4ERR_CLID_INUSE"; break;
3931 case NFS4ERR_RESOURCE
: p
= "NFS4ERR_RESOURCE"; break;
3932 case NFS4ERR_MOVED
: p
= "NFS4ERR_MOVED"; break;
3933 case NFS4ERR_NOFILEHANDLE
: p
= "NFS4ERR_NOFILEHANDLE"; break;
3934 case NFS4ERR_MINOR_VERS_MISMATCH
: p
= "NFS4ERR_MINOR_VERS_MISMATCH";
3936 case NFS4ERR_STALE_CLIENTID
: p
= "NFS4ERR_STALE_CLIENTID"; break;
3937 case NFS4ERR_STALE_STATEID
: p
= "NFS4ERR_STALE_STATEID"; break;
3938 case NFS4ERR_OLD_STATEID
: p
= "NFS4ERR_OLD_STATEID"; break;
3939 case NFS4ERR_BAD_STATEID
: p
= "NFS4ERR_BAD_STATEID"; break;
3940 case NFS4ERR_BAD_SEQID
: p
= "NFS4ERR_BAD_SEQID"; break;
3941 case NFS4ERR_NOT_SAME
: p
= "NFS4ERR_NOT_SAME"; break;
3942 case NFS4ERR_LOCK_RANGE
: p
= "NFS4ERR_LOCK_RANGE"; break;
3943 case NFS4ERR_SYMLINK
: p
= "NFS4ERR_SYMLINK"; break;
3944 case NFS4ERR_RESTOREFH
: p
= "NFS4ERR_RESTOREFH"; break;
3945 case NFS4ERR_LEASE_MOVED
: p
= "NFS4ERR_LEASE_MOVED"; break;
3946 case NFS4ERR_ATTRNOTSUPP
: p
= "NFS4ERR_ATTRNOTSUPP"; break;
3947 case NFS4ERR_NO_GRACE
: p
= "NFS4ERR_NO_GRACE"; break;
3948 case NFS4ERR_RECLAIM_BAD
: p
= "NFS4ERR_RECLAIM_BAD"; break;
3949 case NFS4ERR_RECLAIM_CONFLICT
: p
= "NFS4ERR_RECLAIM_CONFLICT"; break;
3950 case NFS4ERR_BADXDR
: p
= "NFS4ERR_BADXDR"; break;
3951 case NFS4ERR_LOCKS_HELD
: p
= "NFS4ERR_LOCKS_HELD"; break;
3952 case NFS4ERR_OPENMODE
: p
= "NFS4ERR_OPENMODE"; break;
3953 case NFS4ERR_BADOWNER
: p
= "NFS4ERR_BADOWNER"; break;
3954 case NFS4ERR_BADCHAR
: p
= "NFS4ERR_BADCHAR"; break;
3955 case NFS4ERR_BADNAME
: p
= "NFS4ERR_BADNAME"; break;
3956 case NFS4ERR_BAD_RANGE
: p
= "NFS4ERR_BAD_RANGE"; break;
3957 case NFS4ERR_LOCK_NOTSUPP
: p
= "NFS4ERR_LOCK_NOTSUPP"; break;
3958 case NFS4ERR_OP_ILLEGAL
: p
= "NFS4ERR_OP_ILLEGAL"; break;
3959 case NFS4ERR_DEADLOCK
: p
= "NFS4ERR_DEADLOCK"; break;
3960 case NFS4ERR_FILE_OPEN
: p
= "NFS4ERR_FILE_OPEN"; break;
3961 case NFS4ERR_ADMIN_REVOKED
: p
= "NFS4ERR_ADMIN_REVOKED"; break;
3962 case NFS4ERR_CB_PATH_DOWN
: p
= "NFS4ERR_CB_PATH_DOWN"; break;
3963 default: p
= "(unknown error)"; break;
3970 nfsstat4_to_name(int status
)
3972 return (status_name(status
));
3976 * Attribute print functions. See attr_info_t.
3980 prt_supported_attrs(XDR
*xdr
)
3984 if (!xdr_bitmap4(xdr
, &val
))
3985 longjmp(xdr_err
, 1);
3986 sprintf(get_line(0, 0), "Supported Attributes:");
3987 detail_attr_bitmap("\t", &val
, NULL
);
3988 xdr_free(xdr_bitmap4
, (char *)&val
);
3996 if (!xdr_nfs_ftype4(xdr
, &val
))
3997 longjmp(xdr_err
, 1);
3998 sprintf(get_line(0, 0), "Type = %s", sum_type_name(val
));
4002 prt_fh_expire_type(XDR
*xdr
)
4004 fattr4_fh_expire_type val
;
4006 bool_t first
= TRUE
;
4008 if (!xdr_fattr4_fh_expire_type(xdr
, &val
))
4009 longjmp(xdr_err
, 1);
4010 buf
= get_line(0, 0);
4012 sprintf(buf
, "Filehandle expire type = ");
4013 if ((val
& (FH4_NOEXPIRE_WITH_OPEN
| FH4_VOLATILE_ANY
|
4014 FH4_VOL_MIGRATION
| FH4_VOL_RENAME
)) == 0) {
4015 strcat(buf
, "Persistent");
4018 if (val
& FH4_NOEXPIRE_WITH_OPEN
) {
4019 strcat(buf
, "No Expire With OPEN");
4022 if (val
& FH4_VOLATILE_ANY
) {
4027 strcat(buf
, "Volatile at any time");
4029 if (val
& FH4_VOL_MIGRATION
) {
4034 strcat(buf
, "Volatile at Migration");
4036 if (val
& FH4_VOL_RENAME
) {
4041 strcat(buf
, "Volatile at Rename");
4046 prt_change(XDR
*xdr
)
4050 if (!xdr_changeid4(xdr
, &val
))
4051 longjmp(xdr_err
, 1);
4052 sprintf(get_line(0, 0), "Change ID = 0x%llx", val
);
4053 /* XXX print as time_t, too? */
4061 if (!xdr_uint64_t(xdr
, &val
))
4062 longjmp(xdr_err
, 1);
4063 sprintf(get_line(0, 0), "Size = %llu", val
);
4067 prt_link_support(XDR
*xdr
)
4071 if (!xdr_bool(xdr
, &val
))
4072 longjmp(xdr_err
, 1);
4073 sprintf(get_line(0, 0), "Link Support = %s",
4074 val
? "TRUE" : "FALSE");
4078 prt_symlink_support(XDR
*xdr
)
4082 if (!xdr_bool(xdr
, &val
))
4083 longjmp(xdr_err
, 1);
4084 sprintf(get_line(0, 0), "Symlink Support = %s",
4085 val
? "TRUE" : "FALSE");
4089 prt_named_attr(XDR
*xdr
)
4093 if (!xdr_bool(xdr
, &val
))
4094 longjmp(xdr_err
, 1);
4095 sprintf(get_line(0, 0), "Has Named Attributes = %s",
4096 val
? "TRUE" : "FALSE");
4104 if (!xdr_fsid4(xdr
, &val
))
4105 longjmp(xdr_err
, 1);
4106 sprintf(get_line(0, 0), "FS ID: Major = %llx, Minor = %llx",
4107 val
.major
, val
.minor
);
4111 prt_unique_handles(XDR
*xdr
)
4115 if (!xdr_bool(xdr
, &val
))
4116 longjmp(xdr_err
, 1);
4117 sprintf(get_line(0, 0), "Unique Handles = %s",
4118 val
? "TRUE" : "FALSE");
4122 prt_lease_time(XDR
*xdr
)
4126 if (!xdr_uint32_t(xdr
, &val
))
4127 longjmp(xdr_err
, 1);
4128 sprintf(get_line(0, 0), "Lease Time = %u", val
);
4132 prt_rdattr_error(XDR
*xdr
)
4136 if (!xdr_nfsstat4(xdr
, &val
))
4137 longjmp(xdr_err
, 1);
4138 sprintf(get_line(0, 0), "Rdattr Error = %u (%s)",
4139 val
, status_name(val
));
4145 static fattr4_acl val
;
4146 char buffy
[NFS4_OPAQUE_LIMIT
];
4149 if (!xdr_fattr4_acl(xdr
, &val
))
4150 longjmp(xdr_err
, 1);
4151 sprintf(get_line(0, 0), "ACL of %d entries", val
.fattr4_acl_len
);
4152 for (i
= 0; i
< val
.fattr4_acl_len
; i
++) {
4153 sprintf(get_line(0, 0), "nfsace4[%d]", i
);
4155 sprintf(get_line(0, 0), " type = %x",
4156 val
.fattr4_acl_val
[i
].type
);
4157 detail_acetype4(val
.fattr4_acl_val
[i
].type
);
4159 sprintf(get_line(0, 0), " flags = %x",
4160 val
.fattr4_acl_val
[i
].flag
);
4161 detail_aceflag4(val
.fattr4_acl_val
[i
].flag
);
4163 sprintf(get_line(0, 0), " mask = %x",
4164 val
.fattr4_acl_val
[i
].access_mask
);
4165 detail_acemask4(val
.fattr4_acl_val
[i
].access_mask
);
4167 len
= val
.fattr4_acl_val
[i
].who
.utf8string_len
;
4168 if (len
>= NFS4_OPAQUE_LIMIT
)
4169 len
= NFS4_OPAQUE_LIMIT
- 1;
4170 (void) strncpy(buffy
, val
.fattr4_acl_val
[i
].who
.utf8string_val
,
4173 sprintf(get_line(0, 0), " who = %s", buffy
);
4175 xdr_free(xdr_fattr4_acl
, (char *)&val
);
4179 detail_acetype4(acetype4 type
)
4181 if (type
>= ACETYPE4_NAMES_MAX
) {
4182 sprintf(get_line(0, 0), " unknown type");
4184 sprintf(get_line(0, 0), " %s", acetype4_names
[type
]);
4189 detail_uint32_bitmap(uint32_t mask
, char *mask_names
[], int names_max
)
4191 char buffy
[BUFSIZ
], *name
;
4196 int len
, namelen
, spacelen
;
4198 strcpy(buffy
, indent
);
4199 len
= strlen(buffy
);
4200 spacelen
= strlen(spacer
);
4202 for (bit
= 0; bit
< names_max
; bit
++) {
4203 if (mask
& (1 << bit
)) {
4204 name
= mask_names
[bit
];
4205 namelen
= strlen(name
);
4206 /* 80 - 6 for "NFS: " = 74 */
4207 if ((len
+ spacelen
+ namelen
) >= 74) {
4208 sprintf(get_line(0, 0), "%s", buffy
);
4209 strcpy(buffy
, indent
);
4210 len
= strlen(buffy
);
4213 (void) strlcat(buffy
, spacer
, sizeof (buffy
));
4214 (void) strlcat(buffy
, name
, sizeof (buffy
));
4216 len
+= spacelen
+ namelen
;
4220 sprintf(get_line(0, 0), "%s", buffy
);
4224 detail_aceflag4(aceflag4 flag
)
4226 detail_uint32_bitmap(flag
, aceflag4_names
, ACEFLAG4_NAMES_MAX
);
4230 detail_acemask4(acemask4 mask
)
4232 detail_uint32_bitmap(mask
, acemask4_names
, ACEMASK4_NAMES_MAX
);
4236 prt_aclsupport(XDR
*xdr
)
4238 fattr4_aclsupport val
;
4240 if (!xdr_fattr4_aclsupport(xdr
, &val
))
4241 longjmp(xdr_err
, 1);
4242 if (val
& ACL4_SUPPORT_ALLOW_ACL
)
4243 sprintf(get_line(0, 0), "ALLOW ACL Supported");
4244 if (val
& ACL4_SUPPORT_DENY_ACL
)
4245 sprintf(get_line(0, 0), "DENY ACL Supported");
4246 if (val
& ACL4_SUPPORT_AUDIT_ACL
)
4247 sprintf(get_line(0, 0), "AUDIT ACL Supported");
4248 if (val
& ACL4_SUPPORT_ALARM_ACL
)
4249 sprintf(get_line(0, 0), "ALARM ACL Supported");
4253 prt_archive(XDR
*xdr
)
4257 if (!xdr_bool(xdr
, &val
))
4258 longjmp(xdr_err
, 1);
4259 sprintf(get_line(0, 0), "Archived = %s",
4260 val
? "TRUE" : "FALSE");
4264 prt_cansettime(XDR
*xdr
)
4268 if (!xdr_bool(xdr
, &val
))
4269 longjmp(xdr_err
, 1);
4270 sprintf(get_line(0, 0), "Server Can Set Time = %s",
4271 val
? "TRUE" : "FALSE");
4275 prt_case_insensitive(XDR
*xdr
)
4279 if (!xdr_bool(xdr
, &val
))
4280 longjmp(xdr_err
, 1);
4281 sprintf(get_line(0, 0), "Case Insensitive Lookups = %s",
4282 val
? "TRUE" : "FALSE");
4286 prt_case_preserving(XDR
*xdr
)
4290 if (!xdr_bool(xdr
, &val
))
4291 longjmp(xdr_err
, 1);
4292 sprintf(get_line(0, 0), "Case Preserving = %s",
4293 val
? "TRUE" : "FALSE");
4297 prt_chown_restricted(XDR
*xdr
)
4301 if (!xdr_bool(xdr
, &val
))
4302 longjmp(xdr_err
, 1);
4303 sprintf(get_line(0, 0), "Chown Is Restricted = %s",
4304 val
? "TRUE" : "FALSE");
4308 prt_filehandle(XDR
*xdr
)
4312 if (!xdr_nfs_fh4(xdr
, &val
))
4313 longjmp(xdr_err
, 1);
4315 xdr_free(xdr_nfs_fh4
, (char *)&val
);
4319 prt_fileid(XDR
*xdr
)
4323 if (!xdr_uint64_t(xdr
, &val
))
4324 longjmp(xdr_err
, 1);
4325 sprintf(get_line(0, 0), "File ID = %llu", val
);
4329 prt_mounted_on_fileid(XDR
*xdr
)
4333 if (!xdr_uint64_t(xdr
, &val
))
4334 longjmp(xdr_err
, 1);
4335 sprintf(get_line(0, 0), "Mounted On File ID = %llu", val
);
4339 prt_files_avail(XDR
*xdr
)
4343 if (!xdr_uint64_t(xdr
, &val
))
4344 longjmp(xdr_err
, 1);
4345 sprintf(get_line(0, 0), "Files Available = %llu", val
);
4349 prt_files_free(XDR
*xdr
)
4353 if (!xdr_uint64_t(xdr
, &val
))
4354 longjmp(xdr_err
, 1);
4355 sprintf(get_line(0, 0), "Files Free = %llu", val
);
4359 prt_files_total(XDR
*xdr
)
4363 if (!xdr_uint64_t(xdr
, &val
))
4364 longjmp(xdr_err
, 1);
4365 sprintf(get_line(0, 0), "Files Total = %llu", val
);
4369 prt_fs_location(fs_location4
*fsl
)
4373 for (i
= 0; i
< fsl
->server
.server_len
; i
++)
4374 sprintf(get_line(0, 0), "server: %s",
4375 utf8localize(&fsl
->server
.server_val
[i
]));
4377 detail_pathname4(&fsl
->rootpath
, "rootpath: ");
4381 prt_fs_locations(XDR
*xdr
)
4383 static fs_locations4 val
;
4386 if (!xdr_fs_locations4(xdr
, &val
))
4387 longjmp(xdr_err
, 1);
4388 sprintf(get_line(0, 0), "[fs_locations]");
4389 detail_pathname4(&val
.fs_root
, "fs_root: ");
4390 for (i
= 0; i
< val
.locations
.locations_len
; i
++)
4391 prt_fs_location(&val
.locations
.locations_val
[i
]);
4392 xdr_free(xdr_fs_locations4
, (char *)&val
);
4396 prt_hidden(XDR
*xdr
)
4400 if (!xdr_bool(xdr
, &val
))
4401 longjmp(xdr_err
, 1);
4402 sprintf(get_line(0, 0), "Hidden = %s",
4403 val
? "TRUE" : "FALSE");
4407 prt_homogeneous(XDR
*xdr
)
4411 if (!xdr_bool(xdr
, &val
))
4412 longjmp(xdr_err
, 1);
4413 sprintf(get_line(0, 0), "FS Is Homogeneous = %s",
4414 val
? "TRUE" : "FALSE");
4418 prt_maxfilesize(XDR
*xdr
)
4422 if (!xdr_uint64_t(xdr
, &val
))
4423 longjmp(xdr_err
, 1);
4424 sprintf(get_line(0, 0), "Maximum File Size = %llu", val
);
4428 prt_maxlink(XDR
*xdr
)
4432 if (!xdr_uint32_t(xdr
, &val
))
4433 longjmp(xdr_err
, 1);
4434 sprintf(get_line(0, 0), "Maximum Number of Links = %u", val
);
4438 prt_maxname(XDR
*xdr
)
4442 if (!xdr_uint32_t(xdr
, &val
))
4443 longjmp(xdr_err
, 1);
4444 sprintf(get_line(0, 0), "Maximum File Name Length = %u", val
);
4448 prt_maxread(XDR
*xdr
)
4452 if (!xdr_uint64_t(xdr
, &val
))
4453 longjmp(xdr_err
, 1);
4454 sprintf(get_line(0, 0), "Maximum Read Size = %llu", val
);
4458 prt_maxwrite(XDR
*xdr
)
4462 if (!xdr_uint64_t(xdr
, &val
))
4463 longjmp(xdr_err
, 1);
4465 sprintf(get_line(0, 0), "Maximum Write Size = %llu", val
);
4469 prt_mimetype(XDR
*xdr
)
4471 static utf8string val
;
4473 if (!xdr_utf8string(xdr
, &val
))
4474 longjmp(xdr_err
, 1);
4475 sprintf(get_line(0, 0), "MIME Type = %s", utf8localize(&val
));
4476 xdr_free(xdr_utf8string
, (char *)&val
);
4484 if (!xdr_mode4(xdr
, &val
))
4485 longjmp(xdr_err
, 1);
4486 sprintf(get_line(0, 0), "Mode = 0%03o", val
);
4490 prt_no_trunc(XDR
*xdr
)
4494 if (!xdr_bool(xdr
, &val
))
4495 longjmp(xdr_err
, 1);
4496 sprintf(get_line(0, 0), "Long Names Are Error (no_trunc) = %s",
4497 val
? "TRUE" : "FALSE");
4501 prt_numlinks(XDR
*xdr
)
4505 if (!xdr_uint32_t(xdr
, &val
))
4506 longjmp(xdr_err
, 1);
4507 sprintf(get_line(0, 0), "Number of Links = %u", val
);
4513 static utf8string val
;
4515 if (!xdr_utf8string(xdr
, &val
))
4516 longjmp(xdr_err
, 1);
4517 sprintf(get_line(0, 0), "Owner = %s", utf8localize(&val
));
4518 xdr_free(xdr_utf8string
, (char *)&val
);
4522 prt_owner_group(XDR
*xdr
)
4524 static utf8string val
;
4526 if (!xdr_utf8string(xdr
, &val
))
4527 longjmp(xdr_err
, 1);
4528 sprintf(get_line(0, 0), "Group = %s", utf8localize(&val
));
4529 xdr_free(xdr_utf8string
, (char *)&val
);
4533 prt_quota_avail_hard(XDR
*xdr
)
4537 if (!xdr_uint64_t(xdr
, &val
))
4538 longjmp(xdr_err
, 1);
4539 sprintf(get_line(0, 0), "Quota Hard Limit = %llu", val
);
4543 prt_quota_avail_soft(XDR
*xdr
)
4547 if (!xdr_uint64_t(xdr
, &val
))
4548 longjmp(xdr_err
, 1);
4549 sprintf(get_line(0, 0), "Quota Soft Limit = %llu", val
);
4553 prt_quota_used(XDR
*xdr
)
4557 if (!xdr_uint64_t(xdr
, &val
))
4558 longjmp(xdr_err
, 1);
4559 sprintf(get_line(0, 0), "Quota Used = %llu", val
);
4563 prt_rawdev(XDR
*xdr
)
4567 if (!xdr_specdata4(xdr
, &val
))
4568 longjmp(xdr_err
, 1);
4569 sprintf(get_line(0, 0), "Raw Device ID = %u, %u",
4570 val
.specdata1
, val
.specdata2
);
4574 prt_space_avail(XDR
*xdr
)
4578 if (!xdr_uint64_t(xdr
, &val
))
4579 longjmp(xdr_err
, 1);
4580 sprintf(get_line(0, 0), "Space Available = %llu", val
);
4584 prt_space_free(XDR
*xdr
)
4588 if (!xdr_uint64_t(xdr
, &val
))
4589 longjmp(xdr_err
, 1);
4590 sprintf(get_line(0, 0), "Space Free = %llu", val
);
4594 prt_space_total(XDR
*xdr
)
4598 if (!xdr_uint64_t(xdr
, &val
))
4599 longjmp(xdr_err
, 1);
4600 sprintf(get_line(0, 0), "Total Disk Space = %llu", val
);
4604 prt_space_used(XDR
*xdr
)
4608 if (!xdr_uint64_t(xdr
, &val
))
4609 longjmp(xdr_err
, 1);
4610 sprintf(get_line(0, 0), "Space Used (this object) = %llu", val
);
4614 prt_system(XDR
*xdr
)
4618 if (!xdr_bool(xdr
, &val
))
4619 longjmp(xdr_err
, 1);
4620 sprintf(get_line(0, 0), "System File = %s",
4621 val
? "TRUE" : "FALSE");
4625 prt_time_access(XDR
*xdr
)
4629 if (!xdr_nfstime4(xdr
, &val
))
4630 longjmp(xdr_err
, 1);
4631 sprintf(get_line(0, 0), "Last Access Time = %s",
4632 format_time(val
.seconds
, val
.nseconds
));
4636 prt_time_access_set(XDR
*xdr
)
4640 if (!xdr_settime4(xdr
, &val
))
4641 longjmp(xdr_err
, 1);
4642 if (val
.set_it
== SET_TO_CLIENT_TIME4
) {
4643 sprintf(get_line(0, 0), "Access Time = %s (set to client time)",
4644 format_time(val
.settime4_u
.time
.seconds
,
4645 val
.settime4_u
.time
.nseconds
));
4646 } else if (val
.set_it
== SET_TO_SERVER_TIME4
) {
4647 sprintf(get_line(0, 0), "Access Time (set to server time)");
4649 longjmp(xdr_err
, 1);
4653 prt_time_backup(XDR
*xdr
)
4657 if (!xdr_nfstime4(xdr
, &val
))
4658 longjmp(xdr_err
, 1);
4659 sprintf(get_line(0, 0), "Last Backup Time = %s",
4660 format_time(val
.seconds
, val
.nseconds
));
4664 prt_time_create(XDR
*xdr
)
4668 if (!xdr_nfstime4(xdr
, &val
))
4669 longjmp(xdr_err
, 1);
4670 sprintf(get_line(0, 0), "Creation Time = %s",
4671 format_time(val
.seconds
, val
.nseconds
));
4675 prt_time_delta(XDR
*xdr
)
4679 if (!xdr_nfstime4(xdr
, &val
))
4680 longjmp(xdr_err
, 1);
4681 sprintf(get_line(0, 0), "Server Time Granularity = %lld.%09d sec",
4682 val
.seconds
, val
.nseconds
);
4686 prt_time_metadata(XDR
*xdr
)
4690 if (!xdr_nfstime4(xdr
, &val
))
4691 longjmp(xdr_err
, 1);
4692 sprintf(get_line(0, 0), "Last Metadata Change Time = %s",
4693 format_time(val
.seconds
, val
.nseconds
));
4697 prt_time_modify(XDR
*xdr
)
4701 if (!xdr_nfstime4(xdr
, &val
))
4702 longjmp(xdr_err
, 1);
4703 sprintf(get_line(0, 0), "Last Modification Time = %s",
4704 format_time(val
.seconds
, val
.nseconds
));
4708 prt_time_modify_set(XDR
*xdr
)
4712 if (!xdr_settime4(xdr
, &val
))
4713 longjmp(xdr_err
, 1);
4714 if (val
.set_it
== SET_TO_CLIENT_TIME4
) {
4715 sprintf(get_line(0, 0),
4716 "Modification Time = %s (set to client time)",
4717 format_time(val
.settime4_u
.time
.seconds
,
4718 val
.settime4_u
.time
.nseconds
));
4719 } else if (val
.set_it
== SET_TO_SERVER_TIME4
) {
4720 sprintf(get_line(0, 0),
4721 "Modification Time (set to server time)");
4723 longjmp(xdr_err
, 1);
4727 * Display the UTF8 string that is next in the XDR stream.
4731 showxdr_utf8string(char *fmt
)
4733 static utf8string string
;
4735 if (!xdr_utf8string(&xdrm
, &string
))
4736 longjmp(xdr_err
, 1);
4737 sprintf(get_line(0, 0), fmt
, utf8localize(&string
));
4738 xdr_free(xdr_utf8string
, (char *)&string
);
4742 * utf8string is defined in nfs4_prot.x as an opaque array, which means
4743 * when it is decoded into a string, the string might not have a trailing
4744 * null. Also, the string will still be encoded in UTF-8, rather than
4745 * whatever character encoding is associated with the current locale. This
4746 * routine converts a utf8string into a (null-terminated) C string. One day
4747 * it will convert into the current character encoding, too. To avoid
4748 * dealing with storage management issues, it allocates storage for each
4749 * new string, then this storage is "freed" when the packet has been
4753 #define MAX_UTF8_STRINGS 512
4755 static char *utf_buf
[MAX_UTF8_STRINGS
];
4756 static size_t utf_buflen
[MAX_UTF8_STRINGS
];
4757 static uint_t cur_utf_buf
= 0;
4760 utf8localize(utf8string
*utf8str
)
4762 size_t newsize
, oldsize
, len
;
4765 len
= utf8str
->utf8string_len
;
4768 if (cur_utf_buf
>= MAX_UTF8_STRINGS
)
4769 return ("[Too Many UTF-8 Strings]");
4771 newsize
= oldsize
= utf_buflen
[cur_utf_buf
];
4774 if (oldsize
< len
+ 1) {
4775 /* truncate opaques at NFS4_OPAQUE_LIMIT */
4776 if (len
> NFS4_OPAQUE_LIMIT
)
4777 len
= NFS4_OPAQUE_LIMIT
;
4780 if (newsize
!= oldsize
) {
4781 utf_buf
[cur_utf_buf
] = realloc(utf_buf
[cur_utf_buf
],
4783 if (utf_buf
[cur_utf_buf
] == NULL
) {
4784 pr_err("out of memory\n");
4785 utf_buflen
[cur_utf_buf
] = 0;
4788 utf_buflen
[cur_utf_buf
] = newsize
;
4791 result
= utf_buf
[cur_utf_buf
];
4792 strncpy(result
, utf8str
->utf8string_val
, len
);
4794 for (cp
= result
; cp
< result
+ len
; cp
++) {
4795 if (!isprint(*cp
)) {
4813 * adler16(): adler32 hash code shamelessly copied and mutiliated from
4814 * usr/src/uts/common/io/ppp/spppcomp/zlib.[ch]
4816 * The alg was originally created to provide a running
4817 * checksum, but we don't need that -- we just want to
4818 * chksum data described by buf,len; therefore, the first
4819 * parameter was removed (held the running checksum),
4820 * and s1/s2 are always set to their required initial
4821 * values (1 and 0). I also ripped out code which only
4822 * applied to large data sets (bufs larger than 5k). All
4823 * I wanted was their core checksum alg (which is supposed
4824 * to do really well). The v2/v3 hash alg didn't work well
4825 * at all for v4 stuff -- it produced too many collisions.
4827 * The copyright info from uts/common/io/ppp/spppcomp/zlib.[ch]
4828 * is included below.
4831 /* -----zlib.c copyright info below */
4833 * Copyright 2000 Sun Microsystems, Inc.
4834 * All rights reserved.
4836 * Updated from zlib-1.0.4 to zlib-1.1.3 by James Carlson.
4838 * This file is derived from various .h and .c files from the zlib-1.0.4
4839 * distribution by Jean-loup Gailly and Mark Adler, with some additions
4840 * by Paul Mackerras to aid in implementing Deflate compression and
4841 * decompression for PPP packets. See zlib.h for conditions of
4842 * distribution and use.
4844 * Changes that have been made include:
4845 * - added Z_PACKET_FLUSH (see zlib.h for details)
4846 * - added inflateIncomp and deflateOutputPending
4847 * - allow strm->next_out to be NULL, meaning discard the output
4849 * $Id: zlib.c,v 1.11 1998/09/13 23:37:12 paulus Exp $
4853 * adler32.c -- compute the Adler-32 checksum of a data stream
4854 * Copyright (C) 1995-1998 Mark Adler
4855 * For conditions of distribution and use, see copyright notice in zlib.h
4857 /* From: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */
4858 /* -----zlib.c copyright info above */
4860 /* -----zlib.h copyright info below */
4862 * Copyright 2000 Sun Microsystems, Inc.
4863 * All rights reserved.
4865 * Permission to use, copy, modify, and distribute this software and
4866 * its documentation is hereby granted, provided that the above
4867 * copyright notice appears in all copies.
4869 * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
4870 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
4871 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
4872 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE
4873 * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
4874 * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
4876 * This file has been altered from its original by Sun Microsystems to
4877 * fit local coding style.
4879 /* -----zlib.h copyright info above */
4881 #define DO1(buf, i) {s1 += buf[i]; s2 += s1; }
4882 #define DO2(buf, i) DO1(buf, i); DO1(buf, i+1);
4883 #define DO4(buf, i) DO2(buf, i); DO2(buf, i+2);
4884 #define DO8(buf, i) DO4(buf, i); DO4(buf, i+4);
4885 #define DO16(buf) DO8(buf, 0); DO8(buf, 8);
4888 adler16(void *p
, int len
)
4906 return ((uint32_t)(s2
^ s1
) & 0xFFFFU
);