Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/nolibc: move uname() and friends to sys/utsname.h

This is the location regular userspace expects these definitions.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-7-74f82eea3b59@weissschuh.net

+44 -27
+1
tools/include/nolibc/Makefile
··· 62 62 sys/time.h \ 63 63 sys/timerfd.h \ 64 64 sys/types.h \ 65 + sys/utsname.h \ 65 66 sys/wait.h \ 66 67 time.h \ 67 68 types.h \
+1
tools/include/nolibc/nolibc.h
··· 109 109 #include "sys/sysmacros.h" 110 110 #include "sys/time.h" 111 111 #include "sys/timerfd.h" 112 + #include "sys/utsname.h" 112 113 #include "sys/wait.h" 113 114 #include "ctype.h" 114 115 #include "elf.h"
-27
tools/include/nolibc/sys.h
··· 23 23 #include <linux/auxvec.h> 24 24 #include <linux/fcntl.h> /* for O_* and AT_* */ 25 25 #include <linux/stat.h> /* for statx() */ 26 - #include <linux/utsname.h> 27 26 28 27 #include "errno.h" 29 28 #include "stdarg.h" ··· 890 891 int umount2(const char *path, int flags) 891 892 { 892 893 return __sysret(sys_umount2(path, flags)); 893 - } 894 - 895 - 896 - /* 897 - * int uname(struct utsname *buf); 898 - */ 899 - 900 - struct utsname { 901 - char sysname[65]; 902 - char nodename[65]; 903 - char release[65]; 904 - char version[65]; 905 - char machine[65]; 906 - char domainname[65]; 907 - }; 908 - 909 - static __attribute__((unused)) 910 - int sys_uname(struct utsname *buf) 911 - { 912 - return my_syscall1(__NR_uname, buf); 913 - } 914 - 915 - static __attribute__((unused)) 916 - int uname(struct utsname *buf) 917 - { 918 - return __sysret(sys_uname(buf)); 919 894 } 920 895 921 896
+42
tools/include/nolibc/sys/utsname.h
··· 1 + /* SPDX-License-Identifier: LGPL-2.1 OR MIT */ 2 + /* 3 + * Utsname definitions for NOLIBC 4 + * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu> 5 + */ 6 + 7 + /* make sure to include all global symbols */ 8 + #include "../nolibc.h" 9 + 10 + #ifndef _NOLIBC_SYS_UTSNAME_H 11 + #define _NOLIBC_SYS_UTSNAME_H 12 + 13 + #include "../sys.h" 14 + 15 + #include <linux/utsname.h> 16 + 17 + /* 18 + * int uname(struct utsname *buf); 19 + */ 20 + 21 + struct utsname { 22 + char sysname[65]; 23 + char nodename[65]; 24 + char release[65]; 25 + char version[65]; 26 + char machine[65]; 27 + char domainname[65]; 28 + }; 29 + 30 + static __attribute__((unused)) 31 + int sys_uname(struct utsname *buf) 32 + { 33 + return my_syscall1(__NR_uname, buf); 34 + } 35 + 36 + static __attribute__((unused)) 37 + int uname(struct utsname *buf) 38 + { 39 + return __sysret(sys_uname(buf)); 40 + } 41 + 42 + #endif /* _NOLIBC_SYS_UTSNAME_H */