From 178d88b2aaa2748809f8a2d80941601e3ca8c951 Mon Sep 17 00:00:00 2001 From: Michael Shaw Date: Sat, 21 Oct 2023 11:11:03 -0400 Subject: [PATCH] fs: add `ino_t` --- fs/ext2.c | 6 +++--- include/fs/vfs.h | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ext2.c b/fs/ext2.c index d26f487..76c5966 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -149,7 +149,7 @@ int ext2_write_block(struct ext2fs *fs, void *buf, size_t block) return block_write(fs->bdev, buf, bdev_block, num_blocks_read); } -int ext2_read_inode(struct ext2fs *fs, struct ext2_inode *out, uint32_t inode) +int ext2_read_inode(struct ext2fs *fs, struct ext2_inode *out, ino_t inode) { uint32_t group = (inode - 1) / fs->sb.inodes_per_group; uint32_t index = (inode - 1) % fs->sb.inodes_per_group; @@ -176,7 +176,7 @@ int ext2_read_inode(struct ext2fs *fs, struct ext2_inode *out, uint32_t inode) return 0; } -int ext2_write_inode(struct ext2fs *fs, struct ext2_inode *in, uint32_t inode) +int ext2_write_inode(struct ext2fs *fs, struct ext2_inode *in, ino_t inode) { uint32_t group = (inode - 1) / fs->sb.inodes_per_group; uint32_t index = (inode - 1) % fs->sb.inodes_per_group; @@ -217,7 +217,7 @@ int ext2_open_file(struct fs *vfs, struct file *file, const char *path) if (!inode) return -ENOMEM; - uint32_t inode_no = 2; + ino_t inode_no = 2; int ret = ext2_read_inode(fs, inode, inode_no); if (ret < 0) { kfree(inode); diff --git a/include/fs/vfs.h b/include/fs/vfs.h index d693da2..dfbbd51 100644 --- a/include/fs/vfs.h +++ b/include/fs/vfs.h @@ -20,6 +20,8 @@ #define SEEK_CUR 1 #define SEEK_END 2 +typedef uint32_t ino_t; + struct inode { uint16_t mode; uint16_t uid; @@ -66,7 +68,7 @@ typedef struct _DIR { struct file { struct inode inode; - uint32_t inode_num; /* inode number */ + ino_t inode_num; /* inode number */ uint32_t type; /* type of the file */ uint64_t size; /* size of the file */