mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-05-24 03:59:09 +00:00
Add sys$gethostname and /bin/hostname
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user