diff options
author | Thomas Weißschuh <linux@weissschuh.net> | 2024-04-14 01:45:09 +0200 |
---|---|---|
committer | Thomas Weißschuh <linux@weissschuh.net> | 2024-04-14 20:28:54 +0200 |
commit | 0adab2b6b7336fb6ee3c6456a432dad3b1d25647 (patch) | |
tree | 63364137143c23cab403ad7681f7713d47e91582 /tools/include/nolibc | |
parent | e93b912ecf6ab113c9d4ec9ced2fa30dfac24c70 (diff) |
tools/nolibc: add support for uname(2)
All supported kernels are assumed to use struct new_utsname.
This is validated in test_uname().
uname(2) can for example be used in ksft_min_kernel_version() from the
kernels selftest framework.
Link: https://lore.kernel.org/lkml/20240412123536.GA32444@redhat.com/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'tools/include/nolibc')
-rw-r--r-- | tools/include/nolibc/sys.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index dda9dffd1d74..7b82bc3cf107 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -22,6 +22,7 @@ #include <linux/stat.h> /* for statx() */ #include <linux/prctl.h> #include <linux/resource.h> +#include <linux/utsname.h> #include "arch.h" #include "errno.h" @@ -1140,6 +1141,32 @@ int umount2(const char *path, int flags) /* + * int uname(struct utsname *buf); + */ + +struct utsname { + char sysname[65]; + char nodename[65]; + char release[65]; + char version[65]; + char machine[65]; + char domainname[65]; +}; + +static __attribute__((unused)) +int sys_uname(struct utsname *buf) +{ + return my_syscall1(__NR_uname, buf); +} + +static __attribute__((unused)) +int uname(struct utsname *buf) +{ + return __sysret(sys_uname(buf)); +} + + +/* * int unlink(const char *path); */ |