[PoC 3/7] Create sysfs files under sb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>

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@xxxxxxxx>
---
 fs/super.c         | 8 ++++----
 include/linux/fs.h | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

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);
-- 
2.6.6

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux