2 * Common NFSv4 ACL handling code.
4 * Copyright (c) 2002, 2003 The Regents of the University of Michigan.
7 * Marius Aamodt Eriksen <marius@umich.edu>
8 * Jeff Sedlak <jsedlak@umich.edu>
9 * J. Bruce Fields <bfields@umich.edu>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include <linux/slab.h>
38 #include <linux/nfs_fs.h>
39 #include <linux/export.h>
43 /* mode bit translations: */
44 #define NFS4_READ_MODE (NFS4_ACE_READ_DATA)
45 #define NFS4_WRITE_MODE (NFS4_ACE_WRITE_DATA | NFS4_ACE_APPEND_DATA)
46 #define NFS4_EXECUTE_MODE NFS4_ACE_EXECUTE
47 #define NFS4_ANYONE_MODE (NFS4_ACE_READ_ATTRIBUTES | NFS4_ACE_READ_ACL | NFS4_ACE_SYNCHRONIZE)
48 #define NFS4_OWNER_MODE (NFS4_ACE_WRITE_ATTRIBUTES | NFS4_ACE_WRITE_ACL)
50 /* We don't support these bits; insist they be neither allowed nor denied */
51 #define NFS4_MASK_UNSUPP (NFS4_ACE_DELETE | NFS4_ACE_WRITE_OWNER \
52 | NFS4_ACE_READ_NAMED_ATTRS | NFS4_ACE_WRITE_NAMED_ATTRS)
54 /* flags used to simulate posix default ACLs */
55 #define NFS4_INHERITANCE_FLAGS (NFS4_ACE_FILE_INHERIT_ACE \
56 | NFS4_ACE_DIRECTORY_INHERIT_ACE)
58 #define NFS4_SUPPORTED_FLAGS (NFS4_INHERITANCE_FLAGS \
59 | NFS4_ACE_INHERIT_ONLY_ACE \
60 | NFS4_ACE_IDENTIFIER_GROUP)
62 #define MASK_EQUAL(mask1, mask2) \
63 ( ((mask1) & NFS4_ACE_MASK_ALL) == ((mask2) & NFS4_ACE_MASK_ALL) )
66 mask_from_posix(unsigned short perm, unsigned int flags)
68 int mask = NFS4_ANYONE_MODE;
70 if (flags & NFS4_ACL_OWNER)
71 mask |= NFS4_OWNER_MODE;
73 mask |= NFS4_READ_MODE;
75 mask |= NFS4_WRITE_MODE;
76 if ((perm & ACL_WRITE) && (flags & NFS4_ACL_DIR))
77 mask |= NFS4_ACE_DELETE_CHILD;
78 if (perm & ACL_EXECUTE)
79 mask |= NFS4_EXECUTE_MODE;
84 deny_mask_from_posix(unsigned short perm, u32 flags)
89 mask |= NFS4_READ_MODE;
91 mask |= NFS4_WRITE_MODE;
92 if ((perm & ACL_WRITE) && (flags & NFS4_ACL_DIR))
93 mask |= NFS4_ACE_DELETE_CHILD;
94 if (perm & ACL_EXECUTE)
95 mask |= NFS4_EXECUTE_MODE;
99 /* XXX: modify functions to return NFS errors; they're only ever
100 * used by nfs code, after all.... */
102 /* We only map from NFSv4 to POSIX ACLs when setting ACLs, when we err on the
103 * side of being more restrictive, so the mode bit mapping below is
104 * pessimistic. An optimistic version would be needed to handle DENY's,
105 * but we espect to coalesce all ALLOWs and DENYs before mapping to mode
109 low_mode_from_nfs4(u32 perm, unsigned short *mode, unsigned int flags)
111 u32 write_mode = NFS4_WRITE_MODE;
113 if (flags & NFS4_ACL_DIR)
114 write_mode |= NFS4_ACE_DELETE_CHILD;
116 if ((perm & NFS4_READ_MODE) == NFS4_READ_MODE)
118 if ((perm & write_mode) == write_mode)
120 if ((perm & NFS4_EXECUTE_MODE) == NFS4_EXECUTE_MODE)
121 *mode |= ACL_EXECUTE;
124 struct ace_container {
125 struct nfs4_ace *ace;
126 struct list_head ace_l;
129 static short ace2type(struct nfs4_ace *);
130 static void _posix_to_nfsv4_one(struct posix_acl *, struct nfs4_acl *,
134 nfs4_acl_posix_to_nfsv4(struct posix_acl *pacl, struct posix_acl *dpacl,
137 struct nfs4_acl *acl;
141 if (posix_acl_valid(pacl) < 0)
142 return ERR_PTR(-EINVAL);
143 size += 2*pacl->a_count;
146 if (posix_acl_valid(dpacl) < 0)
147 return ERR_PTR(-EINVAL);
148 size += 2*dpacl->a_count;
151 /* Allocate for worst case: one (deny, allow) pair each: */
152 acl = nfs4_acl_new(size);
154 return ERR_PTR(-ENOMEM);
157 _posix_to_nfsv4_one(pacl, acl, flags & ~NFS4_ACL_TYPE_DEFAULT);
160 _posix_to_nfsv4_one(dpacl, acl, flags | NFS4_ACL_TYPE_DEFAULT);
165 struct posix_acl_summary {
166 unsigned short owner;
167 unsigned short users;
168 unsigned short group;
169 unsigned short groups;
170 unsigned short other;
175 summarize_posix_acl(struct posix_acl *acl, struct posix_acl_summary *pas)
177 struct posix_acl_entry *pa, *pe;
180 * Only pas.users and pas.groups need initialization; previous
181 * posix_acl_valid() calls ensure that the other fields will be
182 * initialized in the following loop. But, just to placate gcc:
184 memset(pas, 0, sizeof(*pas));
187 pe = acl->a_entries + acl->a_count;
189 FOREACH_ACL_ENTRY(pa, acl, pe) {
192 pas->owner = pa->e_perm;
195 pas->group = pa->e_perm;
198 pas->users |= pa->e_perm;
201 pas->groups |= pa->e_perm;
204 pas->other = pa->e_perm;
207 pas->mask = pa->e_perm;
211 /* We'll only care about effective permissions: */
212 pas->users &= pas->mask;
213 pas->group &= pas->mask;
214 pas->groups &= pas->mask;
217 /* We assume the acl has been verified with posix_acl_valid. */
219 _posix_to_nfsv4_one(struct posix_acl *pacl, struct nfs4_acl *acl,
222 struct posix_acl_entry *pa, *group_owner_entry;
223 struct nfs4_ace *ace;
224 struct posix_acl_summary pas;
226 int eflag = ((flags & NFS4_ACL_TYPE_DEFAULT) ?
227 NFS4_INHERITANCE_FLAGS | NFS4_ACE_INHERIT_ONLY_ACE : 0);
229 BUG_ON(pacl->a_count < 3);
230 summarize_posix_acl(pacl, &pas);
232 pa = pacl->a_entries;
233 ace = acl->aces + acl->naces;
235 /* We could deny everything not granted by the owner: */
238 * but it is equivalent (and simpler) to deny only what is not
239 * granted by later entries:
241 deny &= pas.users | pas.group | pas.groups | pas.other;
243 ace->type = NFS4_ACE_ACCESS_DENIED_ACE_TYPE;
245 ace->access_mask = deny_mask_from_posix(deny, flags);
246 ace->whotype = NFS4_ACL_WHO_OWNER;
251 ace->type = NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE;
253 ace->access_mask = mask_from_posix(pa->e_perm, flags | NFS4_ACL_OWNER);
254 ace->whotype = NFS4_ACL_WHO_OWNER;
259 while (pa->e_tag == ACL_USER) {
260 deny = ~(pa->e_perm & pas.mask);
261 deny &= pas.groups | pas.group | pas.other;
263 ace->type = NFS4_ACE_ACCESS_DENIED_ACE_TYPE;
265 ace->access_mask = deny_mask_from_posix(deny, flags);
266 ace->whotype = NFS4_ACL_WHO_NAMED;
267 ace->who_uid = pa->e_uid;
271 ace->type = NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE;
273 ace->access_mask = mask_from_posix(pa->e_perm & pas.mask,
275 ace->whotype = NFS4_ACL_WHO_NAMED;
276 ace->who_uid = pa->e_uid;
282 /* In the case of groups, we apply allow ACEs first, then deny ACEs,
283 * since a user can be in more than one group. */
287 group_owner_entry = pa;
289 ace->type = NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE;
291 ace->access_mask = mask_from_posix(pas.group, flags);
292 ace->whotype = NFS4_ACL_WHO_GROUP;
297 while (pa->e_tag == ACL_GROUP) {
298 ace->type = NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE;
299 ace->flag = eflag | NFS4_ACE_IDENTIFIER_GROUP;
300 ace->access_mask = mask_from_posix(pa->e_perm & pas.mask,
302 ace->whotype = NFS4_ACL_WHO_NAMED;
303 ace->who_gid = pa->e_gid;
311 pa = group_owner_entry;
313 deny = ~pas.group & pas.other;
315 ace->type = NFS4_ACE_ACCESS_DENIED_ACE_TYPE;
317 ace->access_mask = deny_mask_from_posix(deny, flags);
318 ace->whotype = NFS4_ACL_WHO_GROUP;
324 while (pa->e_tag == ACL_GROUP) {
325 deny = ~(pa->e_perm & pas.mask);
328 ace->type = NFS4_ACE_ACCESS_DENIED_ACE_TYPE;
329 ace->flag = eflag | NFS4_ACE_IDENTIFIER_GROUP;
330 ace->access_mask = deny_mask_from_posix(deny, flags);
331 ace->whotype = NFS4_ACL_WHO_NAMED;
332 ace->who_gid = pa->e_gid;
339 if (pa->e_tag == ACL_MASK)
341 ace->type = NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE;
343 ace->access_mask = mask_from_posix(pa->e_perm, flags);
344 ace->whotype = NFS4_ACL_WHO_EVERYONE;
349 pace_gt(struct posix_acl_entry *pace1, struct posix_acl_entry *pace2)
351 if (pace1->e_tag != pace2->e_tag)
352 return pace1->e_tag > pace2->e_tag;
353 if (pace1->e_tag == ACL_USER)
354 return uid_gt(pace1->e_uid, pace2->e_uid);
355 if (pace1->e_tag == ACL_GROUP)
356 return gid_gt(pace1->e_gid, pace2->e_gid);
361 sort_pacl_range(struct posix_acl *pacl, int start, int end) {
363 struct posix_acl_entry tmp;
365 /* We just do a bubble sort; easy to do in place, and we're not
366 * expecting acl's to be long enough to justify anything more. */
369 for (i = start; i < end; i++) {
370 if (pace_gt(&pacl->a_entries[i],
371 &pacl->a_entries[i+1])) {
373 tmp = pacl->a_entries[i];
374 pacl->a_entries[i] = pacl->a_entries[i+1];
375 pacl->a_entries[i+1] = tmp;
382 sort_pacl(struct posix_acl *pacl)
384 /* posix_acl_valid requires that users and groups be in order
388 /* no users or groups */
389 if (!pacl || pacl->a_count <= 4)
393 while (pacl->a_entries[i].e_tag == ACL_USER)
395 sort_pacl_range(pacl, 1, i-1);
397 BUG_ON(pacl->a_entries[i].e_tag != ACL_GROUP_OBJ);
399 while (pacl->a_entries[j].e_tag == ACL_GROUP)
401 sort_pacl_range(pacl, i, j-1);
406 * While processing the NFSv4 ACE, this maintains bitmasks representing
407 * which permission bits have been allowed and which denied to a given
409 struct posix_ace_state {
414 struct posix_user_ace_state {
419 struct posix_ace_state perms;
422 struct posix_ace_state_array {
424 struct posix_user_ace_state aces[];
428 * While processing the NFSv4 ACE, this maintains the partial permissions
429 * calculated so far: */
431 struct posix_acl_state {
433 struct posix_ace_state owner;
434 struct posix_ace_state group;
435 struct posix_ace_state other;
436 struct posix_ace_state everyone;
437 struct posix_ace_state mask; /* Deny unused in this case */
438 struct posix_ace_state_array *users;
439 struct posix_ace_state_array *groups;
443 init_state(struct posix_acl_state *state, int cnt)
447 memset(state, 0, sizeof(struct posix_acl_state));
450 * In the worst case, each individual acl could be for a distinct
451 * named user or group, but we don't no which, so we allocate
452 * enough space for either:
454 alloc = sizeof(struct posix_ace_state_array)
455 + cnt*sizeof(struct posix_user_ace_state);
456 state->users = kzalloc(alloc, GFP_KERNEL);
459 state->groups = kzalloc(alloc, GFP_KERNEL);
460 if (!state->groups) {
468 free_state(struct posix_acl_state *state) {
470 kfree(state->groups);
473 static inline void add_to_mask(struct posix_acl_state *state, struct posix_ace_state *astate)
475 state->mask.allow |= astate->allow;
479 * Certain bits (SYNCHRONIZE, DELETE, WRITE_OWNER, READ/WRITE_NAMED_ATTRS,
480 * READ_ATTRIBUTES, READ_ACL) are currently unenforceable and don't translate
481 * to traditional read/write/execute permissions.
483 * It's problematic to reject acls that use certain mode bits, because it
484 * places the burden on users to learn the rules about which bits one
485 * particular server sets, without giving the user a lot of help--we return an
486 * error that could mean any number of different things. To make matters
487 * worse, the problematic bits might be introduced by some application that's
488 * automatically mapping from some other acl model.
490 * So wherever possible we accept anything, possibly erring on the side of
491 * denying more permissions than necessary.
493 * However we do reject *explicit* DENY's of a few bits representing
494 * permissions we could never deny:
497 static inline int check_deny(u32 mask, int isowner)
499 if (mask & (NFS4_ACE_READ_ATTRIBUTES | NFS4_ACE_READ_ACL))
503 if (mask & (NFS4_ACE_WRITE_ATTRIBUTES | NFS4_ACE_WRITE_ACL))
508 static struct posix_acl *
509 posix_state_to_acl(struct posix_acl_state *state, unsigned int flags)
511 struct posix_acl_entry *pace;
512 struct posix_acl *pacl;
517 * ACLs with no ACEs are treated differently in the inheritable
518 * and effective cases: when there are no inheritable ACEs,
519 * calls ->set_acl with a NULL ACL structure.
521 if (state->empty && (flags & NFS4_ACL_TYPE_DEFAULT))
525 * When there are no effective ACEs, the following will end
526 * up setting a 3-element effective posix ACL with all
529 nace = 4 + state->users->n + state->groups->n;
530 pacl = posix_acl_alloc(nace, GFP_KERNEL);
532 return ERR_PTR(-ENOMEM);
534 pace = pacl->a_entries;
535 pace->e_tag = ACL_USER_OBJ;
536 error = check_deny(state->owner.deny, 1);
539 low_mode_from_nfs4(state->owner.allow, &pace->e_perm, flags);
541 for (i=0; i < state->users->n; i++) {
543 pace->e_tag = ACL_USER;
544 error = check_deny(state->users->aces[i].perms.deny, 0);
547 low_mode_from_nfs4(state->users->aces[i].perms.allow,
548 &pace->e_perm, flags);
549 pace->e_uid = state->users->aces[i].uid;
550 add_to_mask(state, &state->users->aces[i].perms);
554 pace->e_tag = ACL_GROUP_OBJ;
555 error = check_deny(state->group.deny, 0);
558 low_mode_from_nfs4(state->group.allow, &pace->e_perm, flags);
559 add_to_mask(state, &state->group);
561 for (i=0; i < state->groups->n; i++) {
563 pace->e_tag = ACL_GROUP;
564 error = check_deny(state->groups->aces[i].perms.deny, 0);
567 low_mode_from_nfs4(state->groups->aces[i].perms.allow,
568 &pace->e_perm, flags);
569 pace->e_gid = state->groups->aces[i].gid;
570 add_to_mask(state, &state->groups->aces[i].perms);
574 pace->e_tag = ACL_MASK;
575 low_mode_from_nfs4(state->mask.allow, &pace->e_perm, flags);
578 pace->e_tag = ACL_OTHER;
579 error = check_deny(state->other.deny, 0);
582 low_mode_from_nfs4(state->other.allow, &pace->e_perm, flags);
586 posix_acl_release(pacl);
587 return ERR_PTR(error);
590 static inline void allow_bits(struct posix_ace_state *astate, u32 mask)
592 /* Allow all bits in the mask not already denied: */
593 astate->allow |= mask & ~astate->deny;
596 static inline void deny_bits(struct posix_ace_state *astate, u32 mask)
598 /* Deny all bits in the mask not already allowed: */
599 astate->deny |= mask & ~astate->allow;
602 static int find_uid(struct posix_acl_state *state, kuid_t uid)
604 struct posix_ace_state_array *a = state->users;
607 for (i = 0; i < a->n; i++)
608 if (uid_eq(a->aces[i].uid, uid))
612 a->aces[i].uid = uid;
613 a->aces[i].perms.allow = state->everyone.allow;
614 a->aces[i].perms.deny = state->everyone.deny;
619 static int find_gid(struct posix_acl_state *state, kgid_t gid)
621 struct posix_ace_state_array *a = state->groups;
624 for (i = 0; i < a->n; i++)
625 if (gid_eq(a->aces[i].gid, gid))
629 a->aces[i].gid = gid;
630 a->aces[i].perms.allow = state->everyone.allow;
631 a->aces[i].perms.deny = state->everyone.deny;
636 static void deny_bits_array(struct posix_ace_state_array *a, u32 mask)
640 for (i=0; i < a->n; i++)
641 deny_bits(&a->aces[i].perms, mask);
644 static void allow_bits_array(struct posix_ace_state_array *a, u32 mask)
648 for (i=0; i < a->n; i++)
649 allow_bits(&a->aces[i].perms, mask);
652 static void process_one_v4_ace(struct posix_acl_state *state,
653 struct nfs4_ace *ace)
655 u32 mask = ace->access_mask;
660 switch (ace2type(ace)) {
662 if (ace->type == NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE) {
663 allow_bits(&state->owner, mask);
665 deny_bits(&state->owner, mask);
669 i = find_uid(state, ace->who_uid);
670 if (ace->type == NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE) {
671 allow_bits(&state->users->aces[i].perms, mask);
673 deny_bits(&state->users->aces[i].perms, mask);
674 mask = state->users->aces[i].perms.deny;
675 deny_bits(&state->owner, mask);
679 if (ace->type == NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE) {
680 allow_bits(&state->group, mask);
682 deny_bits(&state->group, mask);
683 mask = state->group.deny;
684 deny_bits(&state->owner, mask);
685 deny_bits(&state->everyone, mask);
686 deny_bits_array(state->users, mask);
687 deny_bits_array(state->groups, mask);
691 i = find_gid(state, ace->who_gid);
692 if (ace->type == NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE) {
693 allow_bits(&state->groups->aces[i].perms, mask);
695 deny_bits(&state->groups->aces[i].perms, mask);
696 mask = state->groups->aces[i].perms.deny;
697 deny_bits(&state->owner, mask);
698 deny_bits(&state->group, mask);
699 deny_bits(&state->everyone, mask);
700 deny_bits_array(state->users, mask);
701 deny_bits_array(state->groups, mask);
705 if (ace->type == NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE) {
706 allow_bits(&state->owner, mask);
707 allow_bits(&state->group, mask);
708 allow_bits(&state->other, mask);
709 allow_bits(&state->everyone, mask);
710 allow_bits_array(state->users, mask);
711 allow_bits_array(state->groups, mask);
713 deny_bits(&state->owner, mask);
714 deny_bits(&state->group, mask);
715 deny_bits(&state->other, mask);
716 deny_bits(&state->everyone, mask);
717 deny_bits_array(state->users, mask);
718 deny_bits_array(state->groups, mask);
723 int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *acl, struct posix_acl **pacl,
724 struct posix_acl **dpacl, unsigned int flags)
726 struct posix_acl_state effective_acl_state, default_acl_state;
727 struct nfs4_ace *ace;
730 ret = init_state(&effective_acl_state, acl->naces);
733 ret = init_state(&default_acl_state, acl->naces);
737 for (ace = acl->aces; ace < acl->aces + acl->naces; ace++) {
738 if (ace->type != NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE &&
739 ace->type != NFS4_ACE_ACCESS_DENIED_ACE_TYPE)
741 if (ace->flag & ~NFS4_SUPPORTED_FLAGS)
743 if ((ace->flag & NFS4_INHERITANCE_FLAGS) == 0) {
744 process_one_v4_ace(&effective_acl_state, ace);
747 if (!(flags & NFS4_ACL_DIR))
750 * Note that when only one of FILE_INHERIT or DIRECTORY_INHERIT
751 * is set, we're effectively turning on the other. That's OK,
752 * according to rfc 3530.
754 process_one_v4_ace(&default_acl_state, ace);
756 if (!(ace->flag & NFS4_ACE_INHERIT_ONLY_ACE))
757 process_one_v4_ace(&effective_acl_state, ace);
759 *pacl = posix_state_to_acl(&effective_acl_state, flags);
761 ret = PTR_ERR(*pacl);
765 *dpacl = posix_state_to_acl(&default_acl_state,
766 flags | NFS4_ACL_TYPE_DEFAULT);
767 if (IS_ERR(*dpacl)) {
768 ret = PTR_ERR(*dpacl);
770 posix_acl_release(*pacl);
778 free_state(&default_acl_state);
780 free_state(&effective_acl_state);
785 ace2type(struct nfs4_ace *ace)
787 switch (ace->whotype) {
788 case NFS4_ACL_WHO_NAMED:
789 return (ace->flag & NFS4_ACE_IDENTIFIER_GROUP ?
790 ACL_GROUP : ACL_USER);
791 case NFS4_ACL_WHO_OWNER:
793 case NFS4_ACL_WHO_GROUP:
794 return ACL_GROUP_OBJ;
795 case NFS4_ACL_WHO_EVERYONE:
802 EXPORT_SYMBOL(nfs4_acl_posix_to_nfsv4);
803 EXPORT_SYMBOL(nfs4_acl_nfsv4_to_posix);
808 struct nfs4_acl *acl;
810 acl = kmalloc(sizeof(*acl) + n*sizeof(struct nfs4_ace), GFP_KERNEL);
824 .stringlen = sizeof("OWNER@") - 1,
825 .type = NFS4_ACL_WHO_OWNER,
829 .stringlen = sizeof("GROUP@") - 1,
830 .type = NFS4_ACL_WHO_GROUP,
833 .string = "EVERYONE@",
834 .stringlen = sizeof("EVERYONE@") - 1,
835 .type = NFS4_ACL_WHO_EVERYONE,
840 nfs4_acl_get_whotype(char *p, u32 len)
844 for (i = 0; i < ARRAY_SIZE(s2t_map); i++) {
845 if (s2t_map[i].stringlen == len &&
846 0 == memcmp(s2t_map[i].string, p, len))
847 return s2t_map[i].type;
849 return NFS4_ACL_WHO_NAMED;
853 nfs4_acl_write_who(int who, char *p)
857 for (i = 0; i < ARRAY_SIZE(s2t_map); i++) {
858 if (s2t_map[i].type == who) {
859 memcpy(p, s2t_map[i].string, s2t_map[i].stringlen);
860 return s2t_map[i].stringlen;
867 EXPORT_SYMBOL(nfs4_acl_new);
868 EXPORT_SYMBOL(nfs4_acl_get_whotype);
869 EXPORT_SYMBOL(nfs4_acl_write_who);