aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/ksysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/ksysfs.c')
-rw-r--r--kernel/ksysfs.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 015fb69ad94d..99af8b05eeaa 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -15,6 +15,9 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/init.h> 16#include <linux/init.h>
17 17
18u64 uevent_seqnum;
19char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
20
18#define KERNEL_ATTR_RO(_name) \ 21#define KERNEL_ATTR_RO(_name) \
19static struct subsys_attribute _name##_attr = __ATTR_RO(_name) 22static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
20 23
@@ -23,11 +26,29 @@ static struct subsys_attribute _name##_attr = \
23 __ATTR(_name, 0644, _name##_show, _name##_store) 26 __ATTR(_name, 0644, _name##_show, _name##_store)
24 27
25#ifdef CONFIG_HOTPLUG 28#ifdef CONFIG_HOTPLUG
26static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page) 29/* current uevent sequence number */
30static ssize_t uevent_seqnum_show(struct subsystem *subsys, char *page)
31{
32 return sprintf(page, "%llu\n", (unsigned long long)uevent_seqnum);
33}
34KERNEL_ATTR_RO(uevent_seqnum);
35
36/* uevent helper program, used during early boo */
37static ssize_t uevent_helper_show(struct subsystem *subsys, char *page)
38{
39 return sprintf(page, "%s\n", uevent_helper);
40}
41static ssize_t uevent_helper_store(struct subsystem *subsys, const char *page, size_t count)
27{ 42{
28 return sprintf(page, "%llu\n", (unsigned long long)hotplug_seqnum); 43 if (count+1 > UEVENT_HELPER_PATH_LEN)
44 return -ENOENT;
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';
49 return count;
29} 50}
30KERNEL_ATTR_RO(hotplug_seqnum); 51KERNEL_ATTR_RW(uevent_helper);
31#endif 52#endif
32 53
33#ifdef CONFIG_KEXEC 54#ifdef CONFIG_KEXEC
@@ -45,7 +66,8 @@ EXPORT_SYMBOL_GPL(kernel_subsys);
45 66
46static struct attribute * kernel_attrs[] = { 67static struct attribute * kernel_attrs[] = {
47#ifdef CONFIG_HOTPLUG 68#ifdef CONFIG_HOTPLUG
48 &hotplug_seqnum_attr.attr, 69 &uevent_seqnum_attr.attr,
70 &uevent_helper_attr.attr,
49#endif 71#endif
50#ifdef CONFIG_KEXEC 72#ifdef CONFIG_KEXEC
51 &crash_notes_attr.attr, 73 &crash_notes_attr.attr,