All of lore.kernel.org
 help / color / mirror / Atom feed
From: Latchesar Ionkov <lucho@ionkov.net>
To: v9fs-developer@lists.sourceforge.net
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] 9p: basic sysfs support
Date: Fri, 2 Nov 2007 10:53:31 -0600	[thread overview]
Message-ID: <20071102165331.GA16063@ionkov.net> (raw)

This patch implements the basic sysfs support for 9p. If CONFIG_NET_9P_DEBUG
is defined, allows reading and modifying the debug level via
/sysfs/fs/9p/debuglevel.

Signed-off-by: Latchesar Ionkov <lucho@ionkov.net>

---
 include/net/9p/9p.h |    1 +
 net/9p/mod.c        |   45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 686425a..9ace484 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -377,6 +377,7 @@ struct p9_fcall {
 };
 
 struct p9_idpool;
+extern struct kset p9_subsys;
 
 int p9_deserialize_stat(void *buf, u32 buflen, struct p9_stat *stat,
 	int dotu);
diff --git a/net/9p/mod.c b/net/9p/mod.c
index 41d70f4..8205c4b 100644
--- a/net/9p/mod.c
+++ b/net/9p/mod.c
@@ -29,6 +29,7 @@
 #include <net/9p/9p.h>
 #include <linux/fs.h>
 #include <linux/parser.h>
+#include <linux/fs.h>
 #include <net/9p/transport.h>
 #include <linux/list.h>
 
@@ -37,8 +38,17 @@ unsigned int p9_debug_level = 0;	/* feature-rific global debug level  */
 EXPORT_SYMBOL(p9_debug_level);
 module_param_named(debug, p9_debug_level, uint, 0);
 MODULE_PARM_DESC(debug, "9P debugging level");
+
+static ssize_t p9_debug_show(struct kset *, char *);
+static ssize_t p9_debug_store(struct kset *, const char *, size_t);
+
+static struct subsys_attribute p9_debug_attr = __ATTR(debuglevel, 0644,
+	p9_debug_show, p9_debug_store);
 #endif
 
+decl_subsys_name(p9, 9p, NULL, NULL);
+EXPORT_SYMBOL(p9_subsys);
+
 extern int p9_mux_global_init(void);
 extern void p9_mux_global_exit(void);
 
@@ -99,6 +109,27 @@ struct p9_trans_module *v9fs_default_trans(void)
 }
 EXPORT_SYMBOL(v9fs_default_trans);
 
+#ifdef CONFIG_NET_9P_DEBUG
+
+static ssize_t p9_debug_show(struct kset *k, char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n", p9_debug_level);
+}
+
+static ssize_t p9_debug_store(struct kset *k, const char *buf, size_t buflen)
+{
+	int n;
+	char *p;
+
+	n = simple_strtol(buf, &p, 0);
+	if (*p != '\n' && *p != '\0')
+		return EINVAL;
+
+	p9_debug_level = n;
+	return buflen;
+}
+
+#endif
 
 /**
  * v9fs_init - Initialize module
@@ -109,6 +140,19 @@ static int __init init_p9(void)
 	int ret;
 
 	p9_error_init();
+	kobj_set_kset_s(&p9_subsys, fs_subsys);
+	ret = subsystem_register(&p9_subsys);
+	if (ret)
+		return ret;
+
+#ifdef CONFIG_NET_9P_DEBUG
+	ret = subsys_create_file(&p9_subsys, &p9_debug_attr);
+	if (ret) {
+		subsystem_unregister(&p9_subsys);
+		return ret;
+	}
+#endif
+
 	printk(KERN_INFO "Installing 9P2000 support\n");
 	ret = p9_mux_global_init();
 	if (ret) {
@@ -127,6 +171,7 @@ static int __init init_p9(void)
 static void __exit exit_p9(void)
 {
 	p9_mux_global_exit();
+	subsystem_unregister(&p9_subsys);
 }
 
 module_init(init_p9)

             reply	other threads:[~2007-11-02 17:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-02 16:53 Latchesar Ionkov [this message]
2007-11-02 17:51 ` [PATCH] 9p: basic sysfs support Greg KH
2007-11-02 19:14   ` Latchesar Ionkov
2007-11-03  0:18     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071102165331.GA16063@ionkov.net \
    --to=lucho@ionkov.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=v9fs-developer@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.