summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-26 14:56:21 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-26 14:57:26 +0200
commit1c45b28da6e74aeacace16817e6b7481a547a9e7 (patch)
treece89a53c775f1497362314b9f7d606c160b336b6 /Kernel
parent384e2f24d41aad4ad42aa6eff7783e924fea98fc (diff)
downloadserenity-1c45b28da6e74aeacace16817e6b7481a547a9e7.zip
Add sys$uname() and a /bin/uname utility.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Syscall.cpp2
-rw-r--r--Kernel/Syscall.h1
-rw-r--r--Kernel/Task.cpp28
-rw-r--r--Kernel/Task.h1
-rw-r--r--Kernel/_fs_contentsbin1024000 -> 1024000 bytes
-rwxr-xr-xKernel/sync-sh1
-rw-r--r--Kernel/types.h10
7 files changed, 35 insertions, 8 deletions
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index 9af8c2fcef..5314418d5d 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -112,6 +112,8 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3)
return current->sys$get_arguments((int*)arg1, (char***)arg2);
case Syscall::PosixChdir:
return current->sys$chdir((const char*)arg1);
+ case Syscall::PosixUname:
+ return current->sys$uname((utsname*)arg1);
default:
kprintf("int0x80: Unknown function %x requested {%x, %x, %x}\n", function, arg1, arg2, arg3);
break;
diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h
index 9eb832e484..68a36ffd52 100644
--- a/Kernel/Syscall.h
+++ b/Kernel/Syscall.h
@@ -33,6 +33,7 @@ enum Function {
PosixGethostname = 0x2001,
GetArguments = 0x2002,
PosixChdir = 0x2003,
+ PosixUname = 0x2004,
};
void initialize();
diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp
index c26041d70a..b083698a94 100644
--- a/Kernel/Task.cpp
+++ b/Kernel/Task.cpp
@@ -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;
diff --git a/Kernel/Task.h b/Kernel/Task.h
index c5a1362d14..b58b139c0c 100644
--- a/Kernel/Task.h
+++ b/Kernel/Task.h
@@ -104,6 +104,7 @@ public:
int sys$gettimeofday(timeval*);
int sys$gethostname(char* name, size_t length);
int sys$get_arguments(int* argc, char*** argv);
+ int sys$uname(utsname*);
static void initialize();
diff --git a/Kernel/_fs_contents b/Kernel/_fs_contents
index c1123370d1..d31ada7ac0 100644
--- a/Kernel/_fs_contents
+++ b/Kernel/_fs_contents
Binary files differ
diff --git a/Kernel/sync-sh b/Kernel/sync-sh
index 922f07931c..f885e7ab18 100755
--- a/Kernel/sync-sh
+++ b/Kernel/sync-sh
@@ -11,5 +11,6 @@ cp ../Userland/true mnt/bin/true
cp ../Userland/false mnt/bin/false
cp ../Userland/hostname mnt/bin/hostname
cp ../Userland/cat mnt/bin/cat
+cp ../Userland/uname mnt/bin/uname
umount mnt
sync
diff --git a/Kernel/types.h b/Kernel/types.h
index ac5a4feedd..63f2a22846 100644
--- a/Kernel/types.h
+++ b/Kernel/types.h
@@ -31,6 +31,16 @@ struct timeval {
suseconds_t tv_usec;
};
+#define UTSNAME_ENTRY_LEN 65
+
+struct utsname {
+ char sysname[UTSNAME_ENTRY_LEN];
+ char nodename[UTSNAME_ENTRY_LEN];
+ char release[UTSNAME_ENTRY_LEN];
+ char version[UTSNAME_ENTRY_LEN];
+ char machine[UTSNAME_ENTRY_LEN];
+};
+
struct FarPtr {
DWORD offset { 0 };
WORD selector { 0 };