Commit 49705b77 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] sanitize lookup_hash prototype

->permission and ->lookup have a struct nameidata * argument these days to
pass down lookup intents.  Unfortunately some callers of lookup_hash don't
actually pass this one down.  For lookup_one_len() we don't have a struct
nameidata to pass down, but as this function is a library function only
used by filesystem code this is an acceptable limitation.  All other
callers should pass down the nameidata, so this patch changes the
lookup_hash interface to only take a struct nameidata argument and derives
the other two arguments to __lookup_hash from it.  All callers already have
the nameidata argument available so this is not a problem.

At the same time I'd like to deprecate the lookup_hash interface as there
are better exported interfaces for filesystem usage.  Before it can
actually be removed I need to fix up rpc_pipefs.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Ram Pai <linuxram@us.ibm.com>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Al Viro <viro@ftp.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8c744fb8
...@@ -118,3 +118,10 @@ Why: This interface has been obsoleted by the new layer3-independent ...@@ -118,3 +118,10 @@ Why: This interface has been obsoleted by the new layer3-independent
to link against API-compatible library on top of libnfnetlink_queue to link against API-compatible library on top of libnfnetlink_queue
instead of the current 'libipq'. instead of the current 'libipq'.
Who: Harald Welte <laforge@netfilter.org> Who: Harald Welte <laforge@netfilter.org>
---------------------------
What: EXPORT_SYMBOL(lookup_hash)
When: January 2006
Why: Too low-level interface. Use lookup_one_len or lookup_create instead.
Who: Christoph Hellwig <hch@lst.de>
...@@ -1204,9 +1204,9 @@ out: ...@@ -1204,9 +1204,9 @@ out:
return dentry; return dentry;
} }
struct dentry * lookup_hash(struct qstr *name, struct dentry * base) struct dentry * lookup_hash(struct nameidata *nd)
{ {
return __lookup_hash(name, base, NULL); return __lookup_hash(&nd->last, nd->dentry, nd);
} }
/* SMP-safe */ /* SMP-safe */
...@@ -1230,7 +1230,7 @@ struct dentry * lookup_one_len(const char * name, struct dentry * base, int len) ...@@ -1230,7 +1230,7 @@ struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
} }
this.hash = end_name_hash(hash); this.hash = end_name_hash(hash);
return lookup_hash(&this, base); return __lookup_hash(&this, base, NULL);
access: access:
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
} }
...@@ -1563,7 +1563,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) ...@@ -1563,7 +1563,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
dir = nd->dentry; dir = nd->dentry;
nd->flags &= ~LOOKUP_PARENT; nd->flags &= ~LOOKUP_PARENT;
down(&dir->d_inode->i_sem); down(&dir->d_inode->i_sem);
path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); path.dentry = lookup_hash(nd);
path.mnt = nd->mnt; path.mnt = nd->mnt;
do_last: do_last:
...@@ -1665,7 +1665,7 @@ do_link: ...@@ -1665,7 +1665,7 @@ do_link:
} }
dir = nd->dentry; dir = nd->dentry;
down(&dir->d_inode->i_sem); down(&dir->d_inode->i_sem);
path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); path.dentry = lookup_hash(nd);
path.mnt = nd->mnt; path.mnt = nd->mnt;
__putname(nd->last.name); __putname(nd->last.name);
goto do_last; goto do_last;
...@@ -1697,7 +1697,7 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir) ...@@ -1697,7 +1697,7 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir)
/* /*
* Do the final lookup. * Do the final lookup.
*/ */
dentry = lookup_hash(&nd->last, nd->dentry); dentry = lookup_hash(nd);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
goto fail; goto fail;
...@@ -1932,7 +1932,7 @@ asmlinkage long sys_rmdir(const char __user * pathname) ...@@ -1932,7 +1932,7 @@ asmlinkage long sys_rmdir(const char __user * pathname)
goto exit1; goto exit1;
} }
down(&nd.dentry->d_inode->i_sem); down(&nd.dentry->d_inode->i_sem);
dentry = lookup_hash(&nd.last, nd.dentry); dentry = lookup_hash(&nd);
error = PTR_ERR(dentry); error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) { if (!IS_ERR(dentry)) {
error = vfs_rmdir(nd.dentry->d_inode, dentry); error = vfs_rmdir(nd.dentry->d_inode, dentry);
...@@ -2001,7 +2001,7 @@ asmlinkage long sys_unlink(const char __user * pathname) ...@@ -2001,7 +2001,7 @@ asmlinkage long sys_unlink(const char __user * pathname)
if (nd.last_type != LAST_NORM) if (nd.last_type != LAST_NORM)
goto exit1; goto exit1;
down(&nd.dentry->d_inode->i_sem); down(&nd.dentry->d_inode->i_sem);
dentry = lookup_hash(&nd.last, nd.dentry); dentry = lookup_hash(&nd);
error = PTR_ERR(dentry); error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) { if (!IS_ERR(dentry)) {
/* Why not before? Because we want correct error value */ /* Why not before? Because we want correct error value */
...@@ -2344,7 +2344,7 @@ static inline int do_rename(const char * oldname, const char * newname) ...@@ -2344,7 +2344,7 @@ static inline int do_rename(const char * oldname, const char * newname)
trap = lock_rename(new_dir, old_dir); trap = lock_rename(new_dir, old_dir);
old_dentry = lookup_hash(&oldnd.last, old_dir); old_dentry = lookup_hash(&oldnd);
error = PTR_ERR(old_dentry); error = PTR_ERR(old_dentry);
if (IS_ERR(old_dentry)) if (IS_ERR(old_dentry))
goto exit3; goto exit3;
...@@ -2364,7 +2364,7 @@ static inline int do_rename(const char * oldname, const char * newname) ...@@ -2364,7 +2364,7 @@ static inline int do_rename(const char * oldname, const char * newname)
error = -EINVAL; error = -EINVAL;
if (old_dentry == trap) if (old_dentry == trap)
goto exit4; goto exit4;
new_dentry = lookup_hash(&newnd.last, new_dir); new_dentry = lookup_hash(&newnd);
error = PTR_ERR(new_dentry); error = PTR_ERR(new_dentry);
if (IS_ERR(new_dentry)) if (IS_ERR(new_dentry))
goto exit4; goto exit4;
......
...@@ -74,7 +74,7 @@ extern struct file *nameidata_to_filp(struct nameidata *nd, int flags); ...@@ -74,7 +74,7 @@ extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
extern void release_open_intent(struct nameidata *); extern void release_open_intent(struct nameidata *);
extern struct dentry * lookup_one_len(const char *, struct dentry *, int); extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
extern struct dentry * lookup_hash(struct qstr *, struct dentry *); extern struct dentry * lookup_hash(struct nameidata *);
extern int follow_down(struct vfsmount **, struct dentry **); extern int follow_down(struct vfsmount **, struct dentry **);
extern int follow_up(struct vfsmount **, struct dentry **); extern int follow_up(struct vfsmount **, struct dentry **);
......
...@@ -603,7 +603,7 @@ rpc_lookup_negative(char *path, struct nameidata *nd) ...@@ -603,7 +603,7 @@ rpc_lookup_negative(char *path, struct nameidata *nd)
return ERR_PTR(error); return ERR_PTR(error);
dir = nd->dentry->d_inode; dir = nd->dentry->d_inode;
down(&dir->i_sem); down(&dir->i_sem);
dentry = lookup_hash(&nd->last, nd->dentry); dentry = lookup_hash(nd);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
goto out_err; goto out_err;
if (dentry->d_inode) { if (dentry->d_inode) {
...@@ -665,7 +665,7 @@ rpc_rmdir(char *path) ...@@ -665,7 +665,7 @@ rpc_rmdir(char *path)
return error; return error;
dir = nd.dentry->d_inode; dir = nd.dentry->d_inode;
down(&dir->i_sem); down(&dir->i_sem);
dentry = lookup_hash(&nd.last, nd.dentry); dentry = lookup_hash(&nd);
if (IS_ERR(dentry)) { if (IS_ERR(dentry)) {
error = PTR_ERR(dentry); error = PTR_ERR(dentry);
goto out_release; goto out_release;
...@@ -726,7 +726,7 @@ rpc_unlink(char *path) ...@@ -726,7 +726,7 @@ rpc_unlink(char *path)
return error; return error;
dir = nd.dentry->d_inode; dir = nd.dentry->d_inode;
down(&dir->i_sem); down(&dir->i_sem);
dentry = lookup_hash(&nd.last, nd.dentry); dentry = lookup_hash(&nd);
if (IS_ERR(dentry)) { if (IS_ERR(dentry)) {
error = PTR_ERR(dentry); error = PTR_ERR(dentry);
goto out_release; goto out_release;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment