aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/fs/ext2/ext2.c23
-rw-r--r--core/fs/ext2/ext2_fs.h1
2 files changed, 15 insertions, 9 deletions
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index 76bd1d5a..4bc0a535 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -25,22 +25,17 @@ static enum dirent_type ext2_cvt_type(unsigned int d_file_type)
return inode_type[d_file_type];
}
-/*
- * get the group's descriptor of group_num
- */
-static const struct ext2_group_desc *
-ext2_get_group_desc(struct fs_info *fs, uint32_t group_num)
+static const void *__ext2_get_group_desc(struct fs_info *fs, uint32_t group_num)
{
struct ext2_sb_info *sbi = EXT2_SB(fs);
uint32_t desc_block, desc_index;
- const struct ext2_group_desc *desc_data_block;
+ uint8_t *p;
if (group_num >= sbi->s_groups_count) {
printf ("ext2_get_group_desc"
"block_group >= groups_count - "
"block_group = %d, groups_count = %d",
group_num, sbi->s_groups_count);
-
return NULL;
}
@@ -49,8 +44,17 @@ ext2_get_group_desc(struct fs_info *fs, uint32_t group_num)
desc_block += sbi->s_first_data_block + 1;
- desc_data_block = get_cache(fs->fs_dev, desc_block);
- return &desc_data_block[desc_index];
+ p = get_cache(fs->fs_dev, desc_block);
+ return p + sbi->s_desc_size * desc_index;
+}
+
+/*
+ * get the group's descriptor of group_num
+ */
+static inline const struct ext2_group_desc *
+ext2_get_group_desc(struct fs_info *fs, uint32_t group_num)
+{
+ return __ext2_get_group_desc(fs, group_num);
}
/*
@@ -306,6 +310,7 @@ static int ext2_fs_init(struct fs_info *fs)
if (sb.s_desc_size < sizeof(struct ext2_group_desc))
sb.s_desc_size = sizeof(struct ext2_group_desc);
sbi->s_desc_per_block = BLOCK_SIZE(fs) / sb.s_desc_size;
+ sbi->s_desc_size = sb.s_desc_size;
sbi->s_groups_count = (sb.s_blocks_count - sb.s_first_data_block
+ EXT2_BLOCKS_PER_GROUP(fs) - 1)
/ EXT2_BLOCKS_PER_GROUP(fs);
diff --git a/core/fs/ext2/ext2_fs.h b/core/fs/ext2/ext2_fs.h
index 803a9954..d8d07ebd 100644
--- a/core/fs/ext2/ext2_fs.h
+++ b/core/fs/ext2/ext2_fs.h
@@ -278,6 +278,7 @@ struct ext2_sb_info {
uint32_t s_first_data_block; /* First Data Block */
int s_inode_size;
uint8_t s_uuid[16]; /* 128-bit uuid for volume */
+ int s_desc_size; /* size of group descriptor */
};
static inline struct ext2_sb_info *EXT2_SB(struct fs_info *fs)