Nucleus
Barry System headers (remove libc dependency) 18495cf (3 years, 2 months ago)
diff --git a/Makefile b/Makefile
index 2461903..5ec91e5 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ OBJS = $(sort $(subst ./,build/,$(subst .S,.o,$(AS_SRC))))
C_SRC := $(shell find . -name '*.c')
OBJS += $(sort $(subst ./,build/,$(subst .c,.o,$(C_SRC))))
-.PHONY: clean all install
+.PHONY: install-headers clean all install
all: $(PRODUCT)
@@ -26,6 +26,11 @@ clean:
@touch $(PRODUCT)
@rm $(PRODUCT)
+install-headers:
+ $(info INSTALL KERNEL HEADERS)
+ @mkdir -p ${SYSROOT}/usr/include/
+ @cp -r include/* ${SYSROOT}/usr/include/
+
install: $(PRODUCT)
$(info INSTALL $^)
@install -Dm 755 $(PRODUCT) -t ${SYSROOT}/boot/
diff --git a/drivers/devices.c b/drivers/devices.c
index 7e1b709..b33f79d 100644
--- a/drivers/devices.c
+++ b/drivers/devices.c
@@ -3,8 +3,8 @@
* database and controls device initialisation.
*/
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
#include <nucleus/kernel.h>
#include <nucleus/pci.h>
diff --git a/drivers/storage/ata.c b/drivers/storage/ata.c
index bf56afc..a8a27b2 100644
--- a/drivers/storage/ata.c
+++ b/drivers/storage/ata.c
@@ -4,13 +4,12 @@
* actual hardware.
*/
-#include <stdio.h>
#include <stdint.h>
-#include <string.h>
+#include <sys/errno.h>
#include <sys/stat.h>
-#include <errno.h>
-#include <io.h>
#include <nucleus/driver.h>
+#include <nucleus/io.h>
+#include <nucleus/lib.h>
#include <nucleus/vfs.h>
#include "ide.h"
diff --git a/drivers/storage/ide.c b/drivers/storage/ide.c
index 0cc9253..6075192 100644
--- a/drivers/storage/ide.c
+++ b/drivers/storage/ide.c
@@ -9,7 +9,7 @@
*/
#include <stdint.h>
-#include <io.h>
+#include <nucleus/io.h>
#include <nucleus/pci.h>
#include "ide.h"
diff --git a/drivers/video/bga.c b/drivers/video/bga.c
index 061409a..a131982 100644
--- a/drivers/video/bga.c
+++ b/drivers/video/bga.c
@@ -5,15 +5,14 @@
*/
#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/stat.h>
+#include <sys/errno.h>
#include <sys/fb.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <io.h>
+#include <sys/file.h>
+#include <sys/stat.h>
#include <nucleus/driver.h>
+#include <nucleus/io.h>
#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/pci.h>
#include <nucleus/vfs.h>
diff --git a/include/nucleus/cpu.h b/include/nucleus/cpu.h
index 2a8c52b..cb41a28 100644
--- a/include/nucleus/cpu.h
+++ b/include/nucleus/cpu.h
@@ -1,8 +1,8 @@
#ifndef _NUCLEUS_CPU_H
#define _NUCLEUS_CPU_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
#include <nucleus/types.h>
typedef unsigned int cpu_t;
@@ -41,7 +41,7 @@ extern Processor *cpus[];
extern size_t ncpus;
extern int apic;
#define for_each_cpu(c) for (cpu_t __i_ ## c = 0; ((c) = cpus[__i_ ## c]) && \
- __i_ ## c < ncpus; __i_ ## c++)
+ ((__i_ ## c) < ncpus); (__i_ ## c)++)
extern uintptr_t lapicPtr, ioapicPtr;
#define LAPIC(off) (*((uint32_t *) ((uint32_t) lapicPtr + (off))))
diff --git a/include/io.h b/include/nucleus/io.h
similarity index 100%
rename from include/io.h
rename to include/nucleus/io.h
index e0204fd..1868e77 100644
--- a/include/io.h
+++ b/include/nucleus/io.h
@@ -1,8 +1,8 @@
#ifndef _IO_H
#define _IO_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
/* Read byte from port */
static inline uint8_t
diff --git a/include/nucleus/kernel.h b/include/nucleus/kernel.h
index 50bba3d..2b1bc75 100644
--- a/include/nucleus/kernel.h
+++ b/include/nucleus/kernel.h
@@ -2,9 +2,8 @@
#define _NUCLEUS_KERNEL_H
#include <stdarg.h>
+#include <nucleus/lib.h>
-int vsprintf(char *buf, const char *fmt, va_list args);
-int sprintf(char *buf, const char *fmt, ...);
void dbgprintf(char *str);
void kprintf(char *fmt, ...);
_Noreturn void panic(char *fmt, ...);
diff --git a/include/nucleus/lib.h b/include/nucleus/lib.h
new file mode 100644
index 0000000..a352728
--- /dev/null
+++ b/include/nucleus/lib.h
@@ -0,0 +1,21 @@
+#ifndef _NUCLEUS_LIB_H
+#define _NUCLEUS_LIB_H
+
+#include <stdarg.h>
+#include <stddef.h>
+
+int vsprintf(char *buf, const char *fmt, va_list args);
+int sprintf(char *buf, const char *fmt, ...);
+
+void *memset(void *dest, int byte, size_t len);
+int memcmp(void *s1, void *s2, size_t n);
+void *memcpy(void *dest, const void *src, size_t n);
+
+int strcmp(const char *s1, const char *s2);
+int strncmp(const char *s1, const char *s2, size_t n);
+char *strcpy(char *dest, const char *src);
+char *strncpy(char *dest, const char *src, size_t n);
+size_t strlen(const char *str);
+size_t strnlen(const char *str, size_t n);
+
+#endif
diff --git a/include/nucleus/memory.h b/include/nucleus/memory.h
index 595d152..c91e40c 100644
--- a/include/nucleus/memory.h
+++ b/include/nucleus/memory.h
@@ -1,8 +1,8 @@
#ifndef _NUCLEUS_MEMORY_H
#define _NUCLEUS_MEMORY_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
#include <sys/mman.h>
#include <nucleus/object.h>
#include <nucleus/types.h>
diff --git a/include/nucleus/object.h b/include/nucleus/object.h
index 70e7bc1..558d00f 100644
--- a/include/nucleus/object.h
+++ b/include/nucleus/object.h
@@ -1,8 +1,8 @@
#ifndef _NUCLEUS_OBJECT_H
#define _NUCLEUS_OBJECT_H
-#include <sys/types.h>
#include <stddef.h>
+#include <sys/types.h>
#include <nucleus/cpu.h>
#include <nucleus/types.h>
diff --git a/include/nucleus/task.h b/include/nucleus/task.h
index 6212be0..f7825a8 100644
--- a/include/nucleus/task.h
+++ b/include/nucleus/task.h
@@ -4,8 +4,8 @@
#include <stdint.h>
#include <sys/types.h>
#include <nucleus/cpu.h>
-#include <nucleus/object.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
#include <nucleus/types.h>
#include <nucleus/vfs.h>
@@ -100,6 +100,5 @@ void block_task(enum State reason, ObjectList *list);
void unblock_task(Task *task);
Task *find_task(pid_t tid);
void schedule(void);
-pid_t clone(int flags);
#endif
diff --git a/include/nucleus/vfs.h b/include/nucleus/vfs.h
index 6bdf673..019c006 100644
--- a/include/nucleus/vfs.h
+++ b/include/nucleus/vfs.h
@@ -2,16 +2,13 @@
#define _NUCLEUS_VFS_H
#include <stddef.h>
+#include <sys/dirent.h>
+#include <sys/limits.h>
#include <sys/types.h>
-#include <dirent.h>
-#include <nucleus/object.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
#include <nucleus/types.h>
-#define NFILES 32
-#define NAME_MAX 255
-#define PATH_MAX 1024
-
typedef Inode *(*mount_callback_t)(FSType *, int, const char *, void *);
/* Structure for a Super Block */
@@ -93,8 +90,6 @@ extern ObjectType fileType;
void init_vfs(void);
File *create_anonymous_file(void);
void register_fstype(const char *name, mount_callback_t mount);
-int mount(const char *src, const char *target, const char *type,
- unsigned long flags, void *data);
Inode *lookup(const char *path, ObjectList *newcustody);
/* Super Block functions */
diff --git a/include/sys/dirent.h b/include/sys/dirent.h
new file mode 100644
index 0000000..efb6cb6
--- /dev/null
+++ b/include/sys/dirent.h
@@ -0,0 +1,36 @@
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+enum DirType {
+ DT_UNKNOWN,
+ DT_REG,
+ DT_DIR,
+ DT_CHR,
+ DT_BLK,
+ DT_FIFO,
+ DT_SOCK,
+ DT_LNK,
+};
+
+/* Structure for a Directory Entry */
+typedef struct dirent {
+ ino_t d_ino;
+ enum DirType d_type;
+ size_t d_namelen;
+ char d_name[];
+} DirEnt;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+size_t getdents(int fd, void *buf, size_t count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/errno.h b/include/sys/errno.h
new file mode 100644
index 0000000..ad17fc5
--- /dev/null
+++ b/include/sys/errno.h
@@ -0,0 +1,30 @@
+#ifndef _SYS_ERRNO_H
+#define _SYS_ERRNO_H
+
+enum {
+ ENONE,
+ EPERM,
+ ENOENT,
+ ESRCH,
+ EINVAL,
+ EBADF,
+ ENOEXEC,
+ EMFILE,
+ EFAULT,
+ EISDIR,
+ ENOTDIR,
+ EACCES,
+ ENODEV,
+ EEXIST,
+ ENXIO,
+ ENOTBLK,
+ ENOMEM,
+ ECHILD,
+ ENOTTY,
+ ELOOP,
+ ENAMETOOLONG,
+ EINTR,
+ ERANGE,
+};
+
+#endif
diff --git a/include/sys/exec.h b/include/sys/exec.h
new file mode 100644
index 0000000..c693096
--- /dev/null
+++ b/include/sys/exec.h
@@ -0,0 +1,14 @@
+#ifndef _SYS_EXEC_H
+#define _SYS_EXEC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int execve(const char *file, char *argv[], char *envp[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/fb.h b/include/sys/fb.h
new file mode 100644
index 0000000..f75a75f
--- /dev/null
+++ b/include/sys/fb.h
@@ -0,0 +1,26 @@
+#ifndef _SYS_FB_H
+#define _SYS_FB_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+/* ioctl() calls */
+enum FrameBufferIoctls {
+ FBIOGET_VSCREENINFO,
+ FBIOPUT_VSCREENINFO,
+ FBIOGET_FSCREENINFO,
+};
+
+/* Structure for fixed framebuffer info */
+typedef struct FBFixInfo {
+ uintptr_t fbmem;
+ size_t fbmemLen;
+} FBFixInfo;
+
+/* Structure for variable framebuffer info */
+typedef struct FBVarInfo {
+ uint32_t xres, yres;
+ uint32_t bpp;
+} FBVarInfo;
+
+#endif
diff --git a/include/sys/file.h b/include/sys/file.h
new file mode 100644
index 0000000..0a1cdbb
--- /dev/null
+++ b/include/sys/file.h
@@ -0,0 +1,35 @@
+#ifndef _SYS_FILE_H
+#define _SYS_FILE_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+
+#define O_CREATE 0100
+#define O_TRUNC 0200
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int open(const char *name, int flags, ...); /* mode_t mode */
+int dup(int oldfd);
+int dup2(int oldfd, int newfd);
+int read(int fd, void *buf, size_t count);
+int write(int fd, void *buf, size_t count);
+off_t lseek(int fd, off_t offset, int whence);
+int close(int fd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/fs.h b/include/sys/fs.h
new file mode 100644
index 0000000..8cd1376
--- /dev/null
+++ b/include/sys/fs.h
@@ -0,0 +1,18 @@
+#ifndef _SYS_FS_H
+#define _SYS_FS_H
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int chdir(const char *path);
+int chroot(const char *path);
+char *getcwd(char *buf, size_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
new file mode 100644
index 0000000..9c95275
--- /dev/null
+++ b/include/sys/ioctl.h
@@ -0,0 +1,6 @@
+#ifndef _SYS_IOCTL_H
+#define _SYS_IOCTL_H
+
+int ioctl(int fd, unsigned long request, ...);
+
+#endif
diff --git a/include/sys/ipc.h b/include/sys/ipc.h
new file mode 100644
index 0000000..e81e077
--- /dev/null
+++ b/include/sys/ipc.h
@@ -0,0 +1,38 @@
+#ifndef _SYS_IPC_H
+#define _SYS_IPC_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+/* Processes */
+enum Process {
+ NO_PROCESS,
+ SYSTEM,
+
+ ANY = 0xFFFFFFFF
+};
+
+/* Message encodings */
+typedef union MessageContent MessageContent;
+union MessageContent {
+ /* Generics */
+ char raw[16];
+ void *ptr;
+ uint32_t num;
+} __attribute__((__transparent_union__));
+
+/* Structure for a message */
+typedef struct Message Message;
+struct Message {
+ pid_t from;
+ uint16_t type;
+ MessageContent msg;
+ Message *next;
+} __attribute__((packed));
+
+Message *nb_send_msg(pid_t to, uint16_t type, MessageContent *msg);
+Message *send_msg(pid_t to, uint16_t type, MessageContent *msg);
+pid_t nb_recv_msg(Message *buf, pid_t from);
+pid_t recv_msg(Message *buf, pid_t from);
+
+#endif
diff --git a/include/sys/kbd.h b/include/sys/kbd.h
new file mode 100644
index 0000000..75d2830
--- /dev/null
+++ b/include/sys/kbd.h
@@ -0,0 +1,9 @@
+#ifndef _SYS_KBD_H
+#define _SYS_KBD_H
+
+/* Structure for the keyboard input */
+typedef struct KeyInput {
+ unsigned char key;
+} KeyInput;
+
+#endif
diff --git a/include/sys/limits.h b/include/sys/limits.h
new file mode 100644
index 0000000..b37ecab
--- /dev/null
+++ b/include/sys/limits.h
@@ -0,0 +1,9 @@
+#ifndef _SYS_LIMITS_H
+#define _SYS_LIMITS_H
+
+#define NFILES 32
+
+#define NAME_MAX 255
+#define PATH_MAX 1024
+
+#endif
diff --git a/include/sys/mman.h b/include/sys/mman.h
new file mode 100644
index 0000000..a39a4cf
--- /dev/null
+++ b/include/sys/mman.h
@@ -0,0 +1,35 @@
+#ifndef _SYS_MMAN_H
+#define _SYS_MMAN_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+/* Virtual Memory Region Protection */
+enum VMRegionProt {
+ PROT_NONE,
+ PROT_EXEC = (1 << 0),
+ PROT_WRITE = (1 << 1),
+ PROT_READ = (1 << 2),
+};
+
+/* Virtual Memory Region flags */
+enum VMRegionFlag {
+ MAP_SHARED = (1 << 0),
+ MAP_PRIVATE = (1 << 1),
+ MAP_ANONYMOUS = (1 << 2),
+};
+
+#define MAP_ANON MAP_ANONYMOUS
+#define MAP_FAILED ((void *) -1)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/mount.h b/include/sys/mount.h
new file mode 100644
index 0000000..c5508ae
--- /dev/null
+++ b/include/sys/mount.h
@@ -0,0 +1,20 @@
+#ifndef _SYS_MOUNT_H
+#define _SYS_MOUNT_H
+
+#define MS_REMOUNT (1 << 0)
+#define MS_BIND (1 << 1)
+#define MS_MOVE (1 << 2)
+#define MS_RDONLY (1 << 3)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mount(const char *src, const char *target, const char *type,
+ unsigned long flags, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/mouse.h b/include/sys/mouse.h
new file mode 100644
index 0000000..698d405
--- /dev/null
+++ b/include/sys/mouse.h
@@ -0,0 +1,5 @@
+#ifndef _SYS_MOUSE_H
+#define _SYS_MOUSE_H
+
+
+#endif
diff --git a/include/sys/param.h b/include/sys/param.h
new file mode 100644
index 0000000..11ca58a
--- /dev/null
+++ b/include/sys/param.h
@@ -0,0 +1,32 @@
+#ifndef _SYS_PARAM_H
+#define _SYS_PARAM_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+#define NBBY 8
+
+/* Bit map related macros. */
+#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+/* Macros for counting and rounding. */
+#ifndef howmany
+# define howmany(x, y) (((x) + ((y) - 1)) / (y))
+#endif
+#ifdef __GNUC__
+# define roundup(x, y) (__builtin_constant_p (y) && powerof2 (y) \
+ ? (((x) + (y) - 1) & ~((y) - 1)) \
+ : ((((x) + ((y) - 1)) / (y)) * (y)))
+#else
+# define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
+#endif
+#define powerof2(x) ((((x) - 1) & (x)) == 0)
+
+/* Macros for min/max. */
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
+#endif
diff --git a/include/sys/sched.h b/include/sys/sched.h
new file mode 100644
index 0000000..6cf7f94
--- /dev/null
+++ b/include/sys/sched.h
@@ -0,0 +1,31 @@
+#ifndef _SYS_SCHED_H
+#define _SYS_SCHED_H
+
+#include <sys/types.h>
+
+/* Flags for clone syscall */
+enum CloneFlag {
+ CLONE_NONE = (0),
+ CLONE_PARENT = (1 << 0),
+ CLONE_THREAD = (1 << 1),
+ CLONE_FILES = (1 << 2),
+ CLONE_FS = (1 << 3),
+ CLONE_VM = (1 << 4),
+ CLONE_SIGHAND = (1 << 5),
+ CLONE_IPC = (1 << 6), // TODO: Add IPC namespace
+};
+
+pid_t getpid(void);
+pid_t clone(int flags);
+_Noreturn void exit(int status);
+
+uid_t getuid(void);
+int setuid(uid_t uid);
+uid_t geteuid(void);
+int seteuid(uid_t euid);
+gid_t getgid(void);
+int setgid(gid_t gid);
+gid_t getegid(void);
+int setegid(gid_t egid);
+
+#endif
diff --git a/include/sys/signal.h b/include/sys/signal.h
new file mode 100644
index 0000000..f80c669
--- /dev/null
+++ b/include/sys/signal.h
@@ -0,0 +1,48 @@
+#ifndef _SYS_SIGNAL_H
+#define _SYS_SIGNAL_H
+
+#include <sys/types.h>
+
+typedef unsigned long int __sigset_t;
+#ifndef sigset_t
+typedef __sigset_t sigset_t;
+#endif
+#ifndef sig_atomic_t
+typedef int sig_atomic_t;
+#endif
+
+typedef void (*sighandler_t)(int);
+
+#define SIG_ERR (sighandler_t) -1
+#define SIG_IGNORE 0
+#define SIG_DFL 1
+#define SIG_BLOCK 2
+#define SIG_UNBLOCK 3
+#define SIG_SETMASK 4
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum Signal {
+ SIGHUP = 1,
+ SIGINT,
+ SIGQUIT,
+ SIGILL,
+ SIGABRT,
+ SIGFPE,
+ SIGKILL,
+ SIGSEGV,
+ SIGPIPE,
+};
+
+int tgkill(pid_t tgid, pid_t tid, int sig);
+int kill(pid_t pid, int sig);
+sighandler_t signal(int signum, sighandler_t handler);
+int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/stat.h b/include/sys/stat.h
new file mode 100644
index 0000000..4be596e
--- /dev/null
+++ b/include/sys/stat.h
@@ -0,0 +1,68 @@
+#ifndef _SYS_STAT_H
+#define _SYS_STAT_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+#define S_IFMT 0170000
+
+#define S_IFSOCK 0140000
+#define S_IFLNK 0120000
+#define S_IFREG 0100000
+#define S_IFBLK 0060000
+#define S_IFDIR 0040000
+#define S_IFCHR 0020000
+#define S_IFIFO 0010000
+
+#define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
+#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
+#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
+#define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
+#define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
+#define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
+
+#define S_ISUID 04000
+#define S_ISGID 02000
+#define S_ISVTX 01000
+
+#define S_IRWXU 00700
+#define S_IRUSR 00400
+#define S_IWUSR 00200
+#define S_IXUSR 00100
+
+#define S_IRWXG 00070
+#define S_IRGRP 00040
+#define S_IWGRP 00020
+#define S_IXGRP 00010
+
+#define S_IRWXO 00007
+#define S_IROTH 00004
+#define S_IWOTH 00002
+#define S_IXOTH 00001
+
+/* Structure for a stat() call */
+typedef struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ size_t st_size;
+} Stat;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mkdir(const char *pathname, mode_t mode);
+int mknod(const char *pathname, mode_t mode, dev_t dev);
+int stat(const char *pathname, struct stat *statbuf);
+int fstat(int fd, struct stat *statbuf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/syscall.h b/include/sys/syscall.h
new file mode 100644
index 0000000..dd5cf96
--- /dev/null
+++ b/include/sys/syscall.h
@@ -0,0 +1,62 @@
+#ifndef _SYS_SYSCALL_H
+#define _SYS_SYSCALL_H
+
+enum SystemCall {
+ /* Task */
+ SYSCALL_DBGPRINTF,
+ SYSCALL_UNAME,
+ SYSCALL_CLONE,
+ SYSCALL_EXIT,
+ SYSCALL_GETPID,
+ SYSCALL_GETUID,
+ SYSCALL_SETUID,
+ SYSCALL_GETEUID,
+ SYSCALL_SETEUID,
+ SYSCALL_GETGID,
+ SYSCALL_SETGID,
+ SYSCALL_GETEGID,
+ SYSCALL_SETEGID,
+ SYSCALL_EXECVE,
+ SYSCALL_WAITPID,
+ SYSCALL_TIME,
+ SYSCALL_TIMES,
+ SYSCALL_SLEEP,
+
+ /* Files */
+ SYSCALL_OPEN,
+ SYSCALL_CLOSE,
+ SYSCALL_READ,
+ SYSCALL_WRITE,
+ SYSCALL_IOCTL,
+ SYSCALL_LSEEK,
+ SYSCALL_STAT,
+ SYSCALL_FSTAT,
+ SYSCALL_GETDENTS,
+ SYSCALL_MKDIR,
+ SYSCALL_RMDIR,
+ SYSCALL_MKNOD,
+ SYSCALL_RENAME,
+ SYSCALL_DUP,
+ SYSCALL_DUP2,
+ SYSCALL_ISATTY,
+ SYSCALL_PIPE,
+
+ /* File System */
+ SYSCALL_MOUNT,
+ SYSCALL_CHDIR,
+ SYSCALL_CHROOT,
+ SYSCALL_GETCWD,
+
+ /* Memory */
+ SYSCALL_MMAP,
+
+ /* Signals */
+ SYSCALL_TGKILL,
+ SYSCALL_KILL,
+ SYSCALL_SIGNAL,
+ SYSCALL_SIGPROCMASK,
+};
+
+int syscall(int number, ...);
+
+#endif
diff --git a/include/sys/time.h b/include/sys/time.h
new file mode 100644
index 0000000..e528978
--- /dev/null
+++ b/include/sys/time.h
@@ -0,0 +1,11 @@
+#ifndef _SYS_TIME_H
+#define _SYS_TIME_H
+
+#include <sys/types.h>
+
+struct timeval {
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
+
+#endif
diff --git a/include/sys/times.h b/include/sys/times.h
new file mode 100644
index 0000000..8e838fb
--- /dev/null
+++ b/include/sys/times.h
@@ -0,0 +1,18 @@
+#ifndef _SYS_TIMES_H
+#define _SYS_TIMES_H
+
+#include <stdint.h>
+
+typedef uint64_t clock_t;
+
+/* Structure for a times call */
+typedef struct tms {
+ clock_t utime;
+ clock_t stime;
+ clock_t cutime;
+ clock_t cstime;
+} Times;
+
+clock_t times(Times *buf);
+
+#endif
diff --git a/include/sys/types.h b/include/sys/types.h
new file mode 100644
index 0000000..3eb3412
--- /dev/null
+++ b/include/sys/types.h
@@ -0,0 +1,16 @@
+#ifndef _SYS_TYPES_H
+#define _SYS_TYPES_H
+
+typedef int pid_t;
+typedef unsigned short uid_t;
+typedef unsigned short gid_t;
+typedef unsigned int dev_t;
+typedef int ino_t;
+typedef int off_t;
+typedef int mode_t;
+typedef int nlink_t;
+typedef _Atomic int refcount_t;
+typedef unsigned int time_t;
+typedef unsigned int suseconds_t;
+
+#endif
diff --git a/include/sys/utsname.h b/include/sys/utsname.h
new file mode 100644
index 0000000..a26346c
--- /dev/null
+++ b/include/sys/utsname.h
@@ -0,0 +1,15 @@
+#ifndef _SYS_UTSNAME_H
+#define _SYS_UTSNAME_H
+
+#define UTSNAME_LENGTH 256
+
+struct utsname {
+ char sysname[UTSNAME_LENGTH];
+ char release[UTSNAME_LENGTH];
+ char version[UTSNAME_LENGTH];
+ char machine[UTSNAME_LENGTH];
+};
+
+int uname(struct utsname *buf);
+
+#endif
diff --git a/include/sys/wait.h b/include/sys/wait.h
new file mode 100644
index 0000000..47ff26c
--- /dev/null
+++ b/include/sys/wait.h
@@ -0,0 +1,22 @@
+#ifndef _SYS_INCLUDE_H
+#define _SYS_INCLUDE_H
+
+#include <sys/types.h>
+
+#define WIFEXITED(status) (status & (1 << 31))
+#define WEXITSTATUS(status) (status & 0x0F)
+#define WIFSIGNALED(status) (!(status & (1 << 31)))
+#define WTERMSIG(status) (status & 0xFF)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+pid_t wait(int *wstatus);
+pid_t waitpid(pid_t pid, int *wstatus, int options);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/kernel/acpi/acpi.c b/kernel/acpi/acpi.c
index 64443b1..e77bbbd 100644
--- a/kernel/acpi/acpi.c
+++ b/kernel/acpi/acpi.c
@@ -4,8 +4,8 @@
*/
#include <stdint.h>
-#include <string.h>
#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include "acpi.h"
diff --git a/kernel/acpi/apic.c b/kernel/acpi/apic.c
index 5c2297d..6051636 100644
--- a/kernel/acpi/apic.c
+++ b/kernel/acpi/apic.c
@@ -5,13 +5,13 @@
* a non-SMP system, and fall back on the PIC.
*/
-#include <stdint.h>
#include <stddef.h>
-#include <string.h>
-#include <nucleus/memory.h>
+#include <stdint.h>
#include <nucleus/cpu.h>
+#include <nucleus/io.h>
+#include <nucleus/lib.h>
+#include <nucleus/memory.h>
#include <nucleus/task.h>
-#include <io.h>
#include "acpi.h"
void cpu_load(void);
diff --git a/kernel/acpi/dsdt.c b/kernel/acpi/dsdt.c
index 15510a1..ef203fa 100644
--- a/kernel/acpi/dsdt.c
+++ b/kernel/acpi/dsdt.c
@@ -4,8 +4,8 @@
* information on IO ports, IRQs, memory mappings and power management.
*/
+#include <nucleus/io.h>
#include <nucleus/kernel.h>
-#include <io.h>
#include "acpi.h"
/* Parse the DSDT for information */
diff --git a/kernel/acpi/fadt.c b/kernel/acpi/fadt.c
index 92ce4c1..cd85323 100644
--- a/kernel/acpi/fadt.c
+++ b/kernel/acpi/fadt.c
@@ -5,7 +5,7 @@
* Description Table.
*/
-#include <io.h>
+#include <nucleus/io.h>
#include "acpi.h"
/* Preferred Power Management Profile */
diff --git a/kernel/acpi/pci.c b/kernel/acpi/pci.c
index b7c74c1..07f2ee5 100644
--- a/kernel/acpi/pci.c
+++ b/kernel/acpi/pci.c
@@ -5,7 +5,7 @@
*/
#include <stdint.h>
-#include <io.h>
+#include <nucleus/io.h>
#include <nucleus/pci.h>
/* PCI Configuration Ports */
diff --git a/kernel/gdt.c b/kernel/gdt.c
index b9cebb6..7e8a1a4 100644
--- a/kernel/gdt.c
+++ b/kernel/gdt.c
@@ -8,11 +8,11 @@
*/
#include <stdint.h>
-#include <string.h>
#include <sys/types.h>
-#include <nucleus/memory.h>
-#include <nucleus/kernel.h>
#include <nucleus/cpu.h>
+#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
+#include <nucleus/memory.h>
#include "desc.h"
/* GDT Entry Indicies */
diff --git a/kernel/idt.c b/kernel/idt.c
index 37d38d6..dc596f4 100644
--- a/kernel/idt.c
+++ b/kernel/idt.c
@@ -6,12 +6,12 @@
*/
#include <stdint.h>
-#include <string.h>
#include <nucleus/cpu.h>
+#include <nucleus/io.h>
#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/task.h>
-#include <io.h>
#include "desc.h"
/* Structure for an IDT Entry */
diff --git a/kernel/main.c b/kernel/main.c
index b7d8eb8..90c102d 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -5,17 +5,18 @@
*/
#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
+#include <sys/exec.h>
+#include <sys/fs.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/task.h>
#include <nucleus/vfs.h>
-#include "multiboot.h"
-#include "desc.h"
#include "acpi/acpi.h"
+#include "desc.h"
+#include "multiboot.h"
extern char _bss[], _end[];
void page_fault_handler(struct InterruptFrame *frame);
diff --git a/kernel/panic.c b/kernel/panic.c
index 68b68b5..46d9b5d 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -5,10 +5,10 @@
* be compiled in.
*/
-#include <string.h>
#include <nucleus/cpu.h>
+#include <nucleus/io.h>
#include <nucleus/kernel.h>
-#include <io.h>
+#include <nucleus/lib.h>
/* Kernel panic */
_Noreturn void
diff --git a/kernel/pic.c b/kernel/pic.c
index 566abb2..6437185 100644
--- a/kernel/pic.c
+++ b/kernel/pic.c
@@ -6,7 +6,7 @@
*/
#include <stdint.h>
-#include <io.h>
+#include <nucleus/io.h>
/* Initialise the PIT to a specified frequency */
static void
diff --git a/kernel/printf.c b/kernel/printf.c
index 858f26e..89199b4 100644
--- a/kernel/printf.c
+++ b/kernel/printf.c
@@ -4,11 +4,11 @@
* screen.
*/
-#include <string.h>
+#include <nucleus/io.h>
#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/task.h>
-#include <io.h>
/* Print formatted text to debug port */
void
diff --git a/kernel/uname.c b/kernel/uname.c
index 10e52c0..a9ec735 100644
--- a/kernel/uname.c
+++ b/kernel/uname.c
@@ -3,13 +3,13 @@
* kernel to a buffer for userspace to read.
*/
-#include <string.h>
+#include <sys/errno.h>
#include <sys/utsname.h>
-#include <errno.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
static const char *SYSNAME = "Nucleus";
-static const char *RELEASE = "0.9.2";
+static const char *RELEASE = "0.9.3";
static const char *VERSION = "SMP PREEMPT "__DATE__" "__TIME__;
static const char *MACHINE = "x86";
diff --git a/lib/printf.c b/lib/printf.c
index 9836835..977e54d 100644
--- a/lib/printf.c
+++ b/lib/printf.c
@@ -1,7 +1,7 @@
-#include <stdint.h>
#include <stdarg.h>
-#include <string.h>
-#include <io.h>
+#include <stdint.h>
+#include <nucleus/io.h>
+#include <nucleus/lib.h>
#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
@@ -242,7 +242,7 @@ repeat:
/* Format a string into a buffer */
int
-sprintf(char *buf, char *fmt, ...)
+sprintf(char *buf, const char *fmt, ...)
{
int ret;
va_list args;
diff --git a/lib/string.c b/lib/string.c
index 945ffa5..3c9be0a 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -2,7 +2,7 @@
/* Compare two strings */
int
-strcmp(char *s1, char *s2)
+strcmp(const char *s1, const char *s2)
{
for (; *s1 == *s2 && *s1 && *s2; s1++, s2++);
return *(unsigned char *) s1 - *(unsigned char *) s2;
@@ -10,7 +10,7 @@ strcmp(char *s1, char *s2)
/* Compare two limited strings */
int
-strncmp(char *s1, char *s2, size_t n)
+strncmp(const char *s1, const char *s2, size_t n)
{
if (!n--) return 0;
for (; *s1 == *s2 && *s1 && *s2 && n; s1++, s2++, n--);
diff --git a/memory/fault.c b/memory/fault.c
index 1de4939..80dc5e0 100644
--- a/memory/fault.c
+++ b/memory/fault.c
@@ -8,9 +8,9 @@
*/
#include <stdint.h>
-#include <string.h>
#include <nucleus/cpu.h>
#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/task.h>
#include "paging.h"
diff --git a/memory/frame.c b/memory/frame.c
index 33ae7ef..428aae9 100644
--- a/memory/frame.c
+++ b/memory/frame.c
@@ -5,11 +5,11 @@
* as needed.
*/
-#include <stdint.h>
#include <stddef.h>
-#include <string.h>
+#include <stdint.h>
#include <sys/types.h>
#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#define INDEX(a) ((a)/32)
diff --git a/memory/heap.c b/memory/heap.c
index 0e0dbed..a0e696a 100644
--- a/memory/heap.c
+++ b/memory/heap.c
@@ -5,10 +5,10 @@
* can be used to store any kernel data structures.
*/
-#include <stdint.h>
#include <stddef.h>
-#include <string.h>
+#include <stdint.h>
#include <nucleus/kernel.h>
+#include <nucleus/lib.h>
#define KHEAP_START 0x200000 /* 2MB */
#define KHEAP_END 0x800000 /* 2MB */
diff --git a/memory/mmap.c b/memory/mmap.c
index b7a99eb..2093bf3 100644
--- a/memory/mmap.c
+++ b/memory/mmap.c
@@ -4,10 +4,10 @@
* available one and use it.
*/
+#include <sys/errno.h>
#include <sys/mman.h>
-#include <errno.h>
-#include <nucleus/object.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
#include <nucleus/task.h>
#include <nucleus/vfs.h>
#include "namespace.h"
diff --git a/memory/page.c b/memory/page.c
index 95b1548..986b4d9 100644
--- a/memory/page.c
+++ b/memory/page.c
@@ -4,8 +4,8 @@
* is, and the frame tracks where in physical memory the data is located.
*/
-#include <nucleus/object.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
#include "paging.h"
#include "namespace.h"
diff --git a/memory/paging.c b/memory/paging.c
index fe08a96..c88eee1 100644
--- a/memory/paging.c
+++ b/memory/paging.c
@@ -6,7 +6,7 @@
*/
#include <stdint.h>
-#include <string.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include "paging.h"
diff --git a/memory/region.c b/memory/region.c
index ef43efc..26cbc37 100644
--- a/memory/region.c
+++ b/memory/region.c
@@ -5,8 +5,8 @@
* is mapped in the task's virtual address space.
*/
-#include <nucleus/object.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
#include <nucleus/task.h>
#include <nucleus/vfs.h>
#include "namespace.h"
diff --git a/object/list.c b/object/list.c
index a4e2f17..6af7a72 100644
--- a/object/list.c
+++ b/object/list.c
@@ -8,8 +8,8 @@
#include <stdarg.h>
#include <nucleus/kernel.h>
-#include <nucleus/object.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
/* Structure for a List Entry */
struct ListEntry {
diff --git a/task/clone.c b/task/clone.c
index 3a9f579..bd87f52 100644
--- a/task/clone.c
+++ b/task/clone.c
@@ -3,11 +3,11 @@
* and copies most of the attributes from the parent task into it.
*/
-#include <sys/types.h>
#include <sys/sched.h>
+#include <sys/types.h>
+#include <nucleus/io.h>
#include <nucleus/task.h>
#include <nucleus/vfs.h>
-#include <io.h>
/* Clone a task */
pid_t
diff --git a/task/exec.c b/task/exec.c
index d4b4c3d..ff80d21 100644
--- a/task/exec.c
+++ b/task/exec.c
@@ -4,11 +4,10 @@
* and finally jumps into user-mode.
*/
-#include <string.h>
-#include <unistd.h>
+#include <sys/errno.h>
+#include <sys/file.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/task.h>
#include <nucleus/vfs.h>
diff --git a/task/signals.c b/task/signals.c
index 47d8c9b..48b075f 100644
--- a/task/signals.c
+++ b/task/signals.c
@@ -4,8 +4,8 @@
* register signal handlers, which it runs when appropriate.
*/
-#include <signal.h>
-#include <errno.h>
+#include <sys/errno.h>
+#include <sys/signal.h>
#include <nucleus/memory.h>
#include <nucleus/object.h>
#include <nucleus/task.h>
diff --git a/task/syscall.c b/task/syscall.c
index ba7937e..f2bf4bb 100644
--- a/task/syscall.c
+++ b/task/syscall.c
@@ -4,17 +4,19 @@
* and runs the relevant function.
*/
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/syscall.h>
+#include <sys/errno.h>
+#include <sys/exec.h>
+#include <sys/file.h>
+#include <sys/fs.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
-#include <sys/wait.h>
+#include <sys/mount.h>
+#include <sys/sched.h>
+#include <sys/signal.h>
#include <sys/stat.h>
+#include <sys/syscall.h>
#include <sys/utsname.h>
-#include <errno.h>
+#include <sys/wait.h>
#include <nucleus/cpu.h>
#include <nucleus/kernel.h>
#include <nucleus/memory.h>
diff --git a/task/task.c b/task/task.c
index b0268e2..3d84436 100644
--- a/task/task.c
+++ b/task/task.c
@@ -3,13 +3,13 @@
* implements the Task object.
*/
-#include <stdint.h>
#include <stddef.h>
-#include <string.h>
+#include <stdint.h>
#include <nucleus/cpu.h>
-#include <nucleus/task.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/object.h>
+#include <nucleus/task.h>
#include <nucleus/vfs.h>
void timer_handler(struct InterruptFrame *frame);
diff --git a/task/uid.c b/task/uid.c
index 5b50c90..f6b28fe 100644
--- a/task/uid.c
+++ b/task/uid.c
@@ -4,8 +4,8 @@
* the required permission when setting any of these attributes.
*/
+#include <sys/errno.h>
#include <sys/types.h>
-#include <errno.h>
#include <nucleus/task.h>
/* Get the current task's UID */
diff --git a/task/wait.c b/task/wait.c
index 35ee29a..2eb72c3 100644
--- a/task/wait.c
+++ b/task/wait.c
@@ -5,7 +5,7 @@
* information from it before releasing it.
*/
-#include <errno.h>
+#include <sys/errno.h>
#include <nucleus/task.h>
/* Wait for a child process to change state */
diff --git a/vfs/devfs/file.c b/vfs/devfs/file.c
index 0217a8e..f0e8d26 100644
--- a/vfs/devfs/file.c
+++ b/vfs/devfs/file.c
@@ -1,9 +1,9 @@
-#include <stdint.h>
#include <stddef.h>
-#include <string.h>
+#include <stdint.h>
+#include <sys/errno.h>
#include <sys/stat.h>
-#include <errno.h>
#include <nucleus/driver.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/vfs.h>
diff --git a/vfs/direntry.c b/vfs/direntry.c
index de7f02a..62ced1f 100644
--- a/vfs/direntry.c
+++ b/vfs/direntry.c
@@ -2,7 +2,7 @@
* This file implements the Directory Entry object and associated operations.
*/
-#include <string.h>
+#include <nucleus/lib.h>
#include <nucleus/object.h>
#include <nucleus/vfs.h>
diff --git a/vfs/ext2fs/file.c b/vfs/ext2fs/file.c
index a84da51..8d4e7a5 100644
--- a/vfs/ext2fs/file.c
+++ b/vfs/ext2fs/file.c
@@ -1,5 +1,5 @@
-#include <string.h>
-#include <errno.h>
+#include <sys/errno.h>
+#include <nucleus/lib.h>
#include <nucleus/vfs.h>
#include "ext2fs.h"
diff --git a/vfs/ext2fs/inode.c b/vfs/ext2fs/inode.c
index 2208ab6..5c39023 100644
--- a/vfs/ext2fs/inode.c
+++ b/vfs/ext2fs/inode.c
@@ -1,5 +1,5 @@
#include <stdint.h>
-#include <string.h>
+#include <nucleus/lib.h>
#include <nucleus/vfs.h>
#include "ext2fs.h"
diff --git a/vfs/ext2fs/super.c b/vfs/ext2fs/super.c
index f7949f0..5983c95 100644
--- a/vfs/ext2fs/super.c
+++ b/vfs/ext2fs/super.c
@@ -1,8 +1,7 @@
-#include <unistd.h>
-#include <fcntl.h>
+#include <sys/errno.h>
+#include <sys/file.h>
#include <sys/mount.h>
#include <sys/stat.h>
-#include <errno.h>
#include <nucleus/task.h>
#include <nucleus/vfs.h>
#include "ext2fs.h"
diff --git a/vfs/file.c b/vfs/file.c
index 8d7e7cc..4a726a2 100644
--- a/vfs/file.c
+++ b/vfs/file.c
@@ -7,9 +7,9 @@
* generic version.
*/
-#include <string.h>
+#include <sys/errno.h>
#include <sys/stat.h>
-#include <errno.h>
+#include <nucleus/lib.h>
#include <nucleus/object.h>
#include <nucleus/vfs.h>
diff --git a/vfs/files.c b/vfs/files.c
index c285e51..87cc794 100644
--- a/vfs/files.c
+++ b/vfs/files.c
@@ -4,14 +4,13 @@
* of the file-based system calls that need to use a file descriptor.
*/
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
+#include <sys/errno.h>
+#include <sys/file.h>
#include <sys/stat.h>
-#include <errno.h>
+#include <nucleus/lib.h>
+#include <nucleus/memory.h>
#include <nucleus/object.h>
#include <nucleus/task.h>
-#include <nucleus/memory.h>
#include <nucleus/vfs.h>
/* Structure for a Files namespace */
diff --git a/vfs/fstype.c b/vfs/fstype.c
index f157a71..d1949f7 100644
--- a/vfs/fstype.c
+++ b/vfs/fstype.c
@@ -4,8 +4,8 @@
* by the VFS to keep track of the installed file systems.
*/
-#include <string.h>
-#include <errno.h>
+#include <sys/errno.h>
+#include <nucleus/lib.h>
#include <nucleus/object.h>
#include <nucleus/vfs.h>
diff --git a/vfs/inode.c b/vfs/inode.c
index 903efd1..f1fdfd7 100644
--- a/vfs/inode.c
+++ b/vfs/inode.c
@@ -7,11 +7,11 @@
* operation can be called on the particular inode.
*/
-#include <string.h>
+#include <sys/errno.h>
#include <sys/stat.h>
-#include <errno.h>
-#include <nucleus/object.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
#include <nucleus/task.h>
#include <nucleus/vfs.h>
diff --git a/vfs/mount.c b/vfs/mount.c
index a321d34..a6700ee 100644
--- a/vfs/mount.c
+++ b/vfs/mount.c
@@ -3,9 +3,10 @@
* mount system call.
*/
-#include <string.h>
+#include <sys/errno.h>
+#include <sys/mount.h>
#include <sys/stat.h>
-#include <errno.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/task.h>
#include <nucleus/vfs.h>
diff --git a/vfs/namespace.c b/vfs/namespace.c
index 1d560a9..e4cf5a0 100644
--- a/vfs/namespace.c
+++ b/vfs/namespace.c
@@ -3,9 +3,9 @@
* task's file system. It tracks a task's root and current working directory.
*/
-#include <string.h>
+#include <sys/errno.h>
#include <sys/stat.h>
-#include <errno.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/object.h>
#include <nucleus/task.h>
diff --git a/vfs/open.c b/vfs/open.c
index cbc4bac..f0fb004 100644
--- a/vfs/open.c
+++ b/vfs/open.c
@@ -5,10 +5,10 @@
*/
#include <stdarg.h>
-#include <string.h>
+#include <sys/errno.h>
+#include <sys/file.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/object.h>
#include <nucleus/task.h>
diff --git a/vfs/stat.c b/vfs/stat.c
index 037a77f..2d3ef06 100644
--- a/vfs/stat.c
+++ b/vfs/stat.c
@@ -2,9 +2,9 @@
* This file implements the stat system call and similar system calls.
*/
-#include <string.h>
+#include <sys/errno.h>
#include <sys/stat.h>
-#include <errno.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/vfs.h>
diff --git a/vfs/tmpfs/file.c b/vfs/tmpfs/file.c
index 9851ec3..841dadc 100644
--- a/vfs/tmpfs/file.c
+++ b/vfs/tmpfs/file.c
@@ -1,6 +1,6 @@
-#include <stdint.h>
#include <stddef.h>
-#include <string.h>
+#include <stdint.h>
+#include <nucleus/lib.h>
#include <nucleus/memory.h>
#include <nucleus/vfs.h>
diff --git a/vfs/vfs.c b/vfs/vfs.c
index 9f8bc2b..eed0cc4 100644
--- a/vfs/vfs.c
+++ b/vfs/vfs.c
@@ -5,6 +5,7 @@
* IPC and device management.
*/
+#include <sys/mount.h>
#include <sys/stat.h>
#include <nucleus/object.h>
#include <nucleus/vfs.h>