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]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/param.h>
30 #include <sys/types.h>
31 #include <sys/systm.h>
33 #include <sys/vnode.h>
35 #include <sys/dirent.h>
37 #include <sys/stream.h>
38 #include <sys/strsubr.h>
39 #include <sys/debug.h>
40 #include <sys/t_lock.h>
43 #include <rpc/types.h>
47 #include <nfs/nfs_clnt.h>
48 #include <nfs/nfs_acl.h>
51 * These are the XDR routines used to serialize and deserialize
52 * the various structures passed as parameters accross the network
53 * between ACL clients and servers.
57 xdr_uid(XDR
*xdrs
, uid32_t
*objp
)
59 if (!xdr_u_int(xdrs
, objp
))
65 xdr_o_mode(XDR
*xdrs
, o_mode
*objp
)
68 if (!xdr_u_short(xdrs
, (ushort_t
*)objp
))
74 xdr_aclent(XDR
*xdrs
, aclent_t
*objp
)
77 if (!xdr_int(xdrs
, &objp
->a_type
))
79 if (!xdr_uid(xdrs
, &objp
->a_id
))
81 if (!xdr_o_mode(xdrs
, &objp
->a_perm
))
87 xdr_secattr(XDR
*xdrs
, vsecattr_t
*objp
)
91 if (!xdr_u_int(xdrs
, &objp
->vsa_mask
))
93 if (!xdr_int(xdrs
, &objp
->vsa_aclcnt
))
95 if (objp
->vsa_aclentp
!= NULL
)
96 count
= (uint_t
)objp
->vsa_aclcnt
;
99 if (!xdr_array(xdrs
, (char **)&objp
->vsa_aclentp
, &count
,
100 NFS_ACL_MAX_ENTRIES
, sizeof (aclent_t
), (xdrproc_t
)xdr_aclent
))
102 if (count
!= 0 && count
!= (uint_t
)objp
->vsa_aclcnt
) {
104 * Assign the actual array size to vsa_aclcnt before
107 objp
->vsa_aclcnt
= (int)count
;
110 if (!xdr_int(xdrs
, &objp
->vsa_dfaclcnt
))
112 if (objp
->vsa_dfaclentp
!= NULL
)
113 count
= (uint_t
)objp
->vsa_dfaclcnt
;
116 if (!xdr_array(xdrs
, (char **)&objp
->vsa_dfaclentp
, &count
,
117 NFS_ACL_MAX_ENTRIES
, sizeof (aclent_t
), (xdrproc_t
)xdr_aclent
))
119 if (count
!= 0 && count
!= (uint_t
)objp
->vsa_dfaclcnt
) {
121 * Assign the actual array size to vsa_dfaclcnt before
124 objp
->vsa_dfaclcnt
= (int)count
;
131 xdr_GETACL2args(XDR
*xdrs
, GETACL2args
*objp
)
134 if (!xdr_fhandle(xdrs
, &objp
->fh
))
136 if (!xdr_u_int(xdrs
, &objp
->mask
))
141 xdr_fastGETACL2args(XDR
*xdrs
, GETACL2args
**objpp
)
144 #ifdef _LITTLE_ENDIAN
148 if (xdrs
->x_op
!= XDR_DECODE
)
151 ptr
= XDR_INLINE(xdrs
, RNDUP(sizeof (GETACL2args
)));
153 *objpp
= (GETACL2args
*)ptr
;
154 #ifdef _LITTLE_ENDIAN
155 objp
= (GETACL2args
*)ptr
;
156 objp
->mask
= ntohl(objp
->mask
);
165 xdr_GETACL2resok(XDR
*xdrs
, GETACL2resok
*objp
)
168 if (!xdr_fattr(xdrs
, &objp
->attr
))
170 if (!xdr_secattr(xdrs
, &objp
->acl
))
176 xdr_GETACL2res(XDR
*xdrs
, GETACL2res
*objp
)
179 if (!xdr_enum(xdrs
, (enum_t
*)&objp
->status
))
181 switch (objp
->status
) {
183 if (!xdr_GETACL2resok(xdrs
, &objp
->resok
))
191 xdr_SETACL2args(XDR
*xdrs
, SETACL2args
*objp
)
194 if (!xdr_fhandle(xdrs
, &objp
->fh
))
196 if (!xdr_secattr(xdrs
, &objp
->acl
))
202 xdr_SETACL2resok(XDR
*xdrs
, SETACL2resok
*objp
)
205 if (!xdr_fattr(xdrs
, &objp
->attr
))
209 #ifdef _LITTLE_ENDIAN
211 xdr_fastSETACL2resok(XDR
*xdrs
, SETACL2resok
*objp
)
214 if (!xdr_fastfattr(xdrs
, &objp
->attr
))
221 xdr_SETACL2res(XDR
*xdrs
, SETACL2res
*objp
)
224 if (!xdr_enum(xdrs
, (enum_t
*)&objp
->status
))
226 switch (objp
->status
) {
228 if (!xdr_SETACL2resok(xdrs
, &objp
->resok
))
234 #ifdef _LITTLE_ENDIAN
236 xdr_fastSETACL2res(XDR
*xdrs
, SETACL2res
*objp
)
239 if (!xdr_fastenum(xdrs
, (enum_t
*)&objp
->status
))
241 switch (objp
->status
) {
243 if (!xdr_fastSETACL2resok(xdrs
, &objp
->resok
))
252 xdr_GETATTR2args(XDR
*xdrs
, GETATTR2args
*objp
)
255 if (!xdr_fhandle(xdrs
, &objp
->fh
))
260 xdr_fastGETATTR2args(XDR
*xdrs
, GETATTR2args
**objpp
)
264 if (xdrs
->x_op
!= XDR_DECODE
)
267 ptr
= XDR_INLINE(xdrs
, RNDUP(sizeof (GETATTR2args
)));
269 *objpp
= (GETATTR2args
*)ptr
;
277 xdr_GETATTR2resok(XDR
*xdrs
, GETATTR2resok
*objp
)
280 if (!xdr_fattr(xdrs
, &objp
->attr
))
284 #ifdef _LITTLE_ENDIAN
286 xdr_fastGETATTR2resok(XDR
*xdrs
, GETATTR2resok
*objp
)
289 if (!xdr_fastfattr(xdrs
, &objp
->attr
))
296 xdr_GETATTR2res(XDR
*xdrs
, GETATTR2res
*objp
)
299 if (!xdr_enum(xdrs
, (enum_t
*)&objp
->status
))
301 switch (objp
->status
) {
303 if (!xdr_GETATTR2resok(xdrs
, &objp
->resok
))
309 #ifdef _LITTLE_ENDIAN
311 xdr_fastGETATTR2res(XDR
*xdrs
, GETATTR2res
*objp
)
314 if (!xdr_fastenum(xdrs
, (enum_t
*)&objp
->status
))
316 switch (objp
->status
) {
318 if (!xdr_fastGETATTR2resok(xdrs
, &objp
->resok
))
327 xdr_ACCESS2args(XDR
*xdrs
, ACCESS2args
*objp
)
330 if (!xdr_fhandle(xdrs
, &objp
->fh
))
332 if (!xdr_uint32(xdrs
, &objp
->access
))
337 xdr_fastACCESS2args(XDR
*xdrs
, ACCESS2args
**objpp
)
340 #ifdef _LITTLE_ENDIAN
344 if (xdrs
->x_op
!= XDR_DECODE
)
347 ptr
= XDR_INLINE(xdrs
, RNDUP(sizeof (ACCESS2args
)));
349 *objpp
= (ACCESS2args
*)ptr
;
350 #ifdef _LITTLE_ENDIAN
351 objp
= (ACCESS2args
*)ptr
;
352 objp
->access
= ntohl(objp
->access
);
361 xdr_ACCESS2resok(XDR
*xdrs
, ACCESS2resok
*objp
)
364 if (!xdr_fattr(xdrs
, &objp
->attr
))
366 if (!xdr_uint32(xdrs
, &objp
->access
))
370 #ifdef _LITTLE_ENDIAN
372 xdr_fastACCESS2resok(XDR
*xdrs
, ACCESS2resok
*objp
)
375 if (!xdr_fastfattr(xdrs
, &objp
->attr
))
377 objp
->access
= ntohl(objp
->access
);
383 xdr_ACCESS2res(XDR
*xdrs
, ACCESS2res
*objp
)
386 if (!xdr_enum(xdrs
, (enum_t
*)&objp
->status
))
388 switch (objp
->status
) {
390 if (!xdr_ACCESS2resok(xdrs
, &objp
->resok
))
396 #ifdef _LITTLE_ENDIAN
398 xdr_fastACCESS2res(XDR
*xdrs
, ACCESS2res
*objp
)
401 if (!xdr_fastenum(xdrs
, (enum_t
*)&objp
->status
))
403 switch (objp
->status
) {
405 if (!xdr_fastACCESS2resok(xdrs
, &objp
->resok
))
414 xdr_GETXATTRDIR2args(XDR
*xdrs
, GETXATTRDIR2args
*objp
)
416 if (!xdr_fhandle(xdrs
, &objp
->fh
))
418 if (!xdr_bool(xdrs
, &objp
->create
))
424 xdr_GETXATTRDIR2resok(XDR
*xdrs
, GETXATTRDIR2resok
*objp
)
426 if (!xdr_fhandle(xdrs
, &objp
->fh
))
428 if (!xdr_fattr(xdrs
, &objp
->attr
))
434 xdr_GETXATTRDIR2res(XDR
*xdrs
, GETXATTRDIR2res
*objp
)
436 if (!xdr_enum(xdrs
, (enum_t
*)&objp
->status
))
438 switch (objp
->status
) {
440 if (!xdr_GETXATTRDIR2resok(xdrs
, &objp
->resok
))
448 xdr_GETACL3args(XDR
*xdrs
, GETACL3args
*objp
)
451 switch (xdrs
->x_op
) {
454 if (!xdr_nfs_fh3(xdrs
, &objp
->fh
))
458 if (!xdr_nfs_fh3_server(xdrs
, &objp
->fh
))
462 if (!xdr_u_int(xdrs
, &objp
->mask
))
468 xdr_GETACL3resok(XDR
*xdrs
, GETACL3resok
*objp
)
471 if (!xdr_post_op_attr(xdrs
, &objp
->attr
))
473 if (!xdr_secattr(xdrs
, &objp
->acl
))
479 xdr_GETACL3resfail(XDR
*xdrs
, GETACL3resfail
*objp
)
482 if (!xdr_post_op_attr(xdrs
, &objp
->attr
))
488 xdr_GETACL3res(XDR
*xdrs
, GETACL3res
*objp
)
491 if (!xdr_enum(xdrs
, (enum_t
*)&objp
->status
))
493 switch (objp
->status
) {
495 if (!xdr_GETACL3resok(xdrs
, &objp
->resok
))
499 if (!xdr_GETACL3resfail(xdrs
, &objp
->resfail
))
507 xdr_SETACL3args(XDR
*xdrs
, SETACL3args
*objp
)
510 switch (xdrs
->x_op
) {
513 if (!xdr_nfs_fh3(xdrs
, &objp
->fh
))
517 if (!xdr_nfs_fh3_server(xdrs
, &objp
->fh
))
521 if (!xdr_secattr(xdrs
, &objp
->acl
))
527 xdr_SETACL3resok(XDR
*xdrs
, SETACL3resok
*objp
)
530 if (!xdr_post_op_attr(xdrs
, &objp
->attr
))
536 xdr_SETACL3resfail(XDR
*xdrs
, SETACL3resfail
*objp
)
539 if (!xdr_post_op_attr(xdrs
, &objp
->attr
))
545 xdr_SETACL3res(XDR
*xdrs
, SETACL3res
*objp
)
548 if (!xdr_enum(xdrs
, (enum_t
*)&objp
->status
))
550 switch (objp
->status
) {
552 if (!xdr_SETACL3resok(xdrs
, &objp
->resok
))
556 if (!xdr_SETACL3resfail(xdrs
, &objp
->resfail
))
564 xdr_GETXATTRDIR3args(XDR
*xdrs
, GETXATTRDIR3args
*objp
)
566 switch (xdrs
->x_op
) {
569 if (!xdr_nfs_fh3(xdrs
, &objp
->fh
))
573 if (!xdr_nfs_fh3_server(xdrs
, &objp
->fh
))
577 if (!xdr_bool(xdrs
, &objp
->create
))
583 xdr_GETXATTRDIR3resok(XDR
*xdrs
, GETXATTRDIR3resok
*objp
)
585 switch (xdrs
->x_op
) {
587 if (!xdr_nfs_fh3_server(xdrs
, &objp
->fh
))
592 if (!xdr_nfs_fh3(xdrs
, &objp
->fh
))
596 if (!xdr_post_op_attr(xdrs
, &objp
->attr
))
602 xdr_GETXATTRDIR3res(XDR
*xdrs
, GETXATTRDIR3res
*objp
)
604 if (!xdr_enum(xdrs
, (enum_t
*)&objp
->status
))
606 switch (objp
->status
) {
608 if (!xdr_GETXATTRDIR3resok(xdrs
, &objp
->resok
))