4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1993-1997 by Sun Microsystems, Inc.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 * Convert ACL to/from permission bits
38 acltomode(aclent_t
*aclbufp
, int nentries
, mode_t
*modep
)
42 unsigned long grpmode
;
48 if (aclcheck(aclbufp
, nentries
, &which
) != 0) {
50 return (-1); /* errno is set in aclcheck() */
52 for (tp
= aclbufp
; nentries
--; tp
++) {
53 if (tp
->a_type
== USER_OBJ
) {
57 *modep
|= (mode
<< 6);
60 if (tp
->a_type
== GROUP_OBJ
) {
66 if (tp
->a_type
== CLASS_OBJ
) {
71 *modep
|= (mask
<< 3);
74 if (tp
->a_type
== OTHER_OBJ
) {
79 continue; /* we may break here if it is sorted */
83 *modep
|= (grpmode
<< 3);
89 aclfrommode(aclent_t
*aclbufp
, int nentries
, mode_t
*modep
)
98 if (aclcheck(aclbufp
, nentries
, &which
) != 0) {
100 return (-1); /* errno is set in aclcheck() */
102 for (tp
= aclbufp
; nentries
--; tp
++) {
103 if (tp
->a_type
== USER_OBJ
) {
104 mode
= (*modep
& 0700);
105 tp
->a_perm
= (mode
>> 6);
108 if (tp
->a_type
== GROUP_OBJ
) {
109 grpmode
= (*modep
& 070);
113 if (tp
->a_type
== CLASS_OBJ
) {
115 mode
= (*modep
& 070);
116 tp
->a_perm
= (mode
>> 3);
119 if (tp
->a_type
== OTHER_OBJ
) {
120 mode
= (*modep
& 07);
121 tp
->a_perm
= (o_mode_t
)mode
;
122 continue; /* we may break here if it is sorted */
126 savp
->a_perm
= (grpmode
>> 3);