1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 01:25:09 +00:00

Add sys$gethostname and /bin/hostname

This commit is contained in:
Andreas Kling 2018-10-26 09:54:29 +02:00
parent 3faaa3e04a
commit 53abfa7ea1
16 changed files with 77 additions and 40 deletions

View file

@ -24,6 +24,13 @@ Task* s_kernelTask;
static pid_t next_pid;
static InlineLinkedList<Task>* s_tasks;
static InlineLinkedList<Task>* s_deadTasks;
static String* s_hostname;
static String& hostname(InterruptDisabler&)
{
ASSERT(s_hostname);
return *s_hostname;
}
static bool contextSwitch(Task*);
@ -61,6 +68,7 @@ void Task::initialize()
s_tasks = new InlineLinkedList<Task>;
s_deadTasks = new InlineLinkedList<Task>;
s_kernelTask = Task::createKernelTask(nullptr, "colonel");
s_hostname = new String("birx");
redoKernelTaskTSS();
loadTaskRegister(s_kernelTask->selector());
}
@ -167,6 +175,18 @@ int Task::sys$munmap(void* addr, size_t size)
return 0;
}
int Task::sys$gethostname(char* buffer, size_t size)
{
String hn;
{
InterruptDisabler disabler;
hn = hostname(disabler).isolatedCopy();
}
if (size < (hn.length() + 1))
return -ENAMETOOLONG;
memcpy(buffer, hn.characters(), size);
}
int Task::sys$spawn(const char* path)
{
int error = 0;