aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-20 11:31:30 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:43:16 -0400
commit178ea73521d64ba41d7aa5488fb9f549c6d4507d (patch)
tree7fb6bfb6483577752e307a5bb2e3905658d44294 /fs/namei.c
parent07b8ce1ee87d291ff564c02cf878fae973317a52 (diff)
kill check_acl callback of generic_permission()
its value depends only on inode and does not change; we might as well store it in ->i_op->check_acl and be done with that. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/namei.c b/fs/namei.c
index d286cbc3f3e5..c5af0f37e67d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -176,9 +176,9 @@ EXPORT_SYMBOL(putname);
176/* 176/*
177 * This does basic POSIX ACL permission checking 177 * This does basic POSIX ACL permission checking
178 */ 178 */
179static int acl_permission_check(struct inode *inode, int mask, unsigned int flags, 179static int acl_permission_check(struct inode *inode, int mask, unsigned int flags)
180 int (*check_acl)(struct inode *inode, int mask, unsigned int flags))
181{ 180{
181 int (*check_acl)(struct inode *inode, int mask, unsigned int flags);
182 unsigned int mode = inode->i_mode; 182 unsigned int mode = inode->i_mode;
183 183
184 mask &= MAY_READ | MAY_WRITE | MAY_EXEC; 184 mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
@@ -189,6 +189,7 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag
189 if (current_fsuid() == inode->i_uid) 189 if (current_fsuid() == inode->i_uid)
190 mode >>= 6; 190 mode >>= 6;
191 else { 191 else {
192 check_acl = inode->i_op->check_acl;
192 if (IS_POSIXACL(inode) && (mode & S_IRWXG) && check_acl) { 193 if (IS_POSIXACL(inode) && (mode & S_IRWXG) && check_acl) {
193 int error = check_acl(inode, mask, flags); 194 int error = check_acl(inode, mask, flags);
194 if (error != -EAGAIN) 195 if (error != -EAGAIN)
@@ -212,7 +213,6 @@ other_perms:
212 * generic_permission - check for access rights on a Posix-like filesystem 213 * generic_permission - check for access rights on a Posix-like filesystem
213 * @inode: inode to check access rights for 214 * @inode: inode to check access rights for
214 * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) 215 * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
215 * @check_acl: optional callback to check for Posix ACLs
216 * @flags: IPERM_FLAG_ flags. 216 * @flags: IPERM_FLAG_ flags.
217 * 217 *
218 * Used to check for read/write/execute permissions on a file. 218 * Used to check for read/write/execute permissions on a file.
@@ -224,15 +224,14 @@ other_perms:
224 * request cannot be satisfied (eg. requires blocking or too much complexity). 224 * request cannot be satisfied (eg. requires blocking or too much complexity).
225 * It would then be called again in ref-walk mode. 225 * It would then be called again in ref-walk mode.
226 */ 226 */
227int generic_permission(struct inode *inode, int mask, unsigned int flags, 227int generic_permission(struct inode *inode, int mask, unsigned int flags)
228 int (*check_acl)(struct inode *inode, int mask, unsigned int flags))
229{ 228{
230 int ret; 229 int ret;
231 230
232 /* 231 /*
233 * Do the basic POSIX ACL permission checks. 232 * Do the basic POSIX ACL permission checks.
234 */ 233 */
235 ret = acl_permission_check(inode, mask, flags, check_acl); 234 ret = acl_permission_check(inode, mask, flags);
236 if (ret != -EACCES) 235 if (ret != -EACCES)
237 return ret; 236 return ret;
238 237
@@ -290,8 +289,7 @@ int inode_permission(struct inode *inode, int mask)
290 if (inode->i_op->permission) 289 if (inode->i_op->permission)
291 retval = inode->i_op->permission(inode, mask, 0); 290 retval = inode->i_op->permission(inode, mask, 0);
292 else 291 else
293 retval = generic_permission(inode, mask, 0, 292 retval = generic_permission(inode, mask, 0);
294 inode->i_op->check_acl);
295 293
296 if (retval) 294 if (retval)
297 return retval; 295 return retval;
@@ -326,8 +324,7 @@ static inline int exec_permission(struct inode *inode, unsigned int flags)
326 if (likely(!ret)) 324 if (likely(!ret))
327 goto ok; 325 goto ok;
328 } else { 326 } else {
329 ret = acl_permission_check(inode, MAY_EXEC, flags, 327 ret = acl_permission_check(inode, MAY_EXEC, flags);
330 inode->i_op->check_acl);
331 if (likely(!ret)) 328 if (likely(!ret))
332 goto ok; 329 goto ok;
333 if (ret != -EACCES) 330 if (ret != -EACCES)