From adf50dffd83bf9503ceafb5736a0572cb2690983 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 31 Jul 2024 23:54:26 +0300 Subject: [PATCH] LibC: Implement uname() --- userspace/libraries/LibC/CMakeLists.txt | 1 + userspace/libraries/LibC/sys/utsname.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 userspace/libraries/LibC/sys/utsname.cpp diff --git a/userspace/libraries/LibC/CMakeLists.txt b/userspace/libraries/LibC/CMakeLists.txt index e6ec4442c2..113d0c0a1c 100644 --- a/userspace/libraries/LibC/CMakeLists.txt +++ b/userspace/libraries/LibC/CMakeLists.txt @@ -24,6 +24,7 @@ set(LIBC_SOURCES sys/socket.cpp sys/stat.cpp sys/time.cpp + sys/utsname.cpp sys/wait.cpp termios.cpp time.cpp diff --git a/userspace/libraries/LibC/sys/utsname.cpp b/userspace/libraries/LibC/sys/utsname.cpp new file mode 100644 index 0000000000..ff6e4cb10c --- /dev/null +++ b/userspace/libraries/LibC/sys/utsname.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +#define __xstr(s) __str(s) +#define __str(s) #s + +int uname(struct utsname* name) +{ + strcpy(name->sysname, "banan-os"); + if (gethostname(name->nodename, sizeof(name->nodename)) == -1) + return -1; + strcpy(name->release, "0.0.0-banan_os"); + strcpy(name->version, __DATE__ " " __TIME__); + strcpy(name->machine, __xstr(__arch)); + return 0; +}