|
@@ -207,40 +207,53 @@ static int init_symlink(struct inode * inode)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int create_dir(struct kobject * k, struct dentry * p,
|
|
|
- const char * n, struct dentry ** d)
|
|
|
+static int create_dir(struct kobject *kobj, struct dentry *parent,
|
|
|
+ const char *name, struct dentry **p_dentry)
|
|
|
{
|
|
|
int error;
|
|
|
umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
|
|
|
+ struct dentry *dentry;
|
|
|
+ struct sysfs_dirent *sd;
|
|
|
|
|
|
- mutex_lock(&p->d_inode->i_mutex);
|
|
|
- *d = lookup_one_len(n, p, strlen(n));
|
|
|
- if (!IS_ERR(*d)) {
|
|
|
- if (sysfs_dirent_exist(p->d_fsdata, n))
|
|
|
- error = -EEXIST;
|
|
|
- else
|
|
|
- error = sysfs_make_dirent(p->d_fsdata, *d, k, mode,
|
|
|
- SYSFS_DIR);
|
|
|
- if (!error) {
|
|
|
- error = sysfs_create(*d, mode, init_dir);
|
|
|
- if (!error) {
|
|
|
- inc_nlink(p->d_inode);
|
|
|
- (*d)->d_op = &sysfs_dentry_ops;
|
|
|
- d_rehash(*d);
|
|
|
- }
|
|
|
- }
|
|
|
- if (error && (error != -EEXIST)) {
|
|
|
- struct sysfs_dirent *sd = (*d)->d_fsdata;
|
|
|
- if (sd) {
|
|
|
- list_del_init(&sd->s_sibling);
|
|
|
- sysfs_put(sd);
|
|
|
- }
|
|
|
- d_drop(*d);
|
|
|
- }
|
|
|
- dput(*d);
|
|
|
- } else
|
|
|
- error = PTR_ERR(*d);
|
|
|
- mutex_unlock(&p->d_inode->i_mutex);
|
|
|
+ mutex_lock(&parent->d_inode->i_mutex);
|
|
|
+
|
|
|
+ dentry = lookup_one_len(name, parent, strlen(name));
|
|
|
+ if (IS_ERR(dentry)) {
|
|
|
+ error = PTR_ERR(dentry);
|
|
|
+ goto out_unlock;
|
|
|
+ }
|
|
|
+
|
|
|
+ error = -EEXIST;
|
|
|
+ if (sysfs_dirent_exist(parent->d_fsdata, name))
|
|
|
+ goto out_dput;
|
|
|
+
|
|
|
+ error = sysfs_make_dirent(parent->d_fsdata, dentry, kobj, mode,
|
|
|
+ SYSFS_DIR);
|
|
|
+ if (error)
|
|
|
+ goto out_drop;
|
|
|
+
|
|
|
+ error = sysfs_create(dentry, mode, init_dir);
|
|
|
+ if (error)
|
|
|
+ goto out_sput;
|
|
|
+
|
|
|
+ inc_nlink(parent->d_inode);
|
|
|
+ dentry->d_op = &sysfs_dentry_ops;
|
|
|
+ d_rehash(dentry);
|
|
|
+
|
|
|
+ *p_dentry = dentry;
|
|
|
+ error = 0;
|
|
|
+ goto out_dput;
|
|
|
+
|
|
|
+ out_sput:
|
|
|
+ sd = dentry->d_fsdata;
|
|
|
+ list_del_init(&sd->s_sibling);
|
|
|
+ sysfs_put(sd);
|
|
|
+ out_drop:
|
|
|
+ d_drop(dentry);
|
|
|
+ out_dput:
|
|
|
+ dput(dentry);
|
|
|
+ out_unlock:
|
|
|
+ mutex_unlock(&parent->d_inode->i_mutex);
|
|
|
return error;
|
|
|
}
|
|
|
|