diff options
author | Christoph Hellwig <hch@lst.de> | 2005-11-09 00:35:04 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:55:58 -0500 |
commit | e4543eddfd3bf3e0d625841377fa695a519edfd4 (patch) | |
tree | b62546cb0038529bd8cd583333c556ad799f2081 /fs/namei.c | |
parent | e4a53cbabc81f04e24a5570b4aa6a6384bdbfc67 (diff) |
[PATCH] add a vfs_permission helper
Most permission() calls have a struct nameidata * available. This helper
takes that as an argument and thus makes sure we pass it down for lookup
intents and prepares for per-mount read-only support where we need a struct
vfsmount for checking whether a file is writeable.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/fs/namei.c b/fs/namei.c index b3f8a1966c9c..25e4ab4ce8b7 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -256,6 +256,21 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) | |||
256 | return security_inode_permission(inode, mask, nd); | 256 | return security_inode_permission(inode, mask, nd); |
257 | } | 257 | } |
258 | 258 | ||
259 | /** | ||
260 | * vfs_permission - check for access rights to a given path | ||
261 | * @nd: lookup result that describes the path | ||
262 | * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) | ||
263 | * | ||
264 | * Used to check for read/write/execute permissions on a path. | ||
265 | * We use "fsuid" for this, letting us set arbitrary permissions | ||
266 | * for filesystem access without changing the "normal" uids which | ||
267 | * are used for other things. | ||
268 | */ | ||
269 | int vfs_permission(struct nameidata *nd, int mask) | ||
270 | { | ||
271 | return permission(nd->dentry->d_inode, mask, nd); | ||
272 | } | ||
273 | |||
259 | /* | 274 | /* |
260 | * get_write_access() gets write permission for a file. | 275 | * get_write_access() gets write permission for a file. |
261 | * put_write_access() releases this write permission. | 276 | * put_write_access() releases this write permission. |
@@ -765,9 +780,8 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd) | |||
765 | 780 | ||
766 | nd->flags |= LOOKUP_CONTINUE; | 781 | nd->flags |= LOOKUP_CONTINUE; |
767 | err = exec_permission_lite(inode, nd); | 782 | err = exec_permission_lite(inode, nd); |
768 | if (err == -EAGAIN) { | 783 | if (err == -EAGAIN) |
769 | err = permission(inode, MAY_EXEC, nd); | 784 | err = vfs_permission(nd, MAY_EXEC); |
770 | } | ||
771 | if (err) | 785 | if (err) |
772 | break; | 786 | break; |
773 | 787 | ||
@@ -1407,7 +1421,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag) | |||
1407 | if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE)) | 1421 | if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE)) |
1408 | return -EISDIR; | 1422 | return -EISDIR; |
1409 | 1423 | ||
1410 | error = permission(inode, acc_mode, nd); | 1424 | error = vfs_permission(nd, acc_mode); |
1411 | if (error) | 1425 | if (error) |
1412 | return error; | 1426 | return error; |
1413 | 1427 | ||
@@ -2536,6 +2550,7 @@ EXPORT_SYMBOL(path_lookup); | |||
2536 | EXPORT_SYMBOL(path_release); | 2550 | EXPORT_SYMBOL(path_release); |
2537 | EXPORT_SYMBOL(path_walk); | 2551 | EXPORT_SYMBOL(path_walk); |
2538 | EXPORT_SYMBOL(permission); | 2552 | EXPORT_SYMBOL(permission); |
2553 | EXPORT_SYMBOL(vfs_permission); | ||
2539 | EXPORT_SYMBOL(unlock_rename); | 2554 | EXPORT_SYMBOL(unlock_rename); |
2540 | EXPORT_SYMBOL(vfs_create); | 2555 | EXPORT_SYMBOL(vfs_create); |
2541 | EXPORT_SYMBOL(vfs_follow_link); | 2556 | EXPORT_SYMBOL(vfs_follow_link); |