diff options
author | Christoph Hellwig <hch@lst.de> | 2005-11-09 00:35:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:00 -0500 |
commit | 49705b7743fd8f5632a95ec4c6547d169d27ac1f (patch) | |
tree | b209b1f94bfcfee522c44d2abef1cdb196219a52 | |
parent | 8c744fb83da0771afa04695028e3550b798dad90 (diff) |
[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: Christoph 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: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | Documentation/feature-removal-schedule.txt | 7 | ||||
-rw-r--r-- | fs/namei.c | 20 | ||||
-rw-r--r-- | include/linux/namei.h | 2 | ||||
-rw-r--r-- | net/sunrpc/rpc_pipe.c | 6 |
4 files changed, 21 insertions, 14 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 910cc9998731..66e4ca28fc0a 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -118,3 +118,10 @@ Why: This interface has been obsoleted by the new layer3-independent | |||
118 | to link against API-compatible library on top of libnfnetlink_queue | 118 | to link against API-compatible library on top of libnfnetlink_queue |
119 | instead of the current 'libipq'. | 119 | instead of the current 'libipq'. |
120 | Who: Harald Welte <laforge@netfilter.org> | 120 | Who: Harald Welte <laforge@netfilter.org> |
121 | |||
122 | --------------------------- | ||
123 | |||
124 | What: EXPORT_SYMBOL(lookup_hash) | ||
125 | When: January 2006 | ||
126 | Why: Too low-level interface. Use lookup_one_len or lookup_create instead. | ||
127 | Who: Christoph Hellwig <hch@lst.de> | ||
diff --git a/fs/namei.c b/fs/namei.c index b69f6ebadb95..f02ec0e50fca 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1204,9 +1204,9 @@ out: | |||
1204 | return dentry; | 1204 | return dentry; |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | struct dentry * lookup_hash(struct qstr *name, struct dentry * base) | 1207 | struct dentry * lookup_hash(struct nameidata *nd) |
1208 | { | 1208 | { |
1209 | return __lookup_hash(name, base, NULL); | 1209 | return __lookup_hash(&nd->last, nd->dentry, nd); |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | /* SMP-safe */ | 1212 | /* SMP-safe */ |
@@ -1230,7 +1230,7 @@ struct dentry * lookup_one_len(const char * name, struct dentry * base, int len) | |||
1230 | } | 1230 | } |
1231 | this.hash = end_name_hash(hash); | 1231 | this.hash = end_name_hash(hash); |
1232 | 1232 | ||
1233 | return lookup_hash(&this, base); | 1233 | return __lookup_hash(&this, base, NULL); |
1234 | access: | 1234 | access: |
1235 | return ERR_PTR(-EACCES); | 1235 | return ERR_PTR(-EACCES); |
1236 | } | 1236 | } |
@@ -1563,7 +1563,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) | |||
1563 | dir = nd->dentry; | 1563 | dir = nd->dentry; |
1564 | nd->flags &= ~LOOKUP_PARENT; | 1564 | nd->flags &= ~LOOKUP_PARENT; |
1565 | down(&dir->d_inode->i_sem); | 1565 | down(&dir->d_inode->i_sem); |
1566 | path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); | 1566 | path.dentry = lookup_hash(nd); |
1567 | path.mnt = nd->mnt; | 1567 | path.mnt = nd->mnt; |
1568 | 1568 | ||
1569 | do_last: | 1569 | do_last: |
@@ -1665,7 +1665,7 @@ do_link: | |||
1665 | } | 1665 | } |
1666 | dir = nd->dentry; | 1666 | dir = nd->dentry; |
1667 | down(&dir->d_inode->i_sem); | 1667 | down(&dir->d_inode->i_sem); |
1668 | path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); | 1668 | path.dentry = lookup_hash(nd); |
1669 | path.mnt = nd->mnt; | 1669 | path.mnt = nd->mnt; |
1670 | __putname(nd->last.name); | 1670 | __putname(nd->last.name); |
1671 | goto do_last; | 1671 | goto do_last; |
@@ -1697,7 +1697,7 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir) | |||
1697 | /* | 1697 | /* |
1698 | * Do the final lookup. | 1698 | * Do the final lookup. |
1699 | */ | 1699 | */ |
1700 | dentry = lookup_hash(&nd->last, nd->dentry); | 1700 | dentry = lookup_hash(nd); |
1701 | if (IS_ERR(dentry)) | 1701 | if (IS_ERR(dentry)) |
1702 | goto fail; | 1702 | goto fail; |
1703 | 1703 | ||
@@ -1932,7 +1932,7 @@ asmlinkage long sys_rmdir(const char __user * pathname) | |||
1932 | goto exit1; | 1932 | goto exit1; |
1933 | } | 1933 | } |
1934 | down(&nd.dentry->d_inode->i_sem); | 1934 | down(&nd.dentry->d_inode->i_sem); |
1935 | dentry = lookup_hash(&nd.last, nd.dentry); | 1935 | dentry = lookup_hash(&nd); |
1936 | error = PTR_ERR(dentry); | 1936 | error = PTR_ERR(dentry); |
1937 | if (!IS_ERR(dentry)) { | 1937 | if (!IS_ERR(dentry)) { |
1938 | error = vfs_rmdir(nd.dentry->d_inode, dentry); | 1938 | error = vfs_rmdir(nd.dentry->d_inode, dentry); |
@@ -2001,7 +2001,7 @@ asmlinkage long sys_unlink(const char __user * pathname) | |||
2001 | if (nd.last_type != LAST_NORM) | 2001 | if (nd.last_type != LAST_NORM) |
2002 | goto exit1; | 2002 | goto exit1; |
2003 | down(&nd.dentry->d_inode->i_sem); | 2003 | down(&nd.dentry->d_inode->i_sem); |
2004 | dentry = lookup_hash(&nd.last, nd.dentry); | 2004 | dentry = lookup_hash(&nd); |
2005 | error = PTR_ERR(dentry); | 2005 | error = PTR_ERR(dentry); |
2006 | if (!IS_ERR(dentry)) { | 2006 | if (!IS_ERR(dentry)) { |
2007 | /* Why not before? Because we want correct error value */ | 2007 | /* 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 | 2344 | ||
2345 | trap = lock_rename(new_dir, old_dir); | 2345 | trap = lock_rename(new_dir, old_dir); |
2346 | 2346 | ||
2347 | old_dentry = lookup_hash(&oldnd.last, old_dir); | 2347 | old_dentry = lookup_hash(&oldnd); |
2348 | error = PTR_ERR(old_dentry); | 2348 | error = PTR_ERR(old_dentry); |
2349 | if (IS_ERR(old_dentry)) | 2349 | if (IS_ERR(old_dentry)) |
2350 | goto exit3; | 2350 | goto exit3; |
@@ -2364,7 +2364,7 @@ static inline int do_rename(const char * oldname, const char * newname) | |||
2364 | error = -EINVAL; | 2364 | error = -EINVAL; |
2365 | if (old_dentry == trap) | 2365 | if (old_dentry == trap) |
2366 | goto exit4; | 2366 | goto exit4; |
2367 | new_dentry = lookup_hash(&newnd.last, new_dir); | 2367 | new_dentry = lookup_hash(&newnd); |
2368 | error = PTR_ERR(new_dentry); | 2368 | error = PTR_ERR(new_dentry); |
2369 | if (IS_ERR(new_dentry)) | 2369 | if (IS_ERR(new_dentry)) |
2370 | goto exit4; | 2370 | goto exit4; |
diff --git a/include/linux/namei.h b/include/linux/namei.h index 1c975d0d9e94..455660eafba9 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h | |||
@@ -74,7 +74,7 @@ extern struct file *nameidata_to_filp(struct nameidata *nd, int flags); | |||
74 | extern void release_open_intent(struct nameidata *); | 74 | extern void release_open_intent(struct nameidata *); |
75 | 75 | ||
76 | extern struct dentry * lookup_one_len(const char *, struct dentry *, int); | 76 | extern struct dentry * lookup_one_len(const char *, struct dentry *, int); |
77 | extern struct dentry * lookup_hash(struct qstr *, struct dentry *); | 77 | extern struct dentry * lookup_hash(struct nameidata *); |
78 | 78 | ||
79 | extern int follow_down(struct vfsmount **, struct dentry **); | 79 | extern int follow_down(struct vfsmount **, struct dentry **); |
80 | extern int follow_up(struct vfsmount **, struct dentry **); | 80 | extern int follow_up(struct vfsmount **, struct dentry **); |
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 4f188d0a5d11..81e00a6c19de 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -603,7 +603,7 @@ rpc_lookup_negative(char *path, struct nameidata *nd) | |||
603 | return ERR_PTR(error); | 603 | return ERR_PTR(error); |
604 | dir = nd->dentry->d_inode; | 604 | dir = nd->dentry->d_inode; |
605 | down(&dir->i_sem); | 605 | down(&dir->i_sem); |
606 | dentry = lookup_hash(&nd->last, nd->dentry); | 606 | dentry = lookup_hash(nd); |
607 | if (IS_ERR(dentry)) | 607 | if (IS_ERR(dentry)) |
608 | goto out_err; | 608 | goto out_err; |
609 | if (dentry->d_inode) { | 609 | if (dentry->d_inode) { |
@@ -665,7 +665,7 @@ rpc_rmdir(char *path) | |||
665 | return error; | 665 | return error; |
666 | dir = nd.dentry->d_inode; | 666 | dir = nd.dentry->d_inode; |
667 | down(&dir->i_sem); | 667 | down(&dir->i_sem); |
668 | dentry = lookup_hash(&nd.last, nd.dentry); | 668 | dentry = lookup_hash(&nd); |
669 | if (IS_ERR(dentry)) { | 669 | if (IS_ERR(dentry)) { |
670 | error = PTR_ERR(dentry); | 670 | error = PTR_ERR(dentry); |
671 | goto out_release; | 671 | goto out_release; |
@@ -726,7 +726,7 @@ rpc_unlink(char *path) | |||
726 | return error; | 726 | return error; |
727 | dir = nd.dentry->d_inode; | 727 | dir = nd.dentry->d_inode; |
728 | down(&dir->i_sem); | 728 | down(&dir->i_sem); |
729 | dentry = lookup_hash(&nd.last, nd.dentry); | 729 | dentry = lookup_hash(&nd); |
730 | if (IS_ERR(dentry)) { | 730 | if (IS_ERR(dentry)) { |
731 | error = PTR_ERR(dentry); | 731 | error = PTR_ERR(dentry); |
732 | goto out_release; | 732 | goto out_release; |