ext2: add directory entry type macros

This commit is contained in:
Michael Shaw 2023-10-18 23:59:25 -04:00
commit a1f8375134
2 changed files with 11 additions and 2 deletions

View file

@ -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)

View file

@ -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;