The patch titled Subject: reboot: hide from sysfs not applicable settings has been added to the -mm tree. Its filename is reboot-hide-from-sysfs-not-applicable-settings.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/reboot-hide-from-sysfs-not-applicable-settings.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/reboot-hide-from-sysfs-not-applicable-settings.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Matteo Croce <mcroce@xxxxxxxxxxxxx> Subject: 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@xxxxxxxxxxxxxxxxxxx Signed-off-by: Matteo Croce <mcroce@xxxxxxxxxxxxx> Cc: Petr Mladek <pmladek@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/reboot.c | 54 ++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 23 deletions(-) --- a/kernel/reboot.c~reboot-hide-from-sysfs-not-applicable-settings +++ a/kernel/reboot.c @@ -666,6 +666,29 @@ static ssize_t mode_store(struct kobject } 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; @@ -721,7 +744,9 @@ static ssize_t type_store(struct kobject 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); @@ -749,34 +774,17 @@ static ssize_t cpu_store(struct kobject 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, }; _ Patches currently in -mm which might be from mcroce@xxxxxxxxxxxxx are reboot-refactor-and-comment-the-cpu-selection-code.patch reboot-allow-to-specify-reboot-mode-via-sysfs.patch reboot-remove-cf9_safe-from-allowed-types-and-rename-cf9_force.patch reboot-allow-to-override-reboot-type-if-quirks-are-found.patch reboot-hide-from-sysfs-not-applicable-settings.patch