2007-08-08 17:21:14

by Andreas Gruenbacher

[permalink] [raw]
Subject: [RFC 05/10] Use vfs_permission instead of file_permission in sys_fchdir

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

Signed-off-by: Andreas Gruenbacher <[email protected]>

---
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);
out:


2007-08-08 19:26:51

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [RFC 05/10] Use vfs_permission instead of file_permission in sys_fchdir

On Wed, Aug 08, 2007 at 07:16:27PM +0200, Andreas Gruenbacher wrote:
> Create a temporary vfs_lookup object, and use vfs_permission instead
> of file_permission() in sys_fchdir().

NACK for the same reason as the previous one.