标签:
# cat /proc/cpuinfo
# cat /proc/sys/net/ipv4/ip_forward # echo "1" > /proc/sys/net/ipv4/ip_forward # echo "0" > /proc/sys/net/ipv4/ip_forward
$ mount
# ln /root/file1 /root/file2
ln -s /path/to/file1.txt /path/to/file2.txt
$ ln FileAFileB#创建一个硬链接 $ ls -il FileAFileB#具有相同的 inode 号 1482256-rw-r--r-- 2 bruno bruno 21May515:55FileA 1482256-rw-r--r-- 2 bruno bruno 21May515:55FileB $ rm FileA $ cat FileB#将看到FileA的内容 $ ln -s FileBFileC#创建软链接 $ ls -il FileBFileC#FileC文件类型是l-链接文件,且与 FileB 具有不同的 inode 1482256-rw-r--r-- 1 bruno bruno 21May515:55FileB 1482226 lrwxrwxrwx 1 bruno bruno 5May516:22FileC->FileB $ rm FileB $ cat FileC#提示不存在该文件,皮之不存毛将焉附?
硬链接 | 软链接 |
硬链接不能在目录间创建 | 可以在不同目录间创建 |
不能跨越文件系统边界 | 可以跨文件系统边界 |
指向源头,即使源头被移动或者移除 | 不会更新 |
Block Offset | Length | Description |
---|---|---|
byte 0 | 512 bytes | boot record (if present) |
byte 512 | 512 bytes | additional boot record data (if present) |
-- block group 0, blocks 1 to 1439 -- | ||
byte 1024 | 1024 bytes | superblock |
block 2 | 1 block | block group descriptor table |
block 3 | 1 block | block bitmap |
block 4 | 1 block | inode bitmap |
block 5 | 23 blocks | inode table |
block 28 | 1412 blocks | data blocks |
Block Offset | Length | Description |
---|---|---|
byte 0 | 512 bytes | boot record (if present) |
byte 512 | 512 bytes | additional boot record data (if present) |
-- block group 0, blocks 1 to 8192 -- | ||
byte 1024 | 1024 bytes | superblock |
block 2 | 1 block | block group descriptor table |
block 3 | 1 block | block bitmap |
block 4 | 1 block | inode bitmap |
block 5 | 214 blocks | inode table |
block 219 | 7974 blocks | data blocks |
-- block group 1, blocks 8193 to 16384 -- | ||
block 8193 | 1 block | superblock backup |
block 8194 | 1 block | block group descriptor table backup |
block 8195 | 1 block | block bitmap |
block 8196 | 1 block | inode bitmap |
block 8197 | 214 blocks | inode table |
block 8408 | 7974 blocks | data blocks |
-- block group 2, blocks 16385 to 24576 -- | ||
block 16385 | 1 block | block bitmap |
block 16386 | 1 block | inode bitmap |
block 16387 | 214 blocks | inode table |
block 16601 | 3879 blocks | data blocks |
Offset (bytes) | Size (bytes) | Description |
---|---|---|
0 | 2 | i_mode |
2 | 2 | i_uid |
4 | 4 | i_size |
8 | 4 | i_atime |
12 | 4 | i_ctime |
16 | 4 | i_mtime |
20 | 4 | i_dtime |
24 | 2 | i_gid |
26 | 2 | i_links_count |
28 | 4 | i_blocks |
32 | 4 | i_flags |
36 | 4 | i_osd1 |
40 | 15 x 4 | i_block |
100 | 4 | i_generation |
104 | 4 | i_file_acl |
108 | 4 | i_dir_acl |
112 | 4 | i_faddr |
116 | 12 |
i_osd2
|
Constant | Value | Description |
---|---|---|
-- file format -- | ||
EXT2_S_IFSOCK | 0xC000 | socket |
EXT2_S_IFLNK | 0xA000 | symbolic link |
EXT2_S_IFREG | 0x8000 | regular file |
EXT2_S_IFBLK | 0x6000 | block device |
EXT2_S_IFDIR | 0x4000 | directory |
EXT2_S_IFCHR | 0x2000 | character device |
EXT2_S_IFIFO | 0x1000 | fifo |
-- process execution user/group override -- | ||
EXT2_S_ISUID | 0x0800 | Set process User ID |
EXT2_S_ISGID | 0x0400 | Set process Group ID |
EXT2_S_ISVTX | 0x0200 | sticky bit |
-- access rights -- | ||
EXT2_S_IRUSR | 0x0100 | user read |
EXT2_S_IWUSR | 0x0080 | user write |
EXT2_S_IXUSR | 0x0040 | user execute |
EXT2_S_IRGRP | 0x0020 | group read |
EXT2_S_IWGRP | 0x0010 | group write |
EXT2_S_IXGRP | 0x0008 | group execute |
EXT2_S_IROTH | 0x0004 | others read |
EXT2_S_IWOTH | 0x0002 | others write |
EXT2_S_IXOTH | 0x0001 | others execute |
Offset (bytes) | Size (bytes) | Description |
---|---|---|
0 | 4 | bg_block_bitmap |
4 | 4 | bg_inode_bitmap |
8 | 4 | bg_inode_table |
12 | 2 | bg_free_blocks_count |
14 | 2 | bg_free_inodes_count |
16 | 2 | bg_used_dirs_count |
18 | 2 | bg_pad |
20 | 12 | bg_reserved |
Constant Name | Value | Description |
---|---|---|
EXT2_BAD_INO | 1 | bad blocks inode |
EXT2_ROOT_INO | 2 | root directory inode |
EXT2_ACL_IDX_INO | 3 | ACL index inode (deprecated?) |
EXT2_ACL_DATA_INO | 4 | ACL data inode (deprecated?) |
EXT2_BOOT_LOADER_INO | 5 | boot loader inode |
EXT2_UNDEL_DIR_INO | 6 | undelete directory inode |
Offset (bytes) | Size (bytes) | Description |
---|---|---|
0 | 4 | inode |
4 | 2 | rec_len |
6 | 1 | name_len[a] |
7 | 1 | file_type[b] |
8 | 0-255 | name |
Constant Name | Value | Description |
---|---|---|
EXT2_FT_UNKNOWN | 0 | Unknown File Type |
EXT2_FT_REG_FILE | 1 | Regular File |
EXT2_FT_DIR | 2 | Directory File |
EXT2_FT_CHRDEV | 3 | Character Device |
EXT2_FT_BLKDEV | 4 | Block Device |
EXT2_FT_FIFO | 5 | Buffer File |
EXT2_FT_SOCK | 6 | Socket File |
EXT2_FT_SYMLINK | 7 | Symbolic Link |
Table . Sample Linked Directory Data Layout, 4KiB blocks
Offset (bytes) | Size (bytes) | Description |
---|---|---|
Directory Entry 0 | ||
0 | 4 | inode number: 783362 |
4 | 2 | record length: 12 |
6 | 1 | name length: 1 |
7 | 1 | file type: EXT2_FT_DIR =2 |
8 | 1 | name: . |
9 | 3 | padding |
Directory Entry 1 | ||
12 | 4 | inode number: 1109761 |
16 | 2 | record length: 12 |
18 | 1 | name length: 2 |
19 | 1 | file type: EXT2_FT_DIR =2 |
20 | 2 | name: .. |
22 | 2 | padding |
Directory Entry 2 | ||
24 | 4 | inode number: 783364 |
28 | 2 | record length: 24 |
30 | 1 | name length: 13 |
31 | 1 | file type: EXT2_FT_REG_FILE |
32 | 13 | name: .bash_profile |
45 | 3 | padding |
Directory Entry 3 | ||
48 | 4 | inode number: 783363 |
52 | 2 | record length: 16 |
54 | 1 | name length: 7 |
55 | 1 | file type: EXT2_FT_REG_FILE |
56 | 7 | name: .bashrc |
63 | 1 | padding |
Directory Entry 4 | ||
64 | 4 | inode number: 783377 |
68 | 2 | record length: 12 |
70 | 1 | name length: 4 |
71 | 1 | file type: EXT2_FT_REG_FILE |
72 | 4 | name: mbox |
Directory Entry 5 | ||
76 | 4 | inode number: 783545 |
80 | 2 | record length: 20 |
82 | 1 | name length: 11 |
83 | 1 | file type: EXT2_FT_DIR =2 |
84 | 11 | name: public_html |
95 | 1 | padding |
Directory Entry 6 | ||
96 | 4 | inode number: 669354 |
100 | 2 | record length: 12 |
102 | 1 | name length: 3 |
103 | 1 | file type: EXT2_FT_DIR =2 |
104 | 3 | name: tmp |
107 | 1 | padding |
Directory Entry 7 | ||
108 | 4 | inode number: 0 |
112 | 2 | record length: 3988 |
114 | 1 | name length: 0 |
115 | 1 | file type: EXT2_FT_UNKNOWN |
116 | 0 | name: |
116 | 3980 | padding |
Offset (bytes) | Size (bytes) | Description |
---|---|---|
-- Linked Directory Entry: . -- | ||
0 | 4 | inode: this directory |
4 | 2 | rec_len: 12 |
6 | 1 | name_len: 1 |
7 | 1 | file_type: EXT2_FT_DIR =2 |
8 | 1 | name: . |
9 | 3 | padding |
-- Linked Directory Entry: .. -- | ||
12 | 4 | inode: parent directory |
16 | 2 | rec_len: (blocksize - this entry‘s length(12)) |
18 | 1 | name_len: 2 |
19 | 1 | file_type: EXT2_FT_DIR =2 |
20 | 2 | name: .. |
22 | 2 | padding |
-- Indexed Directory Root Information Structure -- | ||
24 | 4 | reserved, zero |
28 | 1 | hash_version |
29 | 1 | info_length |
30 | 1 | indirect_levels |
31 | 1 | reserved - unused flags |
Table 4-6. Indexed Directory Entry Structure (dx_entry)
Offset (bytes) | Size (bytes) | Description |
---|---|---|
0 | 4 | hash |
4 | 4 | block |
标签:
原文地址:http://www.cnblogs.com/codetravel/p/4779430.html