本文主要解析磁盘介质中,是如何排布来存储数据的。比如挂载文件系统后,在目录创建一个text.txt文件,里面存储了hello内容。
磁盘中都有哪些信息,磁盘只存储数据吗?
磁盘中hello的放在什么位置,如何找到它的。
本文需要有一些文件系统基础,比如inode。
SD卡制作一个1M的小分区,然后将SD数据填充为全0,1M的一个分区,是为了方便查看里面所有内容。
把sd插入到ubuntu等中,格式化sd卡为ext4文件系统。
mkfs.ext4 /dev/sdb1
将格式化好的文件系统制作成bin文件,方便后续恢复到最初格式化的状态。
dd if=/dev/mmcblk0p1 of=/ext4_orig.bin
磁盘信息如下:
下面的内容就是在格式化该分区为ext4后的所有内容。
- [root@OIL ~]# hexdump -C ext4_orig.bin
- 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000400 80 00 00 00 00 04 00 00 33 00 00 00 d6 03 00 00 |........3.......|
- 00000410 75 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 |u...............|
- 00000420 00 20 00 00 00 20 00 00 80 00 00 00 00 00 00 00 |. ... ..........|
- 00000430 69 1d 07 63 00 00 ff ff 53 ef 01 00 01 00 00 00 |i..c....S.......|
- 00000440 69 1d 07 63 00 00 00 00 00 00 00 00 01 00 00 00 |i..c............|
- 00000450 00 00 00 00 0b 00 00 00 80 00 00 00 38 00 00 00 |............8...|
- 00000460 c2 02 00 00 6b 04 00 00 fc 5d 80 f1 b1 46 44 10 |....k....]...FD.|
- 00000470 a4 0e be ec c1 01 17 c4 00 00 00 00 00 00 00 00 |................|
- 00000480 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000004c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 00 |................|
- 000004d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 000004e0 00 00 00 00 00 00 00 00 00 00 00 00 6b ac d7 31 |............k..1|
- 000004f0 f4 72 4a fb 9a da db 5e ff 31 e5 79 01 00 40 00 |.rJ....^.1.y..@.|
- 00000500 0c 00 00 00 00 00 00 00 69 1d 07 63 00 00 00 00 |........i..c....|
- 00000510 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000560 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000570 00 00 00 00 04 01 00 00 5a 00 00 00 00 00 00 00 |........Z.......|
- 00000580 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000007f0 00 00 00 00 00 00 00 00 00 00 00 00 d5 1b 3e 5b |..............>[|
- 00000800 0a 00 00 00 1a 00 00 00 2a 00 00 00 d6 03 75 00 |........*.....u.|
- 00000810 02 00 00 00 00 00 00 00 aa 2f cb d5 75 00 95 4c |........./..u..L|
- 00000820 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000830 00 00 00 00 00 00 00 00 f3 cf b5 92 00 00 00 00 |................|
- 00000840 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00002800 ff ff 7f 06 00 fe ff 01 00 00 00 00 00 00 00 00 |................|
- 00002810 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00002870 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 |................|
- 00002880 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
- *
- 00002c00 02 00 00 00 0c 00 01 02 2e 00 00 00 02 00 00 00 |................|
- 00002c10 0c 00 02 02 2e 2e 00 00 0b 00 00 00 dc 03 0a 02 |................|
- 00002c20 6c 6f 73 74 2b 66 6f 75 6e 64 00 00 00 00 00 00 |lost+found......|
- 00002c30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00002ff0 00 00 00 00 00 00 00 00 0c 00 00 de 79 67 de 4c |............yg.L|
- 00003000 0b 00 00 00 0c 00 01 02 2e 00 00 00 02 00 00 00 |................|
- 00003010 e8 03 02 02 2e 2e 00 00 00 00 00 00 00 00 00 00 |................|
- 00003020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000033f0 00 00 00 00 00 00 00 00 0c 00 00 de 6a 8e 73 26 |............j.s&|
- 00003400 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00003410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000037f0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00003800 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00003810 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00003bf0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00003c00 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00003c10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00003ff0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00004000 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00004010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000043f0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00004400 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00004410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000047f0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00004800 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00004810 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00004bf0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00004c00 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00004c10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00004ff0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00005000 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00005010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000053f0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00005400 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00005410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000057f0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00005800 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00005810 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00005bf0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00005c00 00 00 00 00 f4 03 00 00 00 00 00 00 00 00 00 00 |................|
- 00005c10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00005ff0 00 00 00 00 00 00 00 00 0c 00 00 de 14 bf a6 d2 |................|
- 00006000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00006800 ff 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00006810 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
- *
- 00006c00 00 00 00 00 03 00 00 00 04 00 00 00 05 00 00 00 |................|
- 00006c10 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 |................|
- 00006c20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000a800 00 00 00 00 00 00 00 00 69 1d 07 63 69 1d 07 63 |........i..ci..c|
- 0000a810 69 1d 07 63 00 00 00 00 00 00 00 00 00 00 00 00 |i..c............|
- 0000a820 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000a870 00 00 00 00 00 00 00 00 00 00 00 00 ca aa 00 00 |................|
- 0000a880 ed 41 00 00 00 04 00 00 69 1d 07 63 69 1d 07 63 |.A......i..ci..c|
- 0000a890 69 1d 07 63 00 00 00 00 00 00 03 00 02 00 00 00 |i..c............|
- 0000a8a0 00 00 08 00 00 00 00 00 0a f3 01 00 04 00 00 00 |................|
- 0000a8b0 00 00 00 00 00 00 00 00 01 00 00 00 0b 00 00 00 |................|
- 0000a8c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000a8f0 00 00 00 00 00 00 00 00 00 00 00 00 26 f3 00 00 |............&...|
- 0000a900 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000a970 00 00 00 00 00 00 00 00 00 00 00 00 3c 74 00 00 |............<t..|
- 0000a980 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000a9f0 00 00 00 00 00 00 00 00 00 00 00 00 9e 68 00 00 |.............h..|
- 0000aa00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000aa70 00 00 00 00 00 00 00 00 00 00 00 00 5e 95 00 00 |............^...|
- 0000aa80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000aaf0 00 00 00 00 00 00 00 00 00 00 00 00 ef e5 00 00 |................|
- 0000ab00 80 81 00 00 00 30 04 04 69 1d 07 63 69 1d 07 63 |.....0..i..ci..c|
- 0000ab10 69 1d 07 63 00 00 00 00 00 00 01 00 10 00 00 00 |i..c............|
- 0000ab20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000ab50 00 00 00 00 00 00 00 00 00 00 00 00 1b 00 00 00 |................|
- 0000ab60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 0000ab70 00 00 00 00 00 00 00 00 00 00 00 00 18 3e 00 00 |.............>..|
- 0000ab80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000abf0 00 00 00 00 00 00 00 00 00 00 00 00 ab dc 00 00 |................|
- 0000ac00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000ac70 00 00 00 00 00 00 00 00 00 00 00 00 6b 21 00 00 |............k!..|
- 0000ac80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000acf0 00 00 00 00 00 00 00 00 00 00 00 00 da 51 00 00 |.............Q..|
- 0000ad00 c0 41 00 00 00 30 00 00 69 1d 07 63 69 1d 07 63 |.A...0..i..ci..c|
- 0000ad10 69 1d 07 63 00 00 00 00 00 00 02 00 18 00 00 00 |i..c............|
- 0000ad20 00 00 08 00 00 00 00 00 0a f3 01 00 04 00 00 00 |................|
- 0000ad30 00 00 00 00 00 00 00 00 0c 00 00 00 0c 00 00 00 |................|
- 0000ad40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 0000ad70 00 00 00 00 00 00 00 00 00 00 00 00 90 ce 00 00 |................|
- 0000ad80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00100200
- [root@OIL ~]#
更便捷的获取磁盘信息的内容,交叉编译dumpe2fs,该工具解析磁盘分区中的内容,直接展现出来,便于我们回过头去分析磁盘信息。
根据下面内容,可以得到上面的一些重要信息:
- [root@OIL ~]# dumpe2fs /dev/mmcblk0p1
- dumpe2fs 1.42.5 (29-Jul-2012)
- Filesystem volume name: <none>
- Last mounted on: <not available>
- Filesystem UUID: fc5d80f1-b146-4410-a40e-beecc10117c4
- Filesystem magic number: 0xEF53
- Filesystem revision #: 1 (dynamic)
- Filesystem features: ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
- Filesystem flags: signed_directory_hash
- Default mount options: user_xattr acl
- Filesystem state: not clean
- Errors behavior: Continue
- Filesystem OS type: Linux
- Inode count: 128
- Block count: 1024
- Reserved block count: 51
- Free blocks: 982
- Free inodes: 117
- First block: 1
- Block size: 1024
- Fragment size: 1024
- Reserved GDT blocks: 7
- Blocks per group: 8192
- Fragments per group: 8192
- Inodes per group: 128
- Inode blocks per group: 16
- Flex block group size: 16
- Filesystem created: Thu Aug 25 14:57:45 2022
- Last mount time: Thu Jan 1 08:11:00 1970
- Last write time: Thu Jan 1 08:11:00 1970
- Mount count: 1
- Maximum mount count: -1
- Last checked: Thu Aug 25 14:57:45 2022
- Check interval: 0 (<none>)
- Lifetime writes: 90 kB
- Reserved blocks uid: 0 (user root)
- Reserved blocks gid: 0 (group root)
- First inode: 11
- Inode size: 128
- Default directory hash: half_md4
- Directory Hash Seed: 6bacd731-f472-4afb-9ada-db5eff31e579
- Checksum: 0xcfc94b0f
-
-
- Group 0: (Blocks 1-1023)
- Primary superblock at 1, Group descriptors at 2-2
- Reserved GDT blocks at 3-9
- Block bitmap at 10 (+9), Inode bitmap at 26 (+25)
- Inode table at 42-57 (+41)
- 982 free blocks, 117 free inodes, 2 directories, 117 unused inodes
- Free blocks: 24-25, 28-41, 58-1023
- Free inodes: 12-128
- [root@OIL ~]#
根据前面查到信息,从磁盘0xa800开始的之后16个块是inode table。我们将所有inode导出到bin文件中,便于后期查看。
- [root@OIL ~]# dd if=/dev/mmcblk0p1 of=/inode_table.bin skip=42 count=16 bs=1024
-
- 16+0 records in
- 16+0 records out
- 16384 bytes (16.0KB) copied, 0.002334 seconds, 6.7MB/s
- [root@OIL ~]#
- [root@OIL ~]# hexdump -C inode_table.bin
- 00000000 00 00 00 00 00 00 00 00 69 1d 07 63 69 1d 07 63 |........i..ci..c|
- 00000010 69 1d 07 63 00 00 00 00 00 00 00 00 00 00 00 00 |i..c............|
- 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000070 00 00 00 00 00 00 00 00 00 00 00 00 ca aa 00 00 |................|
- 00000080 ed 41 00 00 00 04 00 00 69 1d 07 63 69 1d 07 63 |.A......i..ci..c|
- 00000090 69 1d 07 63 00 00 00 00 00 00 03 00 02 00 00 00 |i..c............|
- 000000a0 00 00 08 00 00 00 00 00 0a f3 01 00 04 00 00 00 |................|
- 000000b0 00 00 00 00 00 00 00 00 01 00 00 00 0b 00 00 00 |................|
- 000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000000f0 00 00 00 00 00 00 00 00 00 00 00 00 26 f3 00 00 |............&...|
- 00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000170 00 00 00 00 00 00 00 00 00 00 00 00 3c 74 00 00 |............<t..|
- 00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 9e 68 00 00 |.............h..|
- 00000200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000270 00 00 00 00 00 00 00 00 00 00 00 00 5e 95 00 00 |............^...|
- 00000280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000002f0 00 00 00 00 00 00 00 00 00 00 00 00 ef e5 00 00 |................|
- 00000300 80 81 00 00 00 30 04 04 69 1d 07 63 69 1d 07 63 |.....0..i..ci..c|
- 00000310 69 1d 07 63 00 00 00 00 00 00 01 00 10 00 00 00 |i..c............|
- 00000320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000350 00 00 00 00 00 00 00 00 00 00 00 00 1b 00 00 00 |................|
- 00000360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- 00000370 00 00 00 00 00 00 00 00 00 00 00 00 18 3e 00 00 |.............>..|
- 00000380 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000003f0 00 00 00 00 00 00 00 00 00 00 00 00 ab dc 00 00 |................|
- 00000400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000470 00 00 00 00 00 00 00 00 00 00 00 00 6b 21 00 00 |............k!..|
- 00000480 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 000004f0 00 00 00 00 00 00 00 00 00 00 00 00 da 51 00 00 |.............Q..|
- 00000500 c0 41 00 00 00 30 00 00 69 1d 07 63 69 1d 07 63 |.A...0..i..ci..c|
- 00000510 69 1d 07 63 00 00 00 00 00 00 02 00 18 00 00 00 |i..c............|
- 00000520 00 00 08 00 00 00 00 00 0a f3 01 00 04 00 00 00 |................|
- 00000530 00 00 00 00 00 00 00 00 0c 00 00 00 0c 00 00 00 |................|
- 00000540 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000570 00 00 00 00 00 00 00 00 00 00 00 00 90 ce 00 00 |................|
- 00000580 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00004000
- [root@OIL ~]#
格式化ext4,挂载后,默认创建了lost+found,如下
- [root@OIL sd]# ls
- lost+found/
- [root@OIL sd]#
查看这个目录对应的inode信息为第11个inode
- [root@OIL sd]# stat lost\+found/
- File: lost+found/
- Size: 12288 Blocks: 24 IO Block: 1024 directory
- Device: b301h/45825d Inode: 11 Links: 2
- Access: (0700/drwx------) Uid: ( 0/ root) Gid: ( 0/ root)
- Access: 1970-01-01 08:24:40.000000000
- Modify: 2022-08-25 14:57:45.000000000
- Change: 2022-08-25 14:57:45.000000000
-
- [root@OIL sd]#
根据inode table,和inode号,得出该inode的信息为:
- [root@OIL sd]# dd if=/inode_table.bin of=inode11.bin skip=10 count=1 bs=128
- 1+0 records in
- 1+0 records out
- 128 bytes (128B) copied, 0.000835 seconds, 149.7KB/s
- [root@OIL sd]# hexdump -C inode11.bin
- 00000000 c0 41 00 00 00 30 00 00 69 1d 07 63 69 1d 07 63 |.A...0..i..ci..c|
- 00000010 69 1d 07 63 00 00 00 00 00 00 02 00 18 00 00 00 |i..c............|
- 00000020 00 00 08 00 00 00 00 00 0a f3 01 00 04 00 00 00 |................|
- 00000030 00 00 00 00 00 00 00 00 0c 00 00 00 0c 00 00 00 |................|
- 00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
- *
- 00000070 00 00 00 00 00 00 00 00 00 00 00 00 90 ce 00 00 |................|
- 00000080
- [root@OIL sd]#
显然,找到inode结构体的定义来和上面的信息一一对应起来。ext4 inode结构体定义:
- struct ext4_inode {
- __le16 i_mode; /* File mode */
- __le16 i_uid; /* Low 16 bits of Owner Uid */
- __le32 i_size_lo; /* Size in bytes */
- __le32 i_atime; /* Access time */
- __le32 i_ctime; /* Inode Change 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_lo; /* Blocks count */
- __le32 i_flags; /* File flags */
- union {
- struct {
- __le32 l_i_version;
- } linux1;
- struct {
- __u32 h_i_translator;
- } hurd1;
- struct {
- __u32 m_i_reserved1;
- } masix1;
- } osd1; /* OS dependent 1 */
- __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
- __le32 i_generation; /* File version (for NFS) */
- __le32 i_file_acl_lo; /* File ACL */
- __le32 i_size_high;
- __le32 i_obso_faddr; /* Obsoleted fragment address */
- union {
- struct {
- __le16 l_i_blocks_high; /* were l_i_reserved1 */
- __le16 l_i_file_acl_high;
- __le16 l_i_uid_high; /* these 2 fields */
- __le16 l_i_gid_high; /* were reserved2[0] */
- __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
- __le16 l_i_reserved;
- } linux2;
- struct {
- __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
- __u16 h_i_mode_high;
- __u16 h_i_uid_high;
- __u16 h_i_gid_high;
- __u32 h_i_author;
- } hurd2;
- struct {
- __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
- __le16 m_i_file_acl_high;
- __u32 m_i_reserved2[2];
- } masix2;
- } osd2; /* OS dependent 2 */
- __le16 i_extra_isize;
- __le16 i_checksum_hi; /* crc32c(uuid+inum+inode) BE */
- __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */
- __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */
- __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
- __le32 i_crtime; /* File Creation time */
- __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
- __le32 i_version_hi; /* high 32 bits for 64-bit version */
- };
文件大小12288:
access时间:
创建一个新文件
0x18*1024 =0x6000
通过上面的简单分析,我们可以看到磁盘中不仅存储数据信息,还要存储与该数据相关的很多信息,如大小,时间,位置等等(是一句废话,怎么可能只存储数据)。
inode分为磁盘inode和vfs看到的内存中的inode,这俩不完全一样。磁盘inode安装文件系统来定义,vfs的inode要比磁盘inode信息要多一些。
通过文件名确定inode编号,通过inode编号找到文件的inode信息,根据inode信息找到文件的存储位置,大小等信息。那么文件名和inode直接的关系是哪里建立的,保存在哪里?后面再分析。