aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2005-06-23 03:09:12 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-23 12:45:20 -0400
commit5f45f1a78fbac3cc859ec10c5366e97d20d40fa2 (patch)
treebafacf11adbfb4eebf2d2d80d92e1fe2d9c02b18
parentac20427ef6aa63da663bdc88b71d16f7394f5e23 (diff)
[PATCH] remove duplicate get_dentry functions in various places
Various filesystem drivers have grown a get_dentry() function that's a duplicate of lookup_one_len, except that it doesn't take a maximum length argument and doesn't check for \0 or / in the passed in filename. Switch all these places to use lookup_one_len. Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Greg KH <greg@kroah.com> Cc: Paul Jackson <pj@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/usb/core/inode.c13
-rw-r--r--fs/debugfs/inode.c12
-rw-r--r--fs/sysfs/dir.c5
-rw-r--r--fs/sysfs/file.c5
-rw-r--r--fs/sysfs/group.c4
-rw-r--r--fs/sysfs/inode.c10
-rw-r--r--fs/sysfs/sysfs.h1
-rw-r--r--kernel/cpuset.c8
8 files changed, 12 insertions, 46 deletions
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index f9f9561c6bad..c3e3a95d3804 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -453,17 +453,6 @@ static int usbfs_fill_super(struct super_block *sb, void *data, int silent)
453 return 0; 453 return 0;
454} 454}
455 455
456static struct dentry * get_dentry(struct dentry *parent, const char *name)
457{
458 struct qstr qstr;
459
460 qstr.name = name;
461 qstr.len = strlen(name);
462 qstr.hash = full_name_hash(name,qstr.len);
463 return lookup_hash(&qstr,parent);
464}
465
466
467/* 456/*
468 * fs_create_by_name - create a file, given a name 457 * fs_create_by_name - create a file, given a name
469 * @name: name of file 458 * @name: name of file
@@ -496,7 +485,7 @@ static int fs_create_by_name (const char *name, mode_t mode,
496 485
497 *dentry = NULL; 486 *dentry = NULL;
498 down(&parent->d_inode->i_sem); 487 down(&parent->d_inode->i_sem);
499 *dentry = get_dentry (parent, name); 488 *dentry = lookup_one_len(name, parent, strlen(name));
500 if (!IS_ERR(dentry)) { 489 if (!IS_ERR(dentry)) {
501 if ((mode & S_IFMT) == S_IFDIR) 490 if ((mode & S_IFMT) == S_IFDIR)
502 error = usbfs_mkdir (parent->d_inode, *dentry, mode); 491 error = usbfs_mkdir (parent->d_inode, *dentry, mode);
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index b529786699e7..a86ac4aeaedb 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -110,16 +110,6 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent)
110 return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files); 110 return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files);
111} 111}
112 112
113static struct dentry * get_dentry(struct dentry *parent, const char *name)
114{
115 struct qstr qstr;
116
117 qstr.name = name;
118 qstr.len = strlen(name);
119 qstr.hash = full_name_hash(name,qstr.len);
120 return lookup_hash(&qstr,parent);
121}
122
123static struct super_block *debug_get_sb(struct file_system_type *fs_type, 113static struct super_block *debug_get_sb(struct file_system_type *fs_type,
124 int flags, const char *dev_name, 114 int flags, const char *dev_name,
125 void *data) 115 void *data)
@@ -157,7 +147,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
157 147
158 *dentry = NULL; 148 *dentry = NULL;
159 down(&parent->d_inode->i_sem); 149 down(&parent->d_inode->i_sem);
160 *dentry = get_dentry (parent, name); 150 *dentry = lookup_one_len(name, parent, strlen(name));
161 if (!IS_ERR(dentry)) { 151 if (!IS_ERR(dentry)) {
162 if ((mode & S_IFMT) == S_IFDIR) 152 if ((mode & S_IFMT) == S_IFDIR)
163 error = debugfs_mkdir(parent->d_inode, *dentry, mode); 153 error = debugfs_mkdir(parent->d_inode, *dentry, mode);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 37d7a6875d86..59734ba1ee60 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -8,6 +8,7 @@
8#include <linux/mount.h> 8#include <linux/mount.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/kobject.h> 10#include <linux/kobject.h>
11#include <linux/namei.h>
11#include "sysfs.h" 12#include "sysfs.h"
12 13
13DECLARE_RWSEM(sysfs_rename_sem); 14DECLARE_RWSEM(sysfs_rename_sem);
@@ -99,7 +100,7 @@ static int create_dir(struct kobject * k, struct dentry * p,
99 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; 100 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
100 101
101 down(&p->d_inode->i_sem); 102 down(&p->d_inode->i_sem);
102 *d = sysfs_get_dentry(p,n); 103 *d = lookup_one_len(n, p, strlen(n));
103 if (!IS_ERR(*d)) { 104 if (!IS_ERR(*d)) {
104 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR); 105 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR);
105 if (!error) { 106 if (!error) {
@@ -315,7 +316,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
315 316
316 down(&parent->d_inode->i_sem); 317 down(&parent->d_inode->i_sem);
317 318
318 new_dentry = sysfs_get_dentry(parent, new_name); 319 new_dentry = lookup_one_len(new_name, parent, strlen(new_name));
319 if (!IS_ERR(new_dentry)) { 320 if (!IS_ERR(new_dentry)) {
320 if (!new_dentry->d_inode) { 321 if (!new_dentry->d_inode) {
321 error = kobject_set_name(kobj, "%s", new_name); 322 error = kobject_set_name(kobj, "%s", new_name);
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 849aac115460..e9cfa39f4099 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -5,6 +5,7 @@
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/dnotify.h> 6#include <linux/dnotify.h>
7#include <linux/kobject.h> 7#include <linux/kobject.h>
8#include <linux/namei.h>
8#include <asm/uaccess.h> 9#include <asm/uaccess.h>
9#include <asm/semaphore.h> 10#include <asm/semaphore.h>
10 11
@@ -400,7 +401,7 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
400 int res = -ENOENT; 401 int res = -ENOENT;
401 402
402 down(&dir->d_inode->i_sem); 403 down(&dir->d_inode->i_sem);
403 victim = sysfs_get_dentry(dir, attr->name); 404 victim = lookup_one_len(attr->name, dir, strlen(attr->name));
404 if (!IS_ERR(victim)) { 405 if (!IS_ERR(victim)) {
405 /* make sure dentry is really there */ 406 /* make sure dentry is really there */
406 if (victim->d_inode && 407 if (victim->d_inode &&
@@ -443,7 +444,7 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
443 int res = -ENOENT; 444 int res = -ENOENT;
444 445
445 down(&dir->d_inode->i_sem); 446 down(&dir->d_inode->i_sem);
446 victim = sysfs_get_dentry(dir, attr->name); 447 victim = lookup_one_len(attr->name, dir, strlen(attr->name));
447 if (!IS_ERR(victim)) { 448 if (!IS_ERR(victim)) {
448 if (victim->d_inode && 449 if (victim->d_inode &&
449 (victim->d_parent->d_inode == dir->d_inode)) { 450 (victim->d_parent->d_inode == dir->d_inode)) {
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index f11ac5ea7021..122145b0895c 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -11,6 +11,7 @@
11#include <linux/kobject.h> 11#include <linux/kobject.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/dcache.h> 13#include <linux/dcache.h>
14#include <linux/namei.h>
14#include <linux/err.h> 15#include <linux/err.h>
15#include "sysfs.h" 16#include "sysfs.h"
16 17
@@ -68,7 +69,8 @@ void sysfs_remove_group(struct kobject * kobj,
68 struct dentry * dir; 69 struct dentry * dir;
69 70
70 if (grp->name) 71 if (grp->name)
71 dir = sysfs_get_dentry(kobj->dentry,grp->name); 72 dir = lookup_one_len(grp->name, kobj->dentry,
73 strlen(grp->name));
72 else 74 else
73 dir = dget(kobj->dentry); 75 dir = dget(kobj->dentry);
74 76
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 565cac1d4200..8de13bafaa76 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -166,16 +166,6 @@ int sysfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *))
166 return error; 166 return error;
167} 167}
168 168
169struct dentry * sysfs_get_dentry(struct dentry * parent, const char * name)
170{
171 struct qstr qstr;
172
173 qstr.name = name;
174 qstr.len = strlen(name);
175 qstr.hash = full_name_hash(name,qstr.len);
176 return lookup_hash(&qstr,parent);
177}
178
179/* 169/*
180 * Get the name for corresponding element represented by the given sysfs_dirent 170 * Get the name for corresponding element represented by the given sysfs_dirent
181 */ 171 */
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 29da6f5f07c8..3f8953e0e5d0 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -7,7 +7,6 @@ extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
7 7
8extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *, 8extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
9 umode_t, int); 9 umode_t, int);
10extern struct dentry * sysfs_get_dentry(struct dentry *, const char *);
11 10
12extern int sysfs_add_file(struct dentry *, const struct attribute *, int); 11extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
13extern void sysfs_hash_and_remove(struct dentry * dir, const char * name); 12extern void sysfs_hash_and_remove(struct dentry * dir, const char * name);
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 00e8f2575512..79dd929f4084 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -228,13 +228,7 @@ static struct dentry_operations cpuset_dops = {
228 228
229static struct dentry *cpuset_get_dentry(struct dentry *parent, const char *name) 229static struct dentry *cpuset_get_dentry(struct dentry *parent, const char *name)
230{ 230{
231 struct qstr qstr; 231 struct dentry *d = lookup_one_len(name, parent, strlen(name));
232 struct dentry *d;
233
234 qstr.name = name;
235 qstr.len = strlen(name);
236 qstr.hash = full_name_hash(name, qstr.len);
237 d = lookup_hash(&qstr, parent);
238 if (!IS_ERR(d)) 232 if (!IS_ERR(d))
239 d->d_op = &cpuset_dops; 233 d->d_op = &cpuset_dops;
240 return d; 234 return d;