aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/posix_acl.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/posix_acl.h')
-rw-r--r--include/linux/posix_acl.h100
1 files changed, 33 insertions, 67 deletions
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 7931efe71175..3e96a6a76103 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -39,9 +39,6 @@ struct posix_acl_entry {
39 union { 39 union {
40 kuid_t e_uid; 40 kuid_t e_uid;
41 kgid_t e_gid; 41 kgid_t e_gid;
42#ifndef CONFIG_UIDGID_STRICT_TYPE_CHECKS
43 unsigned int e_id;
44#endif
45 }; 42 };
46}; 43};
47 44
@@ -88,91 +85,60 @@ extern int posix_acl_valid(const struct posix_acl *);
88extern int posix_acl_permission(struct inode *, const struct posix_acl *, int); 85extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
89extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t); 86extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
90extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *); 87extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);
91extern int posix_acl_create(struct posix_acl **, gfp_t, umode_t *); 88extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
92extern int posix_acl_chmod(struct posix_acl **, gfp_t, umode_t); 89extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
93 90
94extern struct posix_acl *get_posix_acl(struct inode *, int); 91extern struct posix_acl *get_posix_acl(struct inode *, int);
95extern int set_posix_acl(struct inode *, int, struct posix_acl *); 92extern int set_posix_acl(struct inode *, int, struct posix_acl *);
96 93
97#ifdef CONFIG_FS_POSIX_ACL 94#ifdef CONFIG_FS_POSIX_ACL
98static inline struct posix_acl **acl_by_type(struct inode *inode, int type) 95extern int posix_acl_chmod(struct inode *, umode_t);
96extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
97 struct posix_acl **);
98
99extern int simple_set_acl(struct inode *, struct posix_acl *, int);
100extern int simple_acl_create(struct inode *, struct inode *);
101
102struct posix_acl **acl_by_type(struct inode *inode, int type);
103struct posix_acl *get_cached_acl(struct inode *inode, int type);
104struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type);
105void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl);
106void forget_cached_acl(struct inode *inode, int type);
107void forget_all_cached_acls(struct inode *inode);
108
109static inline void cache_no_acl(struct inode *inode)
99{ 110{
100 switch (type) { 111 inode->i_acl = NULL;
101 case ACL_TYPE_ACCESS: 112 inode->i_default_acl = NULL;
102 return &inode->i_acl;
103 case ACL_TYPE_DEFAULT:
104 return &inode->i_default_acl;
105 default:
106 BUG();
107 }
108} 113}
109 114#else
110static inline struct posix_acl *get_cached_acl(struct inode *inode, int type) 115static inline int posix_acl_chmod(struct inode *inode, umode_t mode)
111{ 116{
112 struct posix_acl **p = acl_by_type(inode, type); 117 return 0;
113 struct posix_acl *acl = ACCESS_ONCE(*p);
114 if (acl) {
115 spin_lock(&inode->i_lock);
116 acl = *p;
117 if (acl != ACL_NOT_CACHED)
118 acl = posix_acl_dup(acl);
119 spin_unlock(&inode->i_lock);
120 }
121 return acl;
122} 118}
123 119
124static inline struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type) 120#define simple_set_acl NULL
121
122static inline int simple_acl_create(struct inode *dir, struct inode *inode)
125{ 123{
126 return rcu_dereference(*acl_by_type(inode, type)); 124 return 0;
127} 125}
128 126static inline void cache_no_acl(struct inode *inode)
129static inline void set_cached_acl(struct inode *inode,
130 int type,
131 struct posix_acl *acl)
132{ 127{
133 struct posix_acl **p = acl_by_type(inode, type);
134 struct posix_acl *old;
135 spin_lock(&inode->i_lock);
136 old = *p;
137 rcu_assign_pointer(*p, posix_acl_dup(acl));
138 spin_unlock(&inode->i_lock);
139 if (old != ACL_NOT_CACHED)
140 posix_acl_release(old);
141} 128}
142 129
143static inline void forget_cached_acl(struct inode *inode, int type) 130static inline int posix_acl_create(struct inode *inode, umode_t *mode,
131 struct posix_acl **default_acl, struct posix_acl **acl)
144{ 132{
145 struct posix_acl **p = acl_by_type(inode, type); 133 *default_acl = *acl = NULL;
146 struct posix_acl *old; 134 return 0;
147 spin_lock(&inode->i_lock);
148 old = *p;
149 *p = ACL_NOT_CACHED;
150 spin_unlock(&inode->i_lock);
151 if (old != ACL_NOT_CACHED)
152 posix_acl_release(old);
153} 135}
154 136
155static inline void forget_all_cached_acls(struct inode *inode) 137static inline void forget_all_cached_acls(struct inode *inode)
156{ 138{
157 struct posix_acl *old_access, *old_default;
158 spin_lock(&inode->i_lock);
159 old_access = inode->i_acl;
160 old_default = inode->i_default_acl;
161 inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
162 spin_unlock(&inode->i_lock);
163 if (old_access != ACL_NOT_CACHED)
164 posix_acl_release(old_access);
165 if (old_default != ACL_NOT_CACHED)
166 posix_acl_release(old_default);
167} 139}
168#endif 140#endif /* CONFIG_FS_POSIX_ACL */
169 141
170static inline void cache_no_acl(struct inode *inode) 142struct posix_acl *get_acl(struct inode *inode, int type);
171{
172#ifdef CONFIG_FS_POSIX_ACL
173 inode->i_acl = NULL;
174 inode->i_default_acl = NULL;
175#endif
176}
177 143
178#endif /* __LINUX_POSIX_ACL_H */ 144#endif /* __LINUX_POSIX_ACL_H */