[PATCH] reiserfs: remove kmalloc wrapper
[safe/jmp/linux-2.6] / fs / sysfs / inode.c
index 565cac1..689f7bc 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/pagemap.h>
 #include <linux/namei.h>
 #include <linux/backing-dev.h>
+#include <linux/capability.h>
 #include "sysfs.h"
 
 extern struct super_block * sysfs_sb;
@@ -85,7 +86,7 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
 
                if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
                        mode &= ~S_ISGID;
-               sd_iattr->ia_mode = mode;
+               sd_iattr->ia_mode = sd->s_mode = mode;
        }
 
        return error;
@@ -166,16 +167,6 @@ int sysfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *))
        return error;
 }
 
-struct dentry * sysfs_get_dentry(struct dentry * parent, const char * name)
-{
-       struct qstr qstr;
-
-       qstr.name = name;
-       qstr.len = strlen(name);
-       qstr.hash = full_name_hash(name,qstr.len);
-       return lookup_hash(&qstr,parent);
-}
-
 /*
  * Get the name for corresponding element represented by the given sysfs_dirent
  */
@@ -211,7 +202,7 @@ const unsigned char * sysfs_get_name(struct sysfs_dirent *sd)
 
 /*
  * Unhashes the dentry corresponding to given sysfs_dirent
- * Called with parent inode's i_sem held.
+ * Called with parent inode's i_mutex held.
  */
 void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
 {
@@ -238,7 +229,11 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name)
        struct sysfs_dirent * sd;
        struct sysfs_dirent * parent_sd = dir->d_fsdata;
 
-       down(&dir->d_inode->i_sem);
+       if (dir->d_inode == NULL)
+               /* no inode means this hasn't been made visible yet */
+               return;
+
+       mutex_lock(&dir->d_inode->i_mutex);
        list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
                if (!sd->s_element)
                        continue;
@@ -249,7 +244,5 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name)
                        break;
                }
        }
-       up(&dir->d_inode->i_sem);
+       mutex_unlock(&dir->d_inode->i_mutex);
 }
-
-