Mercurial > hg > toybox
comparison toys/e2fs.h @ 694:786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 13 Nov 2012 17:14:08 -0600 |
parents | aadd28817955 |
children |
comparison
equal
deleted
inserted
replaced
693:4a5a250e0633 | 694:786841fdb1e0 |
---|---|
1 /* vi: set ts=4: | 1 /* mke2fs.h - Headers for ext2 |
2 * | |
3 * mke2fs.h - Headers for ext2 | |
4 * | 2 * |
5 * Copyright 2006 Rob Landley <rob@landley.net> | 3 * Copyright 2006 Rob Landley <rob@landley.net> |
6 */ | 4 */ |
7 | 5 |
8 // Stuff defined in linux/ext2_fs.h | 6 // Stuff defined in linux/ext2_fs.h |
9 | 7 |
10 #define EXT2_SUPER_MAGIC 0xEF53 | 8 #define EXT2_SUPER_MAGIC 0xEF53 |
11 | 9 |
12 struct ext2_superblock { | 10 struct ext2_superblock { |
13 uint32_t inodes_count; // Inodes count | 11 uint32_t inodes_count; // Inodes count |
14 uint32_t blocks_count; // Blocks count | 12 uint32_t blocks_count; // Blocks count |
15 uint32_t r_blocks_count; // Reserved blocks count | 13 uint32_t r_blocks_count; // Reserved blocks count |
16 uint32_t free_blocks_count; // Free blocks count | 14 uint32_t free_blocks_count; // Free blocks count |
17 uint32_t free_inodes_count; // Free inodes count | 15 uint32_t free_inodes_count; // Free inodes count |
18 uint32_t first_data_block; // First Data Block | 16 uint32_t first_data_block; // First Data Block |
19 uint32_t log_block_size; // Block size | 17 uint32_t log_block_size; // Block size |
20 uint32_t log_frag_size; // Fragment size | 18 uint32_t log_frag_size; // Fragment size |
21 uint32_t blocks_per_group; // Blocks per group | 19 uint32_t blocks_per_group; // Blocks per group |
22 uint32_t frags_per_group; // Fragments per group | 20 uint32_t frags_per_group; // Fragments per group |
23 uint32_t inodes_per_group; // Inodes per group | 21 uint32_t inodes_per_group; // Inodes per group |
24 uint32_t mtime; // Mount time | 22 uint32_t mtime; // Mount time |
25 uint32_t wtime; // Write time | 23 uint32_t wtime; // Write time |
26 uint16_t mnt_count; // Mount count | 24 uint16_t mnt_count; // Mount count |
27 uint16_t max_mnt_count; // Maximal mount count | 25 uint16_t max_mnt_count; // Maximal mount count |
28 uint16_t magic; // Magic signature | 26 uint16_t magic; // Magic signature |
29 uint16_t state; // File system state | 27 uint16_t state; // File system state |
30 uint16_t errors; // Behaviour when detecting errors | 28 uint16_t errors; // Behaviour when detecting errors |
31 uint16_t minor_rev_level; // minor revision level | 29 uint16_t minor_rev_level; // minor revision level |
32 uint32_t lastcheck; // time of last check | 30 uint32_t lastcheck; // time of last check |
33 uint32_t checkinterval; // max. time between checks | 31 uint32_t checkinterval; // max. time between checks |
34 uint32_t creator_os; // OS | 32 uint32_t creator_os; // OS |
35 uint32_t rev_level; // Revision level | 33 uint32_t rev_level; // Revision level |
36 uint16_t def_resuid; // Default uid for reserved blocks | 34 uint16_t def_resuid; // Default uid for reserved blocks |
37 uint16_t def_resgid; // Default gid for reserved blocks | 35 uint16_t def_resgid; // Default gid for reserved blocks |
38 uint32_t first_ino; // First non-reserved inode | 36 uint32_t first_ino; // First non-reserved inode |
39 uint16_t inode_size; // size of inode structure | 37 uint16_t inode_size; // size of inode structure |
40 uint16_t block_group_nr; // block group # of this superblock | 38 uint16_t block_group_nr; // block group # of this superblock |
41 uint32_t feature_compat; // compatible feature set | 39 uint32_t feature_compat; // compatible feature set |
42 uint32_t feature_incompat; // incompatible feature set | 40 uint32_t feature_incompat; // incompatible feature set |
43 uint32_t feature_ro_compat; // readonly-compatible feature set | 41 uint32_t feature_ro_compat; // readonly-compatible feature set |
44 char uuid[16]; // 128-bit uuid for volume | 42 char uuid[16]; // 128-bit uuid for volume |
45 char volume_name[16]; // volume name | 43 char volume_name[16]; // volume name |
46 char last_mounted[64]; // directory where last mounted | 44 char last_mounted[64]; // directory where last mounted |
47 uint32_t alg_usage_bitmap; // For compression | 45 uint32_t alg_usage_bitmap; // For compression |
48 // For EXT2_COMPAT_PREALLOC | 46 // For EXT2_COMPAT_PREALLOC |
49 uint8_t prealloc_blocks; // Nr of blocks to try to preallocate | 47 uint8_t prealloc_blocks; // Nr of blocks to try to preallocate |
50 uint8_t prealloc_dir_blocks; //Nr to preallocate for dirs | 48 uint8_t prealloc_dir_blocks; //Nr to preallocate for dirs |
51 uint16_t padding1; | 49 uint16_t padding1; |
52 // For EXT3_FEATURE_COMPAT_HAS_JOURNAL | 50 // For EXT3_FEATURE_COMPAT_HAS_JOURNAL |
53 uint8_t journal_uuid[16]; // uuid of journal superblock | 51 uint8_t journal_uuid[16]; // uuid of journal superblock |
54 uint32_t journal_inum; // inode number of journal file | 52 uint32_t journal_inum; // inode number of journal file |
55 uint32_t journal_dev; // device number of journal file | 53 uint32_t journal_dev; // device number of journal file |
56 uint32_t last_orphan; // start of list of inodes to delete | 54 uint32_t last_orphan; // start of list of inodes to delete |
57 uint32_t hash_seed[4]; // HTREE hash seed | 55 uint32_t hash_seed[4]; // HTREE hash seed |
58 uint8_t def_hash_version; // Default hash version to use | 56 uint8_t def_hash_version; // Default hash version to use |
59 uint8_t padding2[3]; | 57 uint8_t padding2[3]; |
60 uint32_t default_mount_opts; | 58 uint32_t default_mount_opts; |
61 uint32_t first_meta_bg; // First metablock block group | 59 uint32_t first_meta_bg; // First metablock block group |
62 uint32_t mkfs_time; // Creation timestamp | 60 uint32_t mkfs_time; // Creation timestamp |
63 uint32_t jnl_blocks[17]; // Backup of journal inode | 61 uint32_t jnl_blocks[17]; // Backup of journal inode |
64 // uint32_t reserved[172]; // Padding to the end of the block | 62 // uint32_t reserved[172]; // Padding to the end of the block |
65 }; | 63 }; |
66 | 64 |
67 struct ext2_group | 65 struct ext2_group |
68 { | 66 { |
69 uint32_t block_bitmap; // Block number of block bitmap | 67 uint32_t block_bitmap; // Block number of block bitmap |
70 uint32_t inode_bitmap; // Block number of inode bitmap | 68 uint32_t inode_bitmap; // Block number of inode bitmap |
71 uint32_t inode_table; // Block number of inode table | 69 uint32_t inode_table; // Block number of inode table |
72 uint16_t free_blocks_count; // How many free blocks in this group? | 70 uint16_t free_blocks_count; // How many free blocks in this group? |
73 uint16_t free_inodes_count; // How many free inodes in this group? | 71 uint16_t free_inodes_count; // How many free inodes in this group? |
74 uint16_t used_dirs_count; // How many directories? | 72 uint16_t used_dirs_count; // How many directories? |
75 uint16_t reserved[7]; // pad to 32 bytes | 73 uint16_t reserved[7]; // pad to 32 bytes |
76 }; | 74 }; |
77 | 75 |
78 struct ext2_dentry { | 76 struct ext2_dentry { |
79 uint32_t inode; // Inode number | 77 uint32_t inode; // Inode number |
80 uint16_t rec_len; // Directory entry length | 78 uint16_t rec_len; // Directory entry length |
81 uint8_t name_len; // Name length | 79 uint8_t name_len; // Name length |
82 uint8_t file_type; | 80 uint8_t file_type; |
83 char name[0]; // File name | 81 char name[0]; // File name |
84 }; | 82 }; |
85 | 83 |
86 struct ext2_inode { | 84 struct ext2_inode { |
87 uint16_t mode; // File mode | 85 uint16_t mode; // File mode |
88 uint16_t uid; // Low 16 bits of Owner Uid | 86 uint16_t uid; // Low 16 bits of Owner Uid |
89 uint32_t size; // Size in bytes | 87 uint32_t size; // Size in bytes |
90 uint32_t atime; // Access time | 88 uint32_t atime; // Access time |
91 uint32_t ctime; // Creation time | 89 uint32_t ctime; // Creation time |
92 uint32_t mtime; // Modification time | 90 uint32_t mtime; // Modification time |
93 uint32_t dtime; // Deletion Time | 91 uint32_t dtime; // Deletion Time |
94 uint16_t gid; // Low 16 bits of Group Id | 92 uint16_t gid; // Low 16 bits of Group Id |
95 uint16_t links_count; // Links count | 93 uint16_t links_count; // Links count |
96 uint32_t blocks; // Blocks count | 94 uint32_t blocks; // Blocks count |
97 uint32_t flags; // File flags | 95 uint32_t flags; // File flags |
98 uint32_t reserved1; | 96 uint32_t reserved1; |
99 uint32_t block[15]; // Pointers to blocks | 97 uint32_t block[15]; // Pointers to blocks |
100 uint32_t generation; // File version (for NFS) | 98 uint32_t generation; // File version (for NFS) |
101 uint32_t file_acl; // File ACL | 99 uint32_t file_acl; // File ACL |
102 uint32_t dir_acl; // Directory ACL (or top bits of file length) | 100 uint32_t dir_acl; // Directory ACL (or top bits of file length) |
103 uint32_t faddr; // Last block in file | 101 uint32_t faddr; // Last block in file |
104 uint8_t frag; // Fragment number | 102 uint8_t frag; // Fragment number |
105 uint8_t fsize; // Fragment size | 103 uint8_t fsize; // Fragment size |
106 uint16_t pad1; | 104 uint16_t pad1; |
107 uint16_t uid_high; // High bits of uid | 105 uint16_t uid_high; // High bits of uid |
108 uint16_t gid_high; // High bits of gid | 106 uint16_t gid_high; // High bits of gid |
109 uint32_t reserved2; | 107 uint32_t reserved2; |
110 }; | 108 }; |
111 | 109 |
112 #define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 | 110 #define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 |
113 #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 | 111 #define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 |
114 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 | 112 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 |
130 | 128 |
131 // Ext2 directory file types. Only the low 3 bits are used. The | 129 // Ext2 directory file types. Only the low 3 bits are used. The |
132 // other bits are reserved for now. | 130 // other bits are reserved for now. |
133 | 131 |
134 enum { | 132 enum { |
135 EXT2_FT_UNKNOWN, | 133 EXT2_FT_UNKNOWN, |
136 EXT2_FT_REG_FILE, | 134 EXT2_FT_REG_FILE, |
137 EXT2_FT_DIR, | 135 EXT2_FT_DIR, |
138 EXT2_FT_CHRDEV, | 136 EXT2_FT_CHRDEV, |
139 EXT2_FT_BLKDEV, | 137 EXT2_FT_BLKDEV, |
140 EXT2_FT_FIFO, | 138 EXT2_FT_FIFO, |
141 EXT2_FT_SOCK, | 139 EXT2_FT_SOCK, |
142 EXT2_FT_SYMLINK, | 140 EXT2_FT_SYMLINK, |
143 EXT2_FT_MAX | 141 EXT2_FT_MAX |
144 }; | 142 }; |