Nucleus
Barry More syscalls 315b2be (3 years, 2 months ago)
diff --git a/kernel/uname.c b/kernel/uname.c
new file mode 100644
index 0000000..c930faf
--- /dev/null
+++ b/kernel/uname.c
@@ -0,0 +1,33 @@
+/*
+ * This file implements the uname system call. It stores information about the
+ * kernel to a buffer for userspace to read.
+ */
+
+#include <string.h>
+#include <sys/utsname.h>
+#include <errno.h>
+#include <nucleus/memory.h>
+
+static const char *SYSNAME = "Nucleus";
+static const char *RELEASE = "0.9.0";
+static const char *VERSION = "SMP PREEMPT "__DATE__" "__TIME__;
+static const char *MACHINE = "x86";
+
+/* Get information about current kernel */
+int
+uname(struct utsname *buf)
+{
+ strcpy(buf->sysname, SYSNAME);
+ strcpy(buf->release, RELEASE);
+ strcpy(buf->version, VERSION);
+ strcpy(buf->machine, MACHINE);
+}
+
+/* Kernel information system call */
+int
+sys_uname(struct utsname *buf)
+{
+ if (!buf || !verify_access(buf, sizeof(struct utsname), PROT_WRITE))
+ return -EFAULT;
+ uname(buf);
+}