summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-10-03 18:54:57 +0200
committerAnton Kling <anton@kling.gg>2024-10-03 18:54:57 +0200
commit0b1a1eb35169eebcedf62c14cac7f8b83b6cd0ba (patch)
tree1a852086545c126f8e6c297d05ed60d367443def /kernel
parent372c633aa22d826bc515213ad4211791440f60f8 (diff)
kernel/shm: shm_open only create if O_CREAT was supplied
Diffstat (limited to 'kernel')
-rw-r--r--kernel/fs/shm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/fs/shm.c b/kernel/fs/shm.c
index 45f16f4..57ec3c5 100644
--- a/kernel/fs/shm.c
+++ b/kernel/fs/shm.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <errno.h>
+#include <fcntl.h>
#include <fs/shm.h>
#include <fs/vfs.h>
#include <hashmap/hashmap.h>
@@ -82,6 +83,9 @@ int shm_open(const char *name, int oflag, mode_t mode) {
vfs_vm_object_t *internal_object =
hashmap_get_entry(shared_memory_objects, name);
if (!internal_object) {
+ if (!(oflag & O_CREAT)) {
+ return -ENOENT;
+ }
internal_object = kcalloc(1, sizeof(vfs_vm_object_t));
hashmap_add_entry(shared_memory_objects, name, internal_object, NULL, 0);
}