1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

Add sys$uname() and a /bin/uname utility.

This commit is contained in:
Andreas Kling 2018-10-26 14:56:21 +02:00
parent 384e2f24d4
commit 1c45b28da6
15 changed files with 129 additions and 10 deletions

View file

@ -26,12 +26,18 @@ static InlineLinkedList<Task>* s_tasks;
static InlineLinkedList<Task>* s_deadTasks;
static String* s_hostname;
static String& hostname(InterruptDisabler&)
static String& hostnameStorage(InterruptDisabler&)
{
ASSERT(s_hostname);
return *s_hostname;
}
static String getHostname()
{
InterruptDisabler disabler;
return hostnameStorage(disabler).isolatedCopy();
}
static bool contextSwitch(Task*);
static void redoKernelTaskTSS()
@ -177,14 +183,10 @@ int Task::sys$munmap(void* addr, size_t size)
int Task::sys$gethostname(char* buffer, size_t size)
{
String hn;
{
InterruptDisabler disabler;
hn = hostname(disabler).isolatedCopy();
}
if (size < (hn.length() + 1))
auto hostname = getHostname();
if (size < (hostname.length() + 1))
return -ENAMETOOLONG;
memcpy(buffer, hn.characters(), size);
memcpy(buffer, hostname.characters(), size);
return 0;
}
@ -760,6 +762,16 @@ int Task::sys$open(const char* path, size_t pathLength)
return fd;
}
int Task::sys$uname(utsname* buf)
{
strcpy(buf->sysname, "Serenity");
strcpy(buf->release, "1.0-dev");
strcpy(buf->version, "FIXME");
strcpy(buf->machine, "i386");
strcpy(buf->nodename, getHostname().characters());
return 0;
}
int Task::sys$kill(pid_t pid, int sig)
{
(void) sig;