Commit 00142bfd authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Greg Kroah-Hartman

kernels/ksysfs.c: export kernel address bits

This can be used by userspace to determine the address size of the
running kernel.
It frees userspace from having to interpret this information from the
UTS machine field.

Userspace implementation:
https://github.com/util-linux/util-linux/pull/1966Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20221221-address-bits-v1-1-8446b13244ac@weissschuh.netSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e5da06b2
What: /sys/kernel/address_bit
Date: May 2023
KernelVersion: 6.3
Contact: Thomas Weißschuh <linux@weissschuh.net>
Description:
The address size of the running kernel in bits.
Access: Read
Users: util-linux
...@@ -51,6 +51,14 @@ static ssize_t cpu_byteorder_show(struct kobject *kobj, ...@@ -51,6 +51,14 @@ static ssize_t cpu_byteorder_show(struct kobject *kobj,
} }
KERNEL_ATTR_RO(cpu_byteorder); KERNEL_ATTR_RO(cpu_byteorder);
/* address bits */
static ssize_t address_bits_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%zu\n", sizeof(void *) * 8 /* CHAR_BIT */);
}
KERNEL_ATTR_RO(address_bits);
#ifdef CONFIG_UEVENT_HELPER #ifdef CONFIG_UEVENT_HELPER
/* uevent helper program, used during early boot */ /* uevent helper program, used during early boot */
static ssize_t uevent_helper_show(struct kobject *kobj, static ssize_t uevent_helper_show(struct kobject *kobj,
...@@ -233,6 +241,7 @@ static struct attribute * kernel_attrs[] = { ...@@ -233,6 +241,7 @@ static struct attribute * kernel_attrs[] = {
&fscaps_attr.attr, &fscaps_attr.attr,
&uevent_seqnum_attr.attr, &uevent_seqnum_attr.attr,
&cpu_byteorder_attr.attr, &cpu_byteorder_attr.attr,
&address_bits_attr.attr,
#ifdef CONFIG_UEVENT_HELPER #ifdef CONFIG_UEVENT_HELPER
&uevent_helper_attr.attr, &uevent_helper_attr.attr,
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment