summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/comus/fs.h11
-rw-r--r--kernel/include/comus/limits.h4
-rw-r--r--kernel/include/comus/procs.h4
-rw-r--r--kernel/include/comus/syscalls.h3
-rw-r--r--kernel/include/comus/user.h4
5 files changed, 23 insertions, 3 deletions
diff --git a/kernel/include/comus/fs.h b/kernel/include/comus/fs.h
index 2f678b6..044330b 100644
--- a/kernel/include/comus/fs.h
+++ b/kernel/include/comus/fs.h
@@ -148,6 +148,15 @@ struct file {
void (*close)(struct file *file);
};
+/// open flags
+enum {
+ O_CREATE = 0x01,
+ O_RDONLY = 0x02,
+ O_WRONLY = 0x04,
+ O_APPEND = 0x08,
+ O_RDWR = 0x10,
+};
+
/// file system vtable, used for opening
/// and stating files. filesystem mount functions must
/// set fs_name, fs_disk, open, and stat.
@@ -200,7 +209,7 @@ struct file_system {
/// filesystem name
const char *fs_name;
/// opens a file
- int (*open)(struct file_system *fs, const char *fullpath,
+ int (*open)(struct file_system *fs, const char *fullpath, int flags,
struct file **out);
/// stats a file
int (*stat)(struct file_system *fs, const char *fullpath,
diff --git a/kernel/include/comus/limits.h b/kernel/include/comus/limits.h
index 4cb348d..1ef13b4 100644
--- a/kernel/include/comus/limits.h
+++ b/kernel/include/comus/limits.h
@@ -12,6 +12,10 @@
/// max number of processes
#define N_PROCS 256
+/// process limits
+#define N_OPEN_FILES 64
+#define N_ARGS 64
+
/// max nubmer of pci devices
#define N_PCI_DEV 256
diff --git a/kernel/include/comus/procs.h b/kernel/include/comus/procs.h
index 7b1a70a..3df31c3 100644
--- a/kernel/include/comus/procs.h
+++ b/kernel/include/comus/procs.h
@@ -13,6 +13,7 @@
#include <comus/limits.h>
#include <comus/memory.h>
#include <comus/syscalls.h>
+#include <comus/fs.h>
#include <lib.h>
#include <elf.h>
@@ -59,6 +60,9 @@ struct pcb {
char *heap_start;
size_t heap_len;
+ // open files
+ struct file *open_files[N_OPEN_FILES];
+
// elf metadata
Elf64_Ehdr elf_header;
Elf64_Phdr elf_segments[N_ELF_SEGMENTS];
diff --git a/kernel/include/comus/syscalls.h b/kernel/include/comus/syscalls.h
index f714184..8b671c2 100644
--- a/kernel/include/comus/syscalls.h
+++ b/kernel/include/comus/syscalls.h
@@ -30,9 +30,10 @@
#define SYS_poweroff 17
#define SYS_drm 18
#define SYS_ticks 19
+#define SYS_seek 20
// UPDATE THIS DEFINITION IF MORE SYSCALLS ARE ADDED!
-#define N_SYSCALLS 20
+#define N_SYSCALLS 21
// interrupt vector entry for system calls
#define VEC_SYSCALL 0x80
diff --git a/kernel/include/comus/user.h b/kernel/include/comus/user.h
index a1a718b..1b35ac4 100644
--- a/kernel/include/comus/user.h
+++ b/kernel/include/comus/user.h
@@ -9,13 +9,15 @@
#ifndef USER_H_
#define USER_H_
+#include "comus/memory.h"
#include <comus/procs.h>
#include <comus/fs.h>
/**
* Load a user elf program from a file into a pcb
*/
-int user_load(struct pcb *pcb, struct file *file);
+int user_load(struct pcb *pcb, struct file *file, const char **args,
+ mem_ctx_t args_ctx);
/**
* Clone a user process. Used for fork().