[RFC 05/10] Use vfs_permission instead of file_permission in sys_fchdir

Andreas Gruenbacher
2007-08-08T17:21:14Z

[-- Attachment #1: sys_fchdir.diff --]
[-- Type: text/plain, Size: 1100 bytes --]

Create a temporary vfs_lookup object, and use vfs_permission instead
of file_permission() in sys_fchdir().

Signed-off-by: Andreas Gruenbacher <ag@bestbits.at>

---
fs/open.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

--- a/fs/open.c
+++ b/fs/open.c
@@ -501,9 +501,7 @@ out:
asmlinkage long sys_fchdir(unsigned int fd)
{
struct file *file;
- struct dentry *dentry;
- struct inode *inode;
- struct vfsmount *mnt;
+ struct vfs_lookup lookup;
int error;

error = -EBADF;
@@ -511,17 +509,16 @@ asmlinkage long sys_fchdir(unsigned int
if (!file)
goto out;

- dentry = file->f_path.dentry;
- mnt = file->f_path.mnt;
- inode = dentry->d_inode;
+ lookup.path = file->f_path;
+ lookup.flags = 0;

error = -ENOTDIR;
- if (!S_ISDIR(inode->i_mode))
+ if (!S_ISDIR(lookup.path.dentry->d_inode->i_mode))
goto out_putf;

- error = file_permission(file, MAY_EXEC);
+ error = vfs_permission(&lookup, MAY_EXEC);
if (!error)
- set_fs_pwd(current->fs, mnt, dentry);
+ set_fs_pwd(current->fs, lookup.path.mnt, lookup.path.dentry);
out_putf:
fput(file);