1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
6 * OCFS2 cluster sysfs interface
8 * Copyright (C) 2005 Oracle. All rights reserved.
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation,
13 * version 2 of the License.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 021110-1307, USA.
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/kobject.h>
30 #include <linux/sysfs.h>
32 #include "ocfs2_nodemanager.h"
36 struct o2cb_attribute {
37 struct attribute attr;
38 ssize_t (*show)(char *buf);
39 ssize_t (*store)(const char *buf, size_t count);
42 #define O2CB_ATTR(_name, _mode, _show, _store) \
43 struct o2cb_attribute o2cb_attr_##_name = __ATTR(_name, _mode, _show, _store)
45 #define to_o2cb_attr(_attr) container_of(_attr, struct o2cb_attribute, attr)
47 static ssize_t o2cb_interface_revision_show(char *buf)
49 return snprintf(buf, PAGE_SIZE, "%u\n", O2NM_API_VERSION);
52 static O2CB_ATTR(interface_revision, S_IFREG | S_IRUGO, o2cb_interface_revision_show, NULL);
54 static struct attribute *o2cb_attrs[] = {
55 &o2cb_attr_interface_revision.attr,
60 o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer);
62 o2cb_store(struct kobject * kobj, struct attribute * attr,
63 const char * buffer, size_t count);
64 static struct sysfs_ops o2cb_sysfs_ops = {
69 static struct kobj_type o2cb_subsys_type = {
70 .default_attrs = o2cb_attrs,
71 .sysfs_ops = &o2cb_sysfs_ops,
74 /* gives us o2cb_subsys */
75 static decl_subsys(o2cb, NULL, NULL);
78 o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer)
80 struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr);
81 struct kset *sbs = to_kset(kobj);
83 BUG_ON(sbs != &o2cb_subsys);
86 return o2cb_attr->show(buffer);
91 o2cb_store(struct kobject * kobj, struct attribute * attr,
92 const char * buffer, size_t count)
94 struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr);
95 struct kset *sbs = to_kset(kobj);
97 BUG_ON(sbs != &o2cb_subsys);
100 return o2cb_attr->store(buffer, count);
104 void o2cb_sys_shutdown(void)
107 subsystem_unregister(&o2cb_subsys);
110 int o2cb_sys_init(void)
114 o2cb_subsys.kobj.ktype = &o2cb_subsys_type;
115 ret = subsystem_register(&o2cb_subsys);
119 ret = mlog_sys_init(&o2cb_subsys);
121 subsystem_unregister(&o2cb_subsys);