summaryrefslogtreecommitdiff
path: root/kernel/fs/fifo.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-04-02 12:03:52 +0200
committerAnton Kling <anton@kling.gg>2024-04-02 12:03:52 +0200
commite25a47fcc4db09ab9b845a691297da67243e6049 (patch)
treedfb7c473e001fa93a1a8018c36992a5bc77ae5c3 /kernel/fs/fifo.c
parent2229fd91f7230ae7068814ae029b733945852eb1 (diff)
Kernel: Use "struct list" to handle file descriptors instead of a fixed sized array
Diffstat (limited to 'kernel/fs/fifo.c')
-rw-r--r--kernel/fs/fifo.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/fs/fifo.c b/kernel/fs/fifo.c
index f2ad933..a0a9248 100644
--- a/kernel/fs/fifo.c
+++ b/kernel/fs/fifo.c
@@ -1,4 +1,5 @@
#include "fifo.h"
+#include <assert.h>
#include <errno.h>
#define STARTING_SIZE 4096
@@ -63,13 +64,12 @@ FIFO_FILE *create_fifo_object(void) {
}
int create_fifo(void) {
- int fd_n = 0;
- for (; current_task->file_descriptors[fd_n]; fd_n++)
- ;
vfs_fd_t *fd = kmalloc(sizeof(vfs_fd_t));
+ int fd_n;
+ assert(list_add(&current_task->file_descriptors, fd, &fd_n));
+
fd->flags = O_RDWR | O_NONBLOCK;
- current_task->file_descriptors[fd_n] = fd;
fd->inode = kmalloc(sizeof(vfs_inode_t));
fd->inode->internal_object = (void *)create_fifo_object();