From a1f8375134c210ed18137ae755f5af4245e85023 Mon Sep 17 00:00:00 2001 From: Michael Shaw Date: Wed, 18 Oct 2023 23:59:25 -0400 Subject: [PATCH] ext2: add directory entry type macros --- fs/ext2.c | 4 ++-- include/fs/ext2.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/ext2.c b/fs/ext2.c index 73eb19a..7143d38 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -106,7 +106,7 @@ static void ext2_print_dir(struct ext2fs *fs, struct ext2_inode *inode, int inde kprintf(" "); kprintf("[%s] %s\n", types[MIN(7, entry->file_type)], name); - if (entry->file_type == 2) { + if (entry->file_type == EXT2_DE_DIR) { if (!strcmp(name, ".") || !strcmp(name, "..")) goto next; @@ -117,7 +117,7 @@ static void ext2_print_dir(struct ext2fs *fs, struct ext2_inode *inode, int inde ext2_read_inode(fs, in, entry->inode); ext2_print_dir(fs, in, indent + 1); kfree(in); - } else if (entry->file_type == 1) { + } else if (entry->file_type == EXT2_DE_FILE) { /* print the contents of the file */ struct ext2_inode *in = kmalloc(sizeof(struct ext2_inode), ALLOC_KERN); if (!in) diff --git a/include/fs/ext2.h b/include/fs/ext2.h index 01b148c..c20c3ec 100644 --- a/include/fs/ext2.h +++ b/include/fs/ext2.h @@ -10,6 +10,15 @@ #define EXT2_ROOT_INO 2 #define EXT2_SUPERBLOCK_BLOCKNO 1 +#define EXT2_DE_UNKNOWN 0 +#define EXT2_DE_FILE 1 +#define EXT2_DE_DIR 2 +#define EXT2_DE_CHRDEV 3 +#define EXT2_DE_BLKDEV 4 +#define EXT2_DE_FIFO 5 +#define EXT2_DE_SOCK 6 +#define EXT2_DE_SYMLINK 7 + struct ext2_superblock { uint32_t inodes_count; uint32_t blocks_count;