ext4文件系统文件定位流程

本文详细解析了ext4文件系统中文件的定位过程,从总体结构到超级块、块组描述符表、inode表、extern树、directory entries,最后通过反查inode table找到文件在emmc的具体位置,阐述了mount操作和文件读写时的数据结构交互。
摘要由CSDN通过智能技术生成


Ext4文件系统解析

                                 --以cache.img为例,基于32位的文件系统

目录

Cache文件结构:...2

Cache文件系统结构...2

总体结构...2

超级块:3

块组描述符表:4

Inode talble:6

Extern树...7

Directory Entries.9

反查inode table寻找文件具体位置...10

总结:...14

Cache文件结构:

可见ext4文件系统cache中包含.  ..   hello lost+found hello_world.ko , 其中有四个Directory Entries

和一个Regular file

 

Cache文件系统结构

总体结构

Group 0 Padding

ext4 Super Block

Group Descriptors

Reserved GDT Blocks

Data Block Bitmap

inode Bitmap

inode Table

Data Blocks

1024 bytes

1 block

many blocks

many blocks

1 block

1 block

many blocks

many more blocks

超级块:

Offset

Size

Name

Description

0x0

__le32

s_inodes_count

Total inode count.   0x2000=8192

0x4

__le32

s_blocks_count_lo

Total block count.   0x8000=32768

0x8

__le32

s_r_blocks_count_lo

This number of blocks can only be allocated by the super-user.

0xC

__le32

s_free_blocks_count_lo

Free block count.   0x79f0=31216

0x10

__le32

s_free_inodes_count

Free inode count.   0x1ff2=8178

0x14

__le32

s_first_data_block

First data block. This must be at least 1 for 1k-block filesystems and is typically 0 for all other block sizes.

0x18

__le32

s_log_block_size

Block size is 2 ^ (10 + s_log_block_size).0x2=2^10+2=4096

0x1C

__le32

s_log_cluster_size

Cluster size is (2 ^ s_log_cluster_size) blocks if bigalloc is enabled, zero otherwise.

0x20

__le32

s_blocks_per_group

Blocks per group. 0x8000=32768

0x24

__le32

s_clusters_per_group

Clusters per group, if bigalloc is enabled.

0x28

__le32

s_inodes_per_group

Inodes per group.  0x2000=8192

0x2C

__le32

s_mtime

Mount time, in seconds since the epoch.  0x573bc363

0x30

__le32

s_wtime

Write time, in seconds since the epoch.   0x573bc363

0x34

__le16

s_mnt_count

Number of mounts since the last fsck.     0x06

0x36

__le16

s_max_mnt_count

Number of mounts beyond which a fsck is needed. 0xffff

0x38

__le16

s_magic

Magic signature, 0xEF53      0xEF53 

0x3A

__le16

s_state

File system state. Valid values are:

0x0001

Cleanly umounted

0x0002

Errors detected

0x0004

Orphans being recovered

0x3C

__le16

s_errors

Behaviour when detecting errors. One of:

1

Continue

2

Remount read-only

3

Panic

0x3E

__le16

s_minor_rev_level

Minor revision level. 0x0

0x40

__le32

s_lastcheck

Time of last check, in seconds since the epoch.  0x0

0x44

__le32

s_checkinterval

Maximum time between checks, in seconds. 0x0

0x48

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zjuestcer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值