From fbc70ddf7b07a13405775cd7c8000d4e9b9ed901 Mon Sep 17 00:00:00 2001 From: Michael Shaw Date: Sat, 21 Oct 2023 01:09:51 -0400 Subject: [PATCH] vfs: zero fdesc struct on initialization Fixes a bug where using cat on a file twice would fail, because the previous file descriptor slab position would be used again, with the same `pos` value, which was EOF. --- fs/vfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/vfs.c b/fs/vfs.c index d58d499..d928ed6 100644 --- a/fs/vfs.c +++ b/fs/vfs.c @@ -53,6 +53,8 @@ int open(const char *pathname, int flags) return -ENOMEM; } + memset(fd, 0, sizeof(struct file_descriptor)); + /* find the file */ int result = rootfs->ops.open(rootfs, &fd->file, pathname);