summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2004-09-04 04:11:26 +0200
committerGreg Kroah-Hartman <greg@kroah.com>2004-09-04 04:11:26 +0200
commitc4b61455ac041b17933550fc06d436005df4d589 (patch)
tree2cd08281cacf74689aad0e6921a00c08ffb4205b /kernel
parentfa6ee3dddc704b76bfa1730bcafe90e2d8fb964c (diff)
[PATCH] export of SEQNUM to userspace (creates /sys/kernel)
o /sys/kernel/hotplug_seqnum exports the current number o lib/kobject.c's sequence_num is renamed to hotplug_seqnum and exported by include/linux/kobject.h o the source file ksysfs.c in kernel/ creates on init the sybsystem "/sys/kernel/" in sysfs Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/ksysfs.c52
2 files changed, 53 insertions, 1 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index a032595fd58c..cbd9e5162690 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -7,7 +7,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
sysctl.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o workqueue.o pid.o \
rcupdate.o intermodule.o extable.o params.o posix-timers.o \
- kthread.o
+ kthread.o ksysfs.o
obj-$(CONFIG_FUTEX) += futex.o
obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
new file mode 100644
index 000000000000..147aa3f2b111
--- /dev/null
+++ b/kernel/ksysfs.c
@@ -0,0 +1,52 @@
+/*
+ * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
+ * are not related to any other subsystem
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * This file is release under the GPLv2
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#define KERNEL_ATTR_RO(_name) \
+static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
+
+#define KERNEL_ATTR_RW(_name) \
+static struct subsys_attribute _name##_attr = \
+ __ATTR(_name, 0644, _name##_show, _name##_store)
+
+static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
+{
+ return sprintf(page, "%lu\n", hotplug_seqnum);
+}
+KERNEL_ATTR_RO(hotplug_seqnum);
+
+
+static decl_subsys(kernel, NULL, NULL);
+
+static struct attribute * kernel_attrs[] = {
+ &hotplug_seqnum_attr.attr,
+ NULL
+};
+
+static struct attribute_group kernel_attr_group = {
+ .attrs = kernel_attrs,
+};
+
+static int __init ksysfs_init(void)
+{
+ int error = subsystem_register(&kernel_subsys);
+ if (!error)
+ error = sysfs_create_group(&kernel_subsys.kset.kobj, &kernel_attr_group);
+
+ return error;
+}
+
+core_initcall(ksysfs_init);