[文件系统]EXT文件系统学习笔记(二)——数据结构

1,ext2超级块结构

struct ext2_super_block {
__le32 s_inodes_count; /* Inodes count */
__le32 s_blocks_count; /* Blocks count */
__le32 s_r_blocks_count; /* Reserved blocks count */
__le32 s_free_blocks_count; /* Free blocks count */
__le32 s_free_inodes_count; /* Free inodes count */
__le32 s_first_data_block; /* First Data Block */
__le32 s_log_block_size; /* 块长度,通常为0,1,2,分别表示1024,2048,4096 */
__le32 s_log_frag_size; /* 碎片长度 */
__le32 s_blocks_per_group; /* # Blocks per group */
__le32 s_frags_per_group; /* # Fragments per group */
__le32 s_inodes_per_group; /* # Inodes per group */
__le32 s_mtime; /* Mount time */
__le32 s_wtime; /* Write time */
__le16 s_mnt_count; /* Mount count */
__le16 s_max_mnt_count; /* Maximal mount count */
__le16 s_magic; /* Magic signature */
__le16 s_state; /* File system state */
__le16 s_errors; /* Behaviour when detecting errors */
__le16 s_minor_rev_level; /* minor revision level */
__le32 s_lastcheck; /* time of last check */
__le32 s_checkinterval; /* max. time between checks */
__le32 s_creator_os; /* OS */
__le32 s_rev_level; /* Revision level */
__le16 s_def_resuid; /* 能够使用保留块的默认UID,系统分别了一定的块,只有该UID的用户才可以使用 */
__le16 s_def_resgid; /* 能够使用保留块的默认GID */
__le32 s_first_ino; /* First non-reserved inode */
__le16 s_inode_size; /* size of inode structure */
__le16 s_block_group_nr; /* block group # of this superblock */
__le32 s_feature_compat; /* compatible feature set */
__le32 s_feature_incompat; /* incompatible feature set */
__le32 s_feature_ro_compat; /* readonly-compatible feature set */
__u8 s_uuid[16]; /* 128-bit uuid for volume */
char s_volume_name[16]; /* 卷名 */
char s_last_mounted[64]; /* 上一次装载的目录*/
__le32 s_algorithm_usage_bitmap; /* For compression */
__u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
__u8 s_prealloc_dir_blocks; /* Nr to pre-allocate for dirs */
__u16 s_padding1;
...
__u32 s_reserved[190]; /* Padding to the end of the block */
};

2,ext2组描述符结构

struct ext2_group_desc
{
__le32 bg_block_bitmap; /* 块位图块 */
__le32 bg_inode_bitmap; /* inode位图块 */
__le32 bg_inode_table; /* inode表块 */
__le16 bg_free_blocks_count; /* 空闲块数目 */
__le16 bg_free_inodes_count; /* 空闲inode数目 */
__le16 bg_used_dirs_count; /* 目录数目 */
__le16 bg_pad;
__le32 bg_reserved[3];
};

3,ext2 inode结构

struct ext2_inode {
__le16 i_mode; /* File mode */
__le16 i_uid; /* Low 16 bits of Owner Uid */
__le32 i_size; /* Size in bytes */
__le32 i_atime; /* Access time */
__le32 i_ctime; /* Creation time */
__le32 i_mtime; /* Modification time */
__le32 i_dtime; /* Deletion Time */
__le16 i_gid; /* Low 16 bits of Group Id */
__le16 i_links_count; /* Links count */
__le32 i_blocks; /* Blocks count */
__le32 i_flags; /* File flags */
union {
struct {
__le32 l_i_reserved1;
} linux1;
struct {
...
} hurd1;
struct {
...
} masix1;
} osd1; /* OS dependent 1 */
__le32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
__le32 i_generation; /* File version (for NFS) */
__le32 i_file_acl; /* File ACL */
__le32 i_dir_acl; /* Directory ACL */
__le32 i_faddr; /* Fragment address */
union {
struct {
	__u8 l_i_frag; /* Fragment number */
	__u8 l_i_fsize; /* Fragment size */
	__u16 i_pad1;
	__le16 l_i_uid_high; /* these 2 fields */
	__le16 l_i_gid_high; /* were reserved2[0] */
	__u32 l_i_reserved2;
} linux2;
struct {
...
} hurd2;
struct {
...
} masix2;
} osd2; /* OS dependent 2 */
};

4,ext2目录结构的表示

struct ext2_dir_entry_2 {
__le32 inode; /* Inode number */
__le16 rec_len; /* Directory entry length */
__u8 name_len; /* Name length */
__u8 file_type;
char name[EXT2_NAME_LEN]; /* File name */
};


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值