玉米吃了有什么好处| 帕金森病是什么原因引起的| 阿拉伯是什么意思| 二月二十二日是什么星座| 拉黑色的屎是什么原因| 胶原蛋白起什么作用| 什么卫什么海| 白化病是什么| 两个a型血的人生的孩子什么血型| 巨蟹座有什么特点| opple是什么牌子| 嗓子哑是什么原因引起的| 脚后跟疼是什么情况| 女性尿路感染是什么原因造成的| 姨妈有血块是什么原因| 女人白带多是什么原因| 命门火衰是什么意思| 牙齿深覆合是什么意思| 梨子是什么季节的水果| 刑警是干什么的| 吃什么不胖| 有什么中药可以壮阳| 动卧是什么意思| 醋酸氯已定是什么药| 隐血试验阴性是什么意思| 鹅口疮是什么原因引起的| 麒麟长什么样| 伤官见官什么意思| 音字五行属什么| 吃什么药死的快| 人的价值是什么| 扫码是什么意思| 什么叫扁平疣长什么样| 尿尿疼吃什么药| 心跳突然加快是什么原因| 腰臀比是什么意思| 毛豆不能和什么一起吃| 有始无终是什么生肖| 宁静什么意思| 梦见狗死了是什么预兆| 相生相克是什么意思| icu是什么意思| 月经期不能吃什么水果| 织女是什么意思| 夏天适合吃什么水果| 宫颈癌前期有什么症状| 纷纷扬扬是什么意思| 过期的牛奶有什么用途| 9999是什么意思| 叶黄素是什么| 五四运动的精神是什么| 吃什么能让肠道蠕动快| vintage什么意思| 室性早搏是什么原因引起的| 520是什么意思表白| 天蝎座和什么座最配| adh医学上是什么意思| 高危型hpv有什么症状| 信仰是什么意思| 什么牌子的大米好吃| 标准是什么意思| 三餐两点什么意思| 五十岁叫什么之年| 阴阳脸是什么意思| 婴儿什么时候可以睡枕头| 焦糖色搭配什么颜色好看| 经期吃什么让血量增加| 鼻烟壶是干什么用的| 不什么不什么| 运动喝什么水补充能量| 手口足吃什么药| 肌电图主要检查什么病| 身体缺钾有什么症状| 山的五行属什么| 螺子黛是什么| 画什么点睛| 什么的豆角| 西瓜又什么又什么| 什么地| 苔藓是什么意思| 痴男怨女是什么意思| 吃完饭胃疼是什么原因| 什么世什么名| 罗汉果有什么作用| 月经来了吃什么好| 芭蕉花炖猪心治什么病| 玉仁玫白膏有什么功效| 黄精和什么搭配补肾效果最好| 惊厥是什么原因引起的| 心焦是什么意思| 蔡司是什么| 律动是什么意思| 龙的三合生肖是什么| 孕初期吃什么对胎儿好| 腱鞘炎用什么药| 芥酸对身体有什么危害| 什么叫布施| 河粉是什么做的| 例假是什么意思| 子宫内膜增厚吃什么药| 什么动物怕热| 痛经吃什么药最有效| 寸止什么意思| 母亲节一般送什么礼物| 开路是什么意思| 禾加末念什么| tin是什么| 尿检查什么| 人突然消瘦是什么原因| 涮菜都有什么菜| 月经期适合吃什么食物| 露水夫妻是什么意思| 007最新一部叫什么| 立普妥是什么药| 3月11日是什么星座| 清热燥湿是什么意思| 什么的垂下| lot是什么意思| 皮肚是什么| 胸膜炎吃什么药好| 一个金字旁一个本念什么| 鼻子闻不到味道是什么原因| 润六月是什么意思| 先天性是什么意思| 浮尘是什么意思| 什么是德训鞋| 银消病用什么药效果最好| 有什么办法可以怀孕| 子宫肌瘤是什么原因引起的| 脾大有什么危害| 转氨酶偏高吃什么药| 羊肉不能和什么食物一起吃| 搀扶是什么意思| 早泄吃什么补| 亦什么意思| 义务兵是什么意思| 小孩不说话什么原因| 潘驴邓小闲什么意思| 月经来有血块是什么原因| 颈椎病吃什么药最好| 中子是什么| bys是什么药| 压差小是什么原因引起的| 鬼剃头是什么病| 结肠炎不能吃什么食物| 腹股沟淋巴结肿大是什么原因| cg动画是什么意思| 硕是什么意思| 鱼露是什么| 12月29号是什么星座| 胸闷气短什么原因| 脓毒症是什么病| 眼睛淤青用什么方法能快点消除| 小孩子口臭是什么原因| 缘分是什么意思| 避孕药吃多了有什么副作用| 气血不足看什么科室| 香槟玫瑰花语是什么意思| 没吃多少东西但肚子很胀是什么| 男人尿多是什么原因| 4.22是什么日子| mv是什么单位| 什么叫穿刺| 茶宠为什么会变色| 孕吐吃什么| 尿比重高是什么意思| 血稠吃什么药| 七夕节干什么| 喝酒后头疼是什么原因| 舌头烧灼感是什么原因| 取次是什么意思| 弱水三千只取一瓢什么意思| msv是什么单位| 新生儿老是打嗝是什么原因| 早上九点到十点是什么时辰| 中药龙骨是什么| 什么药治脂肪肝| 头晕为什么做眼震检查| 胃酸吃什么能马上缓解| 笋壳鱼是什么鱼| 轻度异常脑电图是什么意思| 方巾是干什么用的| 莫名其妙是什么意思| 子宫内膜病变有什么症状| 女生小便带血是什么原因| 小s和黄子佼为什么分手| 忽视是什么意思| 女人下巴长痘痘是什么原因| 头孢不能和什么药一起吃| 777是什么意思| 青年补钙吃什么好| 口角炎用什么药膏| 春运是什么意思| qq黄钻有什么用| 门的单位是什么| 本卦和变卦是什么关系| 什么血型是万能血型| 龙和什么生肖最配| 什么是牙周炎| 手指关节疼是什么原因| 硫酸亚铁是什么东西| 梦见生孩子是什么意思| 硫酸钠是什么| 吃羊肉不能吃什么东西| 视力5.3是什么概念| 2月11日是什么星座| 吹弹可破的意思是什么| 金不换是什么意思| 防血栓是什么意思| 经期可以吃什么水果| 免疫力和抵抗力有什么区别| 谷丙转氨酶偏高吃什么药| 厨子什么意思| 11.7号是什么星座| 井泉水命什么意思| 朋友妻不可欺是什么意思| 吃什么补津液| 落枕挂什么科| 睡觉憋气是什么原因引起的| 葫芦是什么意思| 什么东西护肝养肝| 眉毛痒痒代表什么预兆| 口腔溃疡什么症状| 澎湃的什么| 钾低了会出现什么症状| 小龙虾和什么不能一起吃| 肌肉劳损吃什么药| 什么样的星星| 子欲养而亲不待是什么意思| 儿童结膜炎用什么眼药水| 骨质破坏是什么意思| 办理健康证需要什么| 心灵鸡汤是什么意思| 十二指肠溃疡是什么原因引起的| 早谢是什么症状| 什么药补血最快| lively是什么意思| 皮肤上出现小红点是什么原因| 翠字五行属什么| 青花鱼是什么鱼| 什么可以保护眼睛| 9.27日是什么星座| 各什么各什么| 我俩太不公平这是什么歌| 钙盐是什么| 红颜知己是什么关系| 吃叶酸有什么好处| 骨赘形成是什么意思| 补充免疫力吃什么好| 月子中心需要什么资质| 鹰击长空是什么意思| 91视频是什么| 膝关节置换后最怕什么| 蓝桉什么意思| 红细胞高是什么意思| 为什么微信运动总是显示步数为0| 荷尔蒙爆发是什么意思| 嘴唇发紫是什么原因引起的| mg是什么| 肝肾衰竭有什么症状| 银耳长在什么地方| 今天属什么生肖老黄历| 条件兵是什么意思| 什么原因得疱疹| 百度

中纪委机关报:有贪官喝年份茅台一次喝掉30万元

百度 因此,只要人口从农村流向城市,整个国家的生产率就会提高,经济增长的动力就不会衰竭,与他们的户籍无关。

This information has been compiled from resources published on the internet, the Linux kernel source and information gained from experimentation.  

The primary focus of the document is to provide enough information to allow someone to read the file system. 

Introduction

When Linus was first creating Linux, he used the Minix filesystem.  This served initial development well but soon there was a need for something bigger and better.

In April 1992, the Extended File System was created.  Although solving the problems of Minix, it had problems of it's own so a successor was created.  This new filesystem was known as the Second Extended File System or Ext2 FS (or EXT2).

Structure

The file system is created from a sequential collection of blocks. These blocks can be either 1k, 2k or 4k in size. These blocks are divided up into groups for various reasons which will be discussed below.

The starting point for the filesystem is the superblock. This is a structure 1024 bytes in length and is always located at an offset of 1024 bytes from the start of the filesystem.  This means that it might be in block 0 or block 1, depending on the block size of the filesystem.  This is the reason for the s_first_data_block entry in the superblock.

The following is a list of the structure used by Linux. Note that other OS's may use a different structure. For details see ???.h

field name type comment
s_inodes_count ULONG Count of inodes in the filesystem
s_blocks_count ULONG Count of blocks in the filesystem
s_r_blocks_count ULONG Count of the number of reserved blocks
s_free_blocks_count ULONG Count of the number of free blocks
s_free_inodes_count ULONG Count of the number of free inodes
s_first_data_block ULONG The first block which contains data
s_log_block_size ULONG Indicator of the block size
s_log_frag_size LONG Indicator of the size of the fragments
s_blocks_per_group ULONG Count of the number of blocks in each block group
s_frags_per_group ULONG Count of the number of fragments in each block group
s_inodes_per_group ULONG Count of the number of inodes in each block group
s_mtime ULONG The time that the filesystem was last mounted
s_wtime ULONG The time that the filesystem was last written to
s_mnt_count USHORT The number of times the file system has been mounted
s_max_mnt_count SHORT The number of times the file system can be mounted
s_magic USHORT Magic number indicating ex2fs
s_state USHORT Flags indicating the current state of the filesystem
s_errors USHORT Flags indicating the procedures for error reporting
s_pad USHORT padding
s_lastcheck ULONG The time that the filesystem was last checked
s_checkinterval ULONG The maximum time permissible between checks
s_creator_os ULONG Indicator of which OS created the filesystem
s_rev_level ULONG The revision level of the filesystem
s_reserved ULONG[235] padding to 1024 bytes

s_r_blocks_count :
this is the number of blocks which are reserved for the super user

s_first_data_block :
Depending on the block size, the first data block will be either 0 or 1. See diagram below

s_log_block_size :
0 = 1k block size
1 = 2k
2 = 4k

s_log_frag_size :
At the moment, it seems that fragments are not implemented. In the future I may have to find out how they work.

s_blocks_per_group
The filesystem is divided up into block groups. Note that the last block group may be incomplete

s_inodes_per_group
Each block group has space reserved for a number of inodes.

s_mtime, s_wtime
This may be the mount time, or the umount time. I am not sure which.

s_mnt_count, s_max_mnt_count
Once this count reaches the maximum, the filesystem must be checked, the count is then reset.

s_magic
This should contain the magic number 0xEF53

s_state
This contains a set of flags which indicate wether the filesystem is clean etc.

s_errors
This contains flags which indicate how the filesystem should be treated if errors are found.

s_creator_os
For Linux this is ???

s_rev_level
The current revision is ???

The information in the superblock is used to access the rest of the data on the disk.

The number of block groups = the number of blocks / the number of blocks per group; // rounded up

(There are several calculations which require divisions rounded up.  I wrote a function called div2 which does the division and then checks to see if it should round up the result)

All block and inode addresses start at 1. The first block on the disk is block 1. 0 is used to indicate no block. (Sparse files can have these inside them)

Each block group can be found at the block address ((group_number - 1)* blocks_per_group) and is of course blocks_per_group long. Group numbers are 1 based as well

Each group is just a series of blocks, however the first blocks in the group have a special purpose. The remainder are used for storing data.

|Superblock | Group Descriptors |Block Bitmap|INode Bitmap|INode Table|Data blocks|
|-------------------------------|-------------------------------------------------|
|This is the same for all groups| this is specific to each group                  |

As discussed above, the superblock is stored at offset 1024 on the disk.  There are also backup superblocks stored in the first datablock of all blockgroups grater than one.  With the advent of revision 1 of the filesystem, there is a flag SPARSE_SUPERBLOCK which means that the superblock is not stored on every block group but just a select few.  This improves performance as changes to the superblock do not have to be written to as many places.

The Group Descriptors contains information on the block groups. This data is covers all the groups and is stored in all the groups for redundancy. This is an array of the following structure

field name type comment
bg_block_bitmap ULONG The address of the block containing the block bitmap for this group
bg_inode_bitmap ULONG The address of the block containing the inode bitmap for this group
bg_inode_table ULONG The address of the block containing the inode table for this group
bg_free_blocks_count USHORT The count of free blocks in this group
bg_free_inodes_count USHORT The count of free inodes in this group
bg_used_dirs_count USHORT The number inodes in this group which are directories
bg_pad USHORT padding
bg_reserved ULONG[3] padding

The size of the descriptors can be calculated as (sizeof(ext2_group) * number_of_groups) / block size; // rounded up if necessary

The information in this structure us used to locate the block and inode bitmaps and inode table.

Remember that the first entry corresponds to block group 1.

The block bitmap is a bitmap indicating which blocks in the group have been allocated. If the bit is set then the block is allocated. The size of the bitmap is (blocks_per_group / 8) / block_size;// with both divisions rounded up.

It is necessary to find out which group a particular group is in to be able to look up the bitmap. The group = ((block_number - 1) / blocks_per_group) + 1; // rounded up

The block in that group is then block_number - (group * blocks_per_group)

The inode bitmap is essentially the same as the block bitmap, but indicates which inodes are allocated. The size of the inode bitmpap is (inodes_per_group / 8) / block_size;// with both divisions rounded up.

The same calculations can be used for finding the group of a particular inode. The group = ((INode_number - 1) / INodes_per_group) + 1; // rounded up

The inode in that group is then INode_Number - (Group * INodes_per_group)

The inode table is an array of the inodes for that particular group. Again, the first entry is for the first inode in that group.

field name type description
i_mode USHORT File mode
i_uid USHORT Owner Uid
i_size ULONG Size in bytes
i_atime ULONG Access time
i_ctime ULONG Creation time
i_mtime ULONG Modification time
i_dtime ULONG Deletion Time
i_gid USHORT Group Id
i_links_count USHORT Links count
i_blocks ULONG Blocks count
i_flags ULONG File flags
i_reserved1 ULONG OS dependent
i_block ULONG[15] Pointers to blocks
i_version ULONG File version (for NFS)
i_file_acl ULONG File ACL
i_dir_acl ULONG Directory ACL
i_faddr ULONG Fragment address
i_frag UCHAR Fragment number
i_fsize UCHAR Fragment size
i_pad1 USHORT  
i_reserved2 ULONG[2]  

The file mode is a set of flags that specify the type of file and the access permissions

identifier value comment
S_IFMT F000 format mask
S_IFSOCK A000 socket
S_IFLNK C000 symbolic link
S_IFREG 8000 regular file
S_IFBLK 6000 block device
S_IFDIR 4000 directory
S_IFCHR 2000 character device
S_IFIFO 1000 fifo
     
S_ISUID 0800 SUID
S_ISGID 0400 SGID
S_ISVTX 0200 sticky bit
     
S_IRWXU 01C0 user mask
S_IRUSR 0100 read
S_IWUSR 0080 write
S_IXUSR 0040 execute
     
S_IRWXG 0038 group mask
S_IRGRP 0020 read
S_IWGRP 0010 write
S_IXGRP 0008 execute
     
S_IRWXO 0007 other mask
S_IROTH 0004 read
S_IWOTH 0002 write
S_IXOTH 0001 execute

The i_block entry is an array of block addresses. The first EXT2_NDIR_BLOCKS (12) are direct block addresses. The data in these blocks is the content of the file. (According to ???, ??% of files in a unix environment are less than 12k, assuming a 1k block size the decision to use 12 direct blocks makes a lot of sense).

The next block EXT2_IND_BLOCK in the indirect block. This is the address of a block which contains a list of addresses of blocks which contain the data. There are block_size / sizeof(ULONG) addresses in this block.

The EXT2_DIND_BLOCK is similar, but it is a double indirect block. It contains the address of a block which has a list of indirect block addresses. Each indirect block then has another list is blocks.

The EXT2_TIND_BLOCK is similar again, but it is the triple indirect block. It contains a list of double indirect blocks etc.

Now that you know how to find and read inodes, you can start to read the files. There are a set of special inodes which are reserved for certain purposes. These include

indetifier value description
EXT2_BAD_INO 1 Bad blocks inode
EXT2_ROOT_INO 2 Root inode
EXT2_ACL_IDX_INO 3 ACL inode
EXT2_ACL_DATA_INO 4 ACL inode
EXT2_BOOT_LOADER_INO 5 Boot loader inode
EXT2_UNDEL_DIR_INO 6 Undelete directory inode
EXT2_FIRST_INO 11 First non reserved inode

The most important inode here is the root inode. This is the inode at the root of the file system. This inode is a directory, which like all directories has the following structure:

field name type description
inode ULONG address if inode
rec_len USHORT length of this record
name_len USHORT length of file name
name CHAR[0] the file name

A directory is a list of these structures. The structures can not pass over a block boundary, so the last record is extended to fill the block. And entry with an inode of 0 should be ignored.

References

团长相当于地方什么官 5.22是什么星座 早上6点半是什么时辰 肺结节是什么病 桃皮绒是什么面料
牛鞭是什么东西 黄山毛峰是什么茶 辣条吃多了有什么危害 一什么千什么 孕妇喝咖啡有什么危害
做梦和别人吵架意味着什么 龙筋是什么 吃什么东西可以降压 大便是红色的是什么原因 兔子肉不能和什么一起吃
1981年属什么 遗精是什么意思啊 甲亢什么症状表现 晶莹的近义词是什么 大姨妈一个月来两次是什么原因
网球肘是什么症状hcv8jop8ns2r.cn 肝喜欢什么食物有哪些hcv8jop2ns4r.cn 成双成对是什么意思yanzhenzixun.com 总掉头发是什么原因naasee.com 喜结连理是什么意思hcv8jop6ns4r.cn
耳朵里痒是什么原因adwl56.com bg是什么意思hcv8jop2ns1r.cn 蹭饭是什么意思hcv7jop5ns0r.cn 11月4号是什么星座cj623037.com 反复发烧是什么原因hcv7jop4ns5r.cn
用减一笔是什么字zhongyiyatai.com 外阴萎缩是什么症状hcv8jop4ns7r.cn 胃肠感冒发烧吃什么药hcv9jop4ns7r.cn 大拇指发麻是什么原因hcv8jop0ns1r.cn 特首是什么意思hcv8jop4ns7r.cn
老年阴道炎用什么药hcv8jop4ns9r.cn 憨是什么意思hcv9jop6ns1r.cn 颈椎脑供血不足吃什么药hcv7jop9ns8r.cn 为什么不能空腹喝牛奶hcv8jop8ns3r.cn 1950年是什么年hcv8jop0ns7r.cn
百度