[PoC 5/7] ocfs2: Use the sb's kset

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

 



From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>

This is just for demonstration. The original ocfs2_kset has been
used to create ocfs2_stack. Not the ideal way to do it.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
---
 fs/ocfs2/Makefile    |  3 ++-
 fs/ocfs2/stackglue.c |  3 +--
 fs/ocfs2/super.c     |  8 ++++----
 fs/ocfs2/sysfs.c     | 26 ++++++++++++++++++++++++++
 fs/ocfs2/sysfs.h     |  8 ++++++++
 5 files changed, 41 insertions(+), 7 deletions(-)
 create mode 100644 fs/ocfs2/sysfs.c
 create mode 100644 fs/ocfs2/sysfs.h

diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile
index e27e652..716ed45 100644
--- a/fs/ocfs2/Makefile
+++ b/fs/ocfs2/Makefile
@@ -41,7 +41,8 @@ ocfs2-objs := \
 	quota_local.o		\
 	quota_global.o		\
 	xattr.o			\
-	acl.o	\
+	acl.o			\
+	sysfs.o			\
 	filecheck.o
 
 ocfs2_stackglue-objs := stackglue.o
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index 13219ed..f9b45b3 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -640,8 +640,7 @@ static void ocfs2_sysfs_exit(void)
 static int ocfs2_sysfs_init(void)
 {
 	int ret;
-
-	ocfs2_kset = kset_create_and_add("ocfs2", NULL, fs_kobj);
+	ocfs2_kset = kset_create_and_add("ocfs2_stack", NULL, fs_kobj);
 	if (!ocfs2_kset)
 		return -ENOMEM;
 
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index d7cae33..b899cde 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -75,6 +75,7 @@
 
 #include "buffer_head_io.h"
 #include "filecheck.h"
+#include "sysfs.h"
 
 static struct kmem_cache *ocfs2_inode_cachep;
 struct kmem_cache *ocfs2_dquot_cachep;
@@ -1200,8 +1201,8 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
 	/* Start this when the mount is almost sure of being successful */
 	ocfs2_orphan_scan_start(osb);
 
-	/* Create filecheck sysfile /sys/fs/ocfs2/<devname>/filecheck */
-	ocfs2_filecheck_create_sysfs(sb);
+	/* Create sysfs entries */
+	ocfs2_sysfs_sb_init(sb);
 
 	return status;
 
@@ -1232,7 +1233,7 @@ static struct file_system_type ocfs2_fs_type = {
 	.name           = "ocfs2",
 	.mount          = ocfs2_mount,
 	.kill_sb        = kill_block_super,
-	.fs_flags       = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE,
+	.fs_flags       = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE|FS_CREATE_SYSFS,
 	.next           = NULL
 };
 MODULE_ALIAS_FS("ocfs2");
@@ -1653,7 +1654,6 @@ static void ocfs2_put_super(struct super_block *sb)
 
 	ocfs2_sync_blockdev(sb);
 	ocfs2_dismount_volume(sb, 0);
-	ocfs2_filecheck_remove_sysfs(sb);
 }
 
 static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
diff --git a/fs/ocfs2/sysfs.c b/fs/ocfs2/sysfs.c
new file mode 100644
index 0000000..1e57e6c
--- /dev/null
+++ b/fs/ocfs2/sysfs.c
@@ -0,0 +1,26 @@
+#include <linux/fs.h>
+#include "ocfs2.h"
+#include "sysfs.h"
+
+static ssize_t slot_num_show(struct super_block *sb,
+			     struct super_block_attribute *attr,
+	  		     char *buf)
+{
+	struct ocfs2_super *osb = OCFS2_SB(sb);
+	return sprintf(buf, "%d\n", osb->slot_num);
+}
+
+static SB_ATTR_RO(slot_num);
+static struct attribute *ocfs2_sb_attrs[] = {
+	&sb_attr_slot_num.attr,
+	NULL
+};
+
+int ocfs2_sysfs_sb_init(struct super_block *sb)
+{
+	sb->s_attr = ocfs2_sb_attrs;
+	return 0;
+
+}
+
+
diff --git a/fs/ocfs2/sysfs.h b/fs/ocfs2/sysfs.h
new file mode 100644
index 0000000..328f9c749
--- /dev/null
+++ b/fs/ocfs2/sysfs.h
@@ -0,0 +1,8 @@
+
+
+#ifndef _SYS_H
+#define _SYS_H
+
+int ocfs2_sysfs_sb_init(struct super_block *sb);
+
+#endif
-- 
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