2007-08-08 17:21:29

by Andreas Gruenbacher

[permalink] [raw]
Subject: [RFC 06/10] Use vfs_permission instead of file_permission in do_path_lookup

Switch from file_permission() to vfs_permission() in do_path_lookup()
by filling in the vfs_lookup in nd slightly earlier.

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

---
fs/namei.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1133,25 +1133,23 @@ static int fastcall do_path_lookup(int d
nd->lookup.path.dentry = dget(fs->pwd);
read_unlock(&fs->lock);
} else {
- struct dentry *dentry;
-
file = fget_light(dfd, &fput_needed);
retval = -EBADF;
if (!file)
goto out_fail;

- dentry = file->f_path.dentry;
+ nd->lookup.path = file->f_path;

retval = -ENOTDIR;
- if (!S_ISDIR(dentry->d_inode->i_mode))
+ if (!S_ISDIR(nd->lookup.path.dentry->d_inode->i_mode))
goto fput_fail;

- retval = file_permission(file, MAY_EXEC);
+ retval = vfs_permission(&nd->lookup, MAY_EXEC);
if (retval)
goto fput_fail;

- nd->lookup.path.mnt = mntget(file->f_path.mnt);
- nd->lookup.path.dentry = dget(dentry);
+ mntget(nd->lookup.path.mnt);
+ dget(nd->lookup.path.dentry);

fput_light(file, fput_needed);
}


2007-08-08 19:27:46

by Christoph Hellwig

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

On Wed, Aug 08, 2007 at 07:16:28PM +0200, Andreas Gruenbacher wrote:
> Switch from file_permission() to vfs_permission() in do_path_lookup()
> by filling in the vfs_lookup in nd slightly earlier.

While this one is okay because it is part of a lookup operation.