2 * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
3 * are not related to any other subsystem
5 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
7 * This file is release under the GPLv2
11 #include <linux/config.h>
12 #include <linux/kobject.h>
13 #include <linux/string.h>
14 #include <linux/sysfs.h>
15 #include <linux/module.h>
16 #include <linux/init.h>
19 char uevent_helper
[UEVENT_HELPER_PATH_LEN
] = "/sbin/hotplug";
21 #define KERNEL_ATTR_RO(_name) \
22 static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
24 #define KERNEL_ATTR_RW(_name) \
25 static struct subsys_attribute _name##_attr = \
26 __ATTR(_name, 0644, _name##_show, _name##_store)
29 /* current uevent sequence number */
30 static ssize_t
uevent_seqnum_show(struct subsystem
*subsys
, char *page
)
32 return sprintf(page
, "%llu\n", (unsigned long long)uevent_seqnum
);
34 KERNEL_ATTR_RO(uevent_seqnum
);
36 /* uevent helper program, used during early boo */
37 static ssize_t
uevent_helper_show(struct subsystem
*subsys
, char *page
)
39 return sprintf(page
, "%s\n", uevent_helper
);
41 static ssize_t
uevent_helper_store(struct subsystem
*subsys
, const char *page
, size_t count
)
43 if (count
+1 > UEVENT_HELPER_PATH_LEN
)
45 memcpy(uevent_helper
, page
, count
);
46 uevent_helper
[count
] = '\0';
47 if (count
&& uevent_helper
[count
-1] == '\n')
48 uevent_helper
[count
-1] = '\0';
51 KERNEL_ATTR_RW(uevent_helper
);
55 #include <asm/kexec.h>
57 static ssize_t
crash_notes_show(struct subsystem
*subsys
, char *page
)
59 return sprintf(page
, "%p\n", (void *)crash_notes
);
61 KERNEL_ATTR_RO(crash_notes
);
64 decl_subsys(kernel
, NULL
, NULL
);
65 EXPORT_SYMBOL_GPL(kernel_subsys
);
67 static struct attribute
* kernel_attrs
[] = {
69 &uevent_seqnum_attr
.attr
,
70 &uevent_helper_attr
.attr
,
73 &crash_notes_attr
.attr
,
78 static struct attribute_group kernel_attr_group
= {
79 .attrs
= kernel_attrs
,
82 static int __init
ksysfs_init(void)
84 int error
= subsystem_register(&kernel_subsys
);
86 error
= sysfs_create_group(&kernel_subsys
.kset
.kobj
,
92 core_initcall(ksysfs_init
);