From f8ea51441eb23571b43d7eeb07f91229d9ca03c3 Mon Sep 17 00:00:00 2001 From: Michael Shaw Date: Wed, 18 Oct 2023 13:44:05 -0400 Subject: [PATCH] add error checking for ext2 superblock read --- fs/ext2.c | 4 ++++ fs/vfs.c | 2 ++ include/kernel/vfs.h | 14 ++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 fs/vfs.c create mode 100644 include/kernel/vfs.h diff --git a/fs/ext2.c b/fs/ext2.c index 0d54074..c945443 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -9,6 +9,10 @@ static int ext2_read_super(struct block_device *bdev, struct ext2_superblock *sb if (!buf) return -1; + #ifdef KDEBUG + kprintf(LOG_DEBUG "Reading superblock from device %s, start_lba: %X\n", bdev->name, bdev->lba_start); + #endif + int ret = block_read(bdev, buf, 2, 2); if (ret < 0) { kfree(buf); diff --git a/fs/vfs.c b/fs/vfs.c new file mode 100644 index 0000000..0bba9d5 --- /dev/null +++ b/fs/vfs.c @@ -0,0 +1,2 @@ +/* SDPX-License-Identifier: GPL-2.0-only */ + diff --git a/include/kernel/vfs.h b/include/kernel/vfs.h new file mode 100644 index 0000000..143c89d --- /dev/null +++ b/include/kernel/vfs.h @@ -0,0 +1,14 @@ +/* SDPX-License-Identifier: GPL-2.0-only */ +#ifndef _VFS_H_ +#define _VFS_H_ + +#include +#include + +struct file { + struct inode *f_inode; + uint64_t pos; + uint32_t flags; +}; + +#endif /* _VFS_H_ */