Skip to content

Commit

Permalink
kernel/utsname_sysctl.c: print kernel arch
Browse files Browse the repository at this point in the history
Print the machine hardware name (UTS_MACHINE) in /proc/sys/kernel/arch.

This helps people who debug kernel with initramfs with minimal environment
(i.e.  without coreutils or even busybox) or allow to open sysfs file
instead of run 'uname -m' in high level languages.

Link: https://lkml.kernel.org/r/20220901194403.3819-1-pvorel@suse.cz
Signed-off-by: Petr Vorel <pvorel@suse.cz>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: David Sterba <dsterba@suse.com>
Cc: "Eric W . Biederman" <ebiederm@xmission.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Petr Vorel authored and Andrew Morton committed Sep 12, 2022
1 parent 8ea0114 commit bfca3dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Documentation/admin-guide/sysctl/kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ combining the following values:
4 s3_beep
= =======

arch
====

The machine hardware name, the same output as ``uname -m``
(e.g. ``x86_64`` or ``aarch64``).

auto_msgmni
===========
Expand Down
7 changes: 7 additions & 0 deletions kernel/utsname_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ static DEFINE_CTL_TABLE_POLL(hostname_poll);
static DEFINE_CTL_TABLE_POLL(domainname_poll);

static struct ctl_table uts_kern_table[] = {
{
.procname = "arch",
.data = init_uts_ns.name.machine,
.maxlen = sizeof(init_uts_ns.name.machine),
.mode = 0444,
.proc_handler = proc_do_uts_string,
},
{
.procname = "ostype",
.data = init_uts_ns.name.sysname,
Expand Down

0 comments on commit bfca3dd

Please sign in to comment.