summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/request.c4
-rw-r--r--src/kernel/vfs/request.h27
-rw-r--r--src/kernel/vfs/root.c9
3 files changed, 24 insertions, 16 deletions
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 1212aa4..a275fd6 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -57,8 +57,8 @@ _Noreturn void vfs_request_finish(struct vfs_request *req, int ret) {
ret = handle;
}
- if (req->type == VFSOP_OPEN)
- kfree(req->open.path);
+ if (req->input.kern) kfree(req->input.buf_kern);
+ if (req->output.kern) kfree(req->output.buf_kern);
req->caller->state = PS_RUNNING;
regs_savereturn(&req->caller->regs, ret);
diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h
index 3021c6f..52af544 100644
--- a/src/kernel/vfs/request.h
+++ b/src/kernel/vfs/request.h
@@ -22,17 +22,24 @@ enum vfs_operation {
// describes an in-process vfs call
struct vfs_request {
enum vfs_operation type;
- union {
- struct {
- char *path;
- int path_len;
- } open;
- struct {
+ struct { // TODO maybe this should be a separate type
+ bool kern; // if false: use .buf ; if true: use .buf_kern
+ union {
char __user *buf;
- int buf_len;
- int id; // filled in by the kernel
- } rw;
- };
+ char *buf_kern;
+ };
+ int len;
+ } input;
+ struct {
+ bool kern; // if false: use .buf ; if true: use .buf_kern
+ union {
+ char __user *buf;
+ char *buf_kern;
+ };
+ int len;
+ } output;
+
+ int id; // handle.file.id
struct process *caller;
struct vfs_backend *backend;
diff --git a/src/kernel/vfs/root.c b/src/kernel/vfs/root.c
index 29caf14..feb718d 100644
--- a/src/kernel/vfs/root.c
+++ b/src/kernel/vfs/root.c
@@ -8,18 +8,19 @@
int vfs_root_handler(struct vfs_request *req) {
switch (req->type) {
case VFSOP_OPEN:
- if (req->open.path_len == 4
- && !memcmp(req->open.path, "/tty", 4)) {
+ assert(req->input.kern);
+ if (req->input.len == 4
+ && !memcmp(req->input.buf_kern, "/tty", 4)) {
return 0;
}
return -1;
case VFSOP_WRITE:
- switch (req->rw.id) {
+ switch (req->id) {
// every id corresponds to a special file type
// this is a shit way to do this but :shrug:
case 0: { // tty
struct virt_iter iter;
- virt_iter_new(&iter, req->rw.buf, req->rw.buf_len,
+ virt_iter_new(&iter, req->input.buf, req->input.len,
req->caller->pages, true, false);
while (virt_iter_next(&iter))
tty_write(iter.frag, iter.frag_len);