diff mbox

[PoC,3/7] Create sysfs files under sb

Message ID 1461895282-4941-4-git-send-email-rgoldwyn@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Goldwyn Rodrigues April 29, 2016, 2:01 a.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

This would create sysfs entries under /sys/fs/<fstype>/<s_id>.
fill_super() must initialize attrs. This may not be the best
way to do it. Suggestions?

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/super.c         | 8 ++++----
 include/linux/fs.h | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/fs/super.c b/fs/super.c
index 5f5e25d..f6cef10 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -179,12 +179,12 @@  static const struct sysfs_ops sb_sysfs_ops = {
 
 static int register_kobj(struct super_block *sb)
 {
-	struct kobj_type *ktype;
-       	ktype = kzalloc(sizeof(struct kobj_type), GFP_USER);
-	if (IS_ERR(ktype))
-		return PTR_ERR(ktype);
+	struct kobj_type *ktype = kzalloc(sizeof(struct kobj_type), GFP_USER);
+	if (!ktype)
+		return -ENOMEM;
 	ktype->sysfs_ops = &sb_sysfs_ops;
 	ktype->release = release_super;
+	ktype->default_attrs = sb->s_attr;
 	sb->s_kobj.kset = sb->s_type->kset;
 	return kobject_init_and_add(&sb->s_kobj, ktype, NULL,
 			"%s", sb->s_id);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e6b9d89..59b84a8 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1441,6 +1441,7 @@  struct super_block {
 	spinlock_t		s_inode_list_lock ____cacheline_aligned_in_smp;
 	struct list_head	s_inodes;	/* all inodes */
 	struct kobject		s_kobj;
+	struct attribute	**s_attr;
 };
 
 extern struct timespec current_fs_time(struct super_block *sb);