diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/arch/amd64/driver/fsroot.c | 2 | ||||
-rw-r--r-- | src/kernel/syscalls.c | 27 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/kernel/arch/amd64/driver/fsroot.c b/src/kernel/arch/amd64/driver/fsroot.c index 7856fba..3bbf2d1 100644 --- a/src/kernel/arch/amd64/driver/fsroot.c +++ b/src/kernel/arch/amd64/driver/fsroot.c @@ -25,7 +25,7 @@ static int handle(struct vfs_request *req) { // TODO getsize for the other kernel provided directories case VFSOP_GETSIZE: return sizeof dir; - default: return 0; + default: return -ENOSYS; } } diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 5dca49f..288aa1e 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -266,7 +266,7 @@ long _syscall_write(handle_t handle_num, const void __user *buf, size_t len, lon long _syscall_getsize(handle_t hid) { struct handle *h = process_handle_get(process_current, hid); if (!h) SYSCALL_RETURN(-1); - if (h->type != HANDLE_FILE) SYSCALL_RETURN(-2); + if (h->type != HANDLE_FILE) SYSCALL_RETURN(-ENOSYS); vfsreq_create((struct vfs_request) { .type = VFSOP_GETSIZE, .id = h->file_id, @@ -276,6 +276,28 @@ long _syscall_getsize(handle_t hid) { return -1; // dummy } +long _syscall_remove(handle_t hid) { + if (hid < 0 || hid >= HANDLE_MAX) return -1; + struct handle **hslot = &process_current->handles[hid]; + struct handle *h = *hslot; + if (!h) SYSCALL_RETURN(-1); + if (h->type == HANDLE_FILE) { + vfsreq_create((struct vfs_request) { + .type = VFSOP_REMOVE, + .id = h->file_id, + .caller = process_current, + .backend = h->backend, + }); + handle_close(*hslot); + *hslot = NULL; + return -1; // dummy + } else { + handle_close(*hslot); + *hslot = NULL; + SYSCALL_RETURN(-ENOSYS); + } +} + long _syscall_close(handle_t hid) { if (hid < 0 || hid >= HANDLE_MAX) return -1; struct handle **h = &process_current->handles[hid]; @@ -441,6 +463,9 @@ long _syscall(long num, long a, long b, long c, long d, long e) { case _SYSCALL_GETSIZE: _syscall_getsize(a); break; + case _SYSCALL_REMOVE: + _syscall_remove(a); + break; case _SYSCALL_CLOSE: _syscall_close(a); break; |