[PATCH 19/67] aufs sysfs interface and lifetime management, source

From: hooanon05
Date: Fri May 16 2008 - 10:48:54 EST


From: Junjiro Okajima <hooanon05@xxxxxxxxxxx>

initial commit
aufs sysfs interface and lifetime management, source

Signed-off-by: Junjiro Okajima <hooanon05@xxxxxxxxxxx>
---
fs/aufs/sysaufs.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 104 insertions(+), 0 deletions(-)

diff --git a/fs/aufs/sysaufs.c b/fs/aufs/sysaufs.c
new file mode 100644
index 0000000..7df12fd
--- /dev/null
+++ b/fs/aufs/sysaufs.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2007-2008 Junjiro Okajima
+ *
+ * This program, aufs is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * sysfs interface and lifetime management
+ * they are necessary regardless sysfs is disabled.
+ *
+ * $Id: sysaufs.c,v 1.4 2008/04/28 03:05:39 sfjro Exp $
+ */
+
+#include <linux/fs.h>
+#include <linux/module.h>
+#include <linux/sysfs.h>
+#include "aufs.h"
+
+/* ---------------------------------------------------------------------- */
+
+/* super_blocks list is not exported */
+DEFINE_MUTEX(au_sbilist_mtx);
+LIST_HEAD(au_sbilist);
+
+/* ---------------------------------------------------------------------- */
+
+static struct kset au_kset;
+
+#define AuSbiAttr(_name) { \
+ .attr = { .name = __stringify(_name), .mode = 0444 }, \
+ .show = sysaufs_sbi_##_name, \
+}
+
+static struct au_sbi_attr au_sbi_attr_xino = AuSbiAttr(xino);
+struct attribute *au_sbi_attrs[] = {
+ &au_sbi_attr_xino.attr,
+ NULL,
+};
+
+static struct sysfs_ops au_sbi_ops = {
+ .show = sysaufs_sbi_show
+};
+
+static struct kobj_type au_sbi_ktype = {
+ .release = au_si_free,
+ .sysfs_ops = &au_sbi_ops,
+ .default_attrs = au_sbi_attrs,
+};
+
+/* ---------------------------------------------------------------------- */
+
+int sysaufs_si_init(struct au_sbinfo *sbinfo)
+{
+ int err;
+
+ sbinfo->si_kobj.kset = &au_kset;
+ err = kobject_init_and_add(&sbinfo->si_kobj, &au_sbi_ktype,
+ NULL/*&au_kset.kobj*/,
+ SysaufsSb_PREFIX "%p", sbinfo);
+ AuTraceErr(err);
+ return err;
+}
+
+
+/* ---------------------------------------------------------------------- */
+
+void sysaufs_fin(void)
+{
+ AuDebugOn(!list_empty(&au_sbilist));
+ sysfs_remove_group(&au_kset.kobj, au_attr_group);
+ kset_unregister(&au_kset);
+}
+
+int __init sysaufs_init(void)
+{
+ int err;
+
+ sysaufs_brs_init();
+ au_kset.kobj.parent = fs_kobj;
+ kobject_set_name(&au_kset.kobj, AUFS_NAME);
+ au_kset.kobj.ktype = au_ktype;
+ err = kset_register(&au_kset);
+ if (unlikely(err))
+ goto out;
+ err = sysfs_create_group(&au_kset.kobj, au_attr_group);
+ if (unlikely(err))
+ kset_unregister(&au_kset);
+
+ out:
+ AuTraceErr(err);
+ return err;
+}
--
1.4.4.4

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