From d1e2263502fb65e90d3f8c4522754388b4a3989b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 17 Dec 2004 16:23:22 +0000 Subject: [PATCH] untested uname implementation still lacking some way of getting/setting hostname in our kernel git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10484 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/sys/Jamfile | 3 ++- src/kernel/libroot/posix/sys/uname.c | 34 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/kernel/libroot/posix/sys/uname.c diff --git a/src/kernel/libroot/posix/sys/Jamfile b/src/kernel/libroot/posix/sys/Jamfile index 5c3ec8cb11..7d119a8108 100644 --- a/src/kernel/libroot/posix/sys/Jamfile +++ b/src/kernel/libroot/posix/sys/Jamfile @@ -14,6 +14,7 @@ KernelMergeObject posix_sys.o : times.c uio.c umask.c - wait.c + uname.c + wait.c : -fPIC -DPIC ; diff --git a/src/kernel/libroot/posix/sys/uname.c b/src/kernel/libroot/posix/sys/uname.c new file mode 100644 index 0000000000..430c5f9191 --- /dev/null +++ b/src/kernel/libroot/posix/sys/uname.c @@ -0,0 +1,34 @@ +/* +** Copyright 2004, Jérôme Duval jerome.duval@free.fr. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#include +#include +#include +#include +#include + +int +uname(struct utsname *info) +{ + system_info sinfo; + + if (!info) { + errno = B_BAD_VALUE; + return -1; + } + + get_system_info(&sinfo); + + strlcpy(info->sysname, sinfo.kernel_name, B_FILE_NAME_LENGTH); + strlcpy(info->version, sinfo.kernel_build_date, B_OS_NAME_LENGTH); + strlcat(info->version, sinfo.kernel_build_time, B_OS_NAME_LENGTH); + sprintf(info->release, "%Ld", sinfo.kernel_version); + + // TODO fill nodename field when we have hostname info + + return 0; +} +