summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authordzwdz2021-09-19 21:51:59 +0200
committerdzwdz2021-09-19 21:51:59 +0200
commitda8fb00c576f6f977da0e75d57901a28d9f02826 (patch)
treefe1420687e5704455973937b5b5c590c276a065a /src/kernel
parent9a93ed59ce8e9311dd29e148048c6c20ba54388c (diff)
slightly tidy up some syscalls
yay for pointless changes
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/syscalls.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index f09085e..497aa7f 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -67,16 +67,13 @@ handle_t _syscall_open(const char __user *path, int len) {
struct vfs_mount *mount;
char *path_buf = NULL;
- if (len > PATH_MAX)
+ if (PATH_MAX < len)
return -1;
-
- // fail if there are no handles left
if (process_find_handle(process_current) < 0)
return -1;
- // copy the path to the kernel
- // path_buf gets freed in vfs_request_finish
- path_buf = kmalloc(len);
+ // copy the path to the kernel, simplify it
+ path_buf = kmalloc(len); // gets freed in vfs_request_finish
if (!virt_cpy_from(process_current->pages, path_buf, path, len))
goto fail;
@@ -96,7 +93,6 @@ handle_t _syscall_open(const char __user *path, int len) {
.caller = process_current,
.backend = mount->backend,
});
-
fail:
kfree(path_buf);
return -1;
@@ -107,19 +103,17 @@ int _syscall_mount(handle_t handle, const char __user *path, int len) {
struct vfs_backend *backend = NULL;
char *path_buf = NULL;
- if (len > PATH_MAX) return -1;
+ if (PATH_MAX < len) return -1;
- // copy the path to the kernel
+ // copy the path to the kernel to simplify it
path_buf = kmalloc(len);
if (!virt_cpy_from(process_current->pages, path_buf, path, len))
goto fail;
-
- // simplify it
len = path_simplify(path_buf, path_buf, len);
if (len < 0) goto fail;
// TODO remove trailing slash
- if (handle >= 0) { // mounting a real backend
+ if (handle >= 0) { // mounting a real backend?
if (handle >= HANDLE_MAX)
goto fail;
if (process_current->handles[handle].type != HANDLE_FS_FRONT)