Mercurial > hg > toybox
comparison toys/mke2fs.c @ 80:7a058d60faf1
One more field, minor shrinking, and start on block groups.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 27 Jan 2007 15:10:48 -0500 |
parents | 1aff4181427b |
children | f95f6fd94eed |
comparison
equal
deleted
inserted
replaced
79:1aff4181427b | 80:7a058d60faf1 |
---|---|
77 // Fill out superblock structure | 77 // Fill out superblock structure |
78 | 78 |
79 // Determine appropriate block size, set log_block_size and log_frag_size. | 79 // Determine appropriate block size, set log_block_size and log_frag_size. |
80 | 80 |
81 if (!TT.blocksize) TT.blocksize = (length && length < 1<<29) ? 1024 : 4096; | 81 if (!TT.blocksize) TT.blocksize = (length && length < 1<<29) ? 1024 : 4096; |
82 if (TT.blocksize == 1024) temp = 0; | 82 for (temp = 0; temp < 7; temp++) if (TT.blocksize == 1024<<temp) break; |
83 else if (TT.blocksize == 2048) temp = 1; | 83 if (temp==7) error_exit("bad blocksize"); |
84 else if (TT.blocksize == 4096) temp = 2; | |
85 else error_exit("bad blocksize"); | |
86 sb->log_block_size = sb->log_frag_size = SWAP_LE32(temp); | 84 sb->log_block_size = sb->log_frag_size = SWAP_LE32(temp); |
87 | 85 |
88 // Fill out blocks_count and r_blocks_count | 86 // Fill out blocks_count, r_blocks_count, first_data_block |
89 | 87 |
90 if (!TT.blocks) TT.blocks = length/TT.blocksize; | 88 if (!TT.blocks) TT.blocks = length/TT.blocksize; |
91 sb->blocks_count = SWAP_LE32(TT.blocks); | 89 sb->blocks_count = SWAP_LE32(TT.blocks); |
92 | 90 |
93 if (!TT.reserved_percent) TT.reserved_percent = 5; | 91 if (!TT.reserved_percent) TT.reserved_percent = 5; |
94 temp = (TT.blocks * (uint64_t)TT.reserved_percent) /100; | 92 temp = (TT.blocks * (uint64_t)TT.reserved_percent) /100; |
95 sb->r_blocks_count = SWAP_LE32(temp); | 93 sb->r_blocks_count = SWAP_LE32(temp); |
94 | |
95 sb->first_data_block = TT.blocksize == 1024 ? 1 : 0; | |
96 | 96 |
97 // Set blocks_per_group and frags_per_group, which is the size of an | 97 // Set blocks_per_group and frags_per_group, which is the size of an |
98 // allocation bitmap that fits in one block (I.E. how many bits per block)? | 98 // allocation bitmap that fits in one block (I.E. how many bits per block)? |
99 | 99 |
100 temp = TT.blocksize*8; | 100 temp = TT.blocksize*8; |