aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-24 00:34:43 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-24 00:34:43 -0400
commitde80af4cc9c30318224b8520dc76a7d097e64cbd (patch)
tree0bc587a0b5433e41cd1e7feefa2359561fe71fbd /fs
parent405d2965597fd9dbd822a5a8c1c66c925a942d6e (diff)
parent5f1835da79df8607ecbd69f648b5b140b7a0b8ba (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: sysfs: don't warn on removal of a nonexistent binary file HOWTO: latest lxr url address changed HOWTO: korean translation of Documentation/HOWTO Fix Off-by-one in /sys/module/*/refcnt sysfs: fix locking in sysfs_lookup() and sysfs_rename_dir()
Diffstat (limited to 'fs')
-rw-r--r--fs/sysfs/bin.c7
-rw-r--r--fs/sysfs/dir.c21
2 files changed, 13 insertions, 15 deletions
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index 135353f8a296..5afe2a26f5d8 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -248,12 +248,7 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
248 248
249void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) 249void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
250{ 250{
251 if (sysfs_hash_and_remove(kobj->sd, attr->attr.name) < 0) { 251 sysfs_hash_and_remove(kobj->sd, attr->attr.name);
252 printk(KERN_ERR "%s: "
253 "bad dentry or inode or no such file: \"%s\"\n",
254 __FUNCTION__, attr->attr.name);
255 dump_stack();
256 }
257} 252}
258 253
259EXPORT_SYMBOL_GPL(sysfs_create_bin_file); 254EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 048e6054c2fd..83e76b3813c9 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -762,12 +762,15 @@ static int sysfs_count_nlink(struct sysfs_dirent *sd)
762static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, 762static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
763 struct nameidata *nd) 763 struct nameidata *nd)
764{ 764{
765 struct dentry *ret = NULL;
765 struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata; 766 struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata;
766 struct sysfs_dirent * sd; 767 struct sysfs_dirent * sd;
767 struct bin_attribute *bin_attr; 768 struct bin_attribute *bin_attr;
768 struct inode *inode; 769 struct inode *inode;
769 int found = 0; 770 int found = 0;
770 771
772 mutex_lock(&sysfs_mutex);
773
771 for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) { 774 for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) {
772 if (sysfs_type(sd) && 775 if (sysfs_type(sd) &&
773 !strcmp(sd->s_name, dentry->d_name.name)) { 776 !strcmp(sd->s_name, dentry->d_name.name)) {
@@ -778,14 +781,14 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
778 781
779 /* no such entry */ 782 /* no such entry */
780 if (!found) 783 if (!found)
781 return NULL; 784 goto out_unlock;
782 785
783 /* attach dentry and inode */ 786 /* attach dentry and inode */
784 inode = sysfs_get_inode(sd); 787 inode = sysfs_get_inode(sd);
785 if (!inode) 788 if (!inode) {
786 return ERR_PTR(-ENOMEM); 789 ret = ERR_PTR(-ENOMEM);
787 790 goto out_unlock;
788 mutex_lock(&sysfs_mutex); 791 }
789 792
790 if (inode->i_state & I_NEW) { 793 if (inode->i_state & I_NEW) {
791 /* initialize inode according to type */ 794 /* initialize inode according to type */
@@ -815,9 +818,9 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
815 sysfs_instantiate(dentry, inode); 818 sysfs_instantiate(dentry, inode);
816 sysfs_attach_dentry(sd, dentry); 819 sysfs_attach_dentry(sd, dentry);
817 820
821 out_unlock:
818 mutex_unlock(&sysfs_mutex); 822 mutex_unlock(&sysfs_mutex);
819 823 return ret;
820 return NULL;
821} 824}
822 825
823const struct inode_operations sysfs_dir_inode_operations = { 826const struct inode_operations sysfs_dir_inode_operations = {
@@ -942,6 +945,8 @@ int sysfs_rename_dir(struct kobject *kobj, struct sysfs_dirent *new_parent_sd,
942 if (error) 945 if (error)
943 goto out_drop; 946 goto out_drop;
944 947
948 mutex_lock(&sysfs_mutex);
949
945 dup_name = sd->s_name; 950 dup_name = sd->s_name;
946 sd->s_name = new_name; 951 sd->s_name = new_name;
947 952
@@ -949,8 +954,6 @@ int sysfs_rename_dir(struct kobject *kobj, struct sysfs_dirent *new_parent_sd,
949 d_add(new_dentry, NULL); 954 d_add(new_dentry, NULL);
950 d_move(sd->s_dentry, new_dentry); 955 d_move(sd->s_dentry, new_dentry);
951 956
952 mutex_lock(&sysfs_mutex);
953
954 sysfs_unlink_sibling(sd); 957 sysfs_unlink_sibling(sd);
955 sysfs_get(new_parent_sd); 958 sysfs_get(new_parent_sd);
956 sysfs_put(sd->s_parent); 959 sysfs_put(sd->s_parent);