2 File: linux/posix_acl.h
4 (C) 2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
8 #ifndef __LINUX_POSIX_ACL_H
9 #define __LINUX_POSIX_ACL_H
11 #include <linux/bug.h>
12 #include <linux/slab.h>
13 #include <linux/rcupdate.h>
14 #include <uapi/linux/posix_acl.h>
16 struct posix_acl_entry {
18 unsigned short e_perm;
27 struct rcu_head a_rcu;
29 struct posix_acl_entry a_entries[0];
32 #define FOREACH_ACL_ENTRY(pa, acl, pe) \
33 for(pa=(acl)->a_entries, pe=pa+(acl)->a_count; pa<pe; pa++)
37 * Duplicate an ACL handle.
39 static inline struct posix_acl *
40 posix_acl_dup(struct posix_acl *acl)
43 atomic_inc(&acl->a_refcount);
51 posix_acl_release(struct posix_acl *acl)
53 if (acl && atomic_dec_and_test(&acl->a_refcount))
54 kfree_rcu(acl, a_rcu);
60 extern void posix_acl_init(struct posix_acl *, int);
61 extern struct posix_acl *posix_acl_alloc(int, gfp_t);
62 extern int posix_acl_valid(struct user_namespace *, const struct posix_acl *);
63 extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
64 extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
65 extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);
66 extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
67 extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
69 extern struct posix_acl *get_posix_acl(struct inode *, int);
70 extern int set_posix_acl(struct inode *, int, struct posix_acl *);
72 #ifdef CONFIG_FS_POSIX_ACL
73 extern int posix_acl_chmod(struct inode *, umode_t);
74 extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
77 extern int simple_set_acl(struct inode *, struct posix_acl *, int);
78 extern int simple_acl_create(struct inode *, struct inode *);
80 struct posix_acl *get_cached_acl(struct inode *inode, int type);
81 struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type);
82 void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl);
83 void forget_cached_acl(struct inode *inode, int type);
84 void forget_all_cached_acls(struct inode *inode);
86 static inline void cache_no_acl(struct inode *inode)
89 inode->i_default_acl = NULL;
92 static inline int posix_acl_chmod(struct inode *inode, umode_t mode)
97 #define simple_set_acl NULL
99 static inline int simple_acl_create(struct inode *dir, struct inode *inode)
103 static inline void cache_no_acl(struct inode *inode)
107 static inline int posix_acl_create(struct inode *inode, umode_t *mode,
108 struct posix_acl **default_acl, struct posix_acl **acl)
110 *default_acl = *acl = NULL;
114 static inline void forget_all_cached_acls(struct inode *inode)
117 #endif /* CONFIG_FS_POSIX_ACL */
119 struct posix_acl *get_acl(struct inode *inode, int type);
121 #endif /* __LINUX_POSIX_ACL_H */