aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/sysfs.c')
-rw-r--r--fs/btrfs/sysfs.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 1671c731800e..cd673ca9bb98 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -189,12 +189,29 @@ static struct kset btrfs_kset;
189int btrfs_sysfs_add_super(struct btrfs_fs_info *fs) 189int btrfs_sysfs_add_super(struct btrfs_fs_info *fs)
190{ 190{
191 int error; 191 int error;
192 char *name;
193 char c;
194 int len = strlen(fs->sb->s_id) + 1;
195 int i;
196
197 name = kmalloc(len, GFP_NOFS);
198 if (!name) {
199 error = -ENOMEM;
200 goto fail;
201 }
202
203 for (i = 0; i < len; i++) {
204 c = fs->sb->s_id[i];
205 if (c == '/' || c == '\\')
206 c = '!';
207 name[i] = c;
208 }
209 name[len] = '\0';
192 210
193 fs->super_kobj.kset = &btrfs_kset; 211 fs->super_kobj.kset = &btrfs_kset;
194 fs->super_kobj.ktype = &btrfs_super_ktype; 212 fs->super_kobj.ktype = &btrfs_super_ktype;
195 213
196 error = kobject_set_name(&fs->super_kobj, "%s", 214 error = kobject_set_name(&fs->super_kobj, "%s", name);
197 fs->sb->s_id);
198 if (error) 215 if (error)
199 goto fail; 216 goto fail;
200 217
@@ -202,9 +219,11 @@ int btrfs_sysfs_add_super(struct btrfs_fs_info *fs)
202 if (error) 219 if (error)
203 goto fail; 220 goto fail;
204 221
222 kfree(name);
205 return 0; 223 return 0;
206 224
207fail: 225fail:
226 kfree(name);
208 printk(KERN_ERR "btrfs: sysfs creation for super failed\n"); 227 printk(KERN_ERR "btrfs: sysfs creation for super failed\n");
209 return error; 228 return error;
210} 229}