Skip to content

Commit 0f97135

Browse files
committed
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 <[email protected]> Acked-by: Willy Tarreau <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e1211e2 commit 0f97135

File tree

4 files changed

+44
-27
lines changed

4 files changed

+44
-27
lines changed

tools/include/nolibc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ all_files := \
6262
sys/time.h \
6363
sys/timerfd.h \
6464
sys/types.h \
65+
sys/utsname.h \
6566
sys/wait.h \
6667
time.h \
6768
types.h \

tools/include/nolibc/nolibc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
#include "sys/sysmacros.h"
110110
#include "sys/time.h"
111111
#include "sys/timerfd.h"
112+
#include "sys/utsname.h"
112113
#include "sys/wait.h"
113114
#include "ctype.h"
114115
#include "elf.h"

tools/include/nolibc/sys.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <linux/auxvec.h>
2424
#include <linux/fcntl.h> /* for O_* and AT_* */
2525
#include <linux/stat.h> /* for statx() */
26-
#include <linux/utsname.h>
2726

2827
#include "errno.h"
2928
#include "stdarg.h"
@@ -894,32 +893,6 @@ int umount2(const char *path, int flags)
894893
}
895894

896895

897-
/*
898-
* int uname(struct utsname *buf);
899-
*/
900-
901-
struct utsname {
902-
char sysname[65];
903-
char nodename[65];
904-
char release[65];
905-
char version[65];
906-
char machine[65];
907-
char domainname[65];
908-
};
909-
910-
static __attribute__((unused))
911-
int sys_uname(struct utsname *buf)
912-
{
913-
return my_syscall1(__NR_uname, buf);
914-
}
915-
916-
static __attribute__((unused))
917-
int uname(struct utsname *buf)
918-
{
919-
return __sysret(sys_uname(buf));
920-
}
921-
922-
923896
/*
924897
* int unlink(const char *path);
925898
*/

tools/include/nolibc/sys/utsname.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
2+
/*
3+
* Utsname definitions for NOLIBC
4+
* Copyright (C) 2017-2021 Willy Tarreau <[email protected]>
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 */

0 commit comments

Comments
 (0)