summaryrefslogtreecommitdiffstats
path: root/kernel/reboot.c
diff options
context:
space:
mode:
authorMatteo Croce <mcroce@microsoft.com>2020-12-15 20:47:07 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2020-12-15 22:46:19 -0800
commit40247e55ba099067bf160332365ed78b5aeb62da (patch)
tree4ac2714684eef6903256c5ed373eefa21e6526a7 /kernel/reboot.c
parent1a9d079f43e3215b81ec13d427950093b8f04c70 (diff)
downloadlinux-40247e55ba099067bf160332365ed78b5aeb62da.tar.gz
linux-40247e55ba099067bf160332365ed78b5aeb62da.tar.bz2
linux-40247e55ba099067bf160332365ed78b5aeb62da.zip
reboot: hide from sysfs not applicable settings
Not all the reboot settings from both the kernel command line or sysfs interface are available to all platforms. Filter out reboot_type and reboot_force which are x86 only, and also remove reboot_cpu on kernels without SMP support. This saves some space, and avoid confusing the user with settings which will have no effect. Link: https://lkml.kernel.org/r/20201130173717.198952-3-mcroce@linux.microsoft.com Signed-off-by: Matteo Croce <mcroce@microsoft.com> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/reboot.c')
-rw-r--r--kernel/reboot.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 4a1a66452ec4..eb1b15850761 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -668,6 +668,29 @@ static ssize_t mode_store(struct kobject *kobj, struct kobj_attribute *attr,
}
static struct kobj_attribute reboot_mode_attr = __ATTR_RW(mode);
+#ifdef CONFIG_X86
+static ssize_t force_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", reboot_force);
+}
+static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buf, size_t count)
+{
+ bool res;
+
+ if (!capable(CAP_SYS_BOOT))
+ return -EPERM;
+
+ if (kstrtobool(buf, &res))
+ return -EINVAL;
+
+ reboot_default = 0;
+ reboot_force = res;
+
+ return count;
+}
+static struct kobj_attribute reboot_force_attr = __ATTR_RW(force);
+
static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
const char *val;
@@ -723,7 +746,9 @@ static ssize_t type_store(struct kobject *kobj, struct kobj_attribute *attr,
return count;
}
static struct kobj_attribute reboot_type_attr = __ATTR_RW(type);
+#endif
+#ifdef CONFIG_SMP
static ssize_t cpu_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", reboot_cpu);
@@ -751,34 +776,17 @@ static ssize_t cpu_store(struct kobject *kobj, struct kobj_attribute *attr,
return count;
}
static struct kobj_attribute reboot_cpu_attr = __ATTR_RW(cpu);
-
-static ssize_t force_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
-{
- return sprintf(buf, "%d\n", reboot_force);
-}
-static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr,
- const char *buf, size_t count)
-{
- bool res;
-
- if (!capable(CAP_SYS_BOOT))
- return -EPERM;
-
- if (kstrtobool(buf, &res))
- return -EINVAL;
-
- reboot_default = 0;
- reboot_force = res;
-
- return count;
-}
-static struct kobj_attribute reboot_force_attr = __ATTR_RW(force);
+#endif
static struct attribute *reboot_attrs[] = {
&reboot_mode_attr.attr,
+#ifdef CONFIG_X86
+ &reboot_force_attr.attr,
&reboot_type_attr.attr,
+#endif
+#ifdef CONFIG_SMP
&reboot_cpu_attr.attr,
- &reboot_force_attr.attr,
+#endif
NULL,
};