OSDN Git Service

One more field, minor shrinking, and start on block groups.
authorRob Landley <rob@landley.net>
Sat, 27 Jan 2007 20:10:48 +0000 (15:10 -0500)
committerRob Landley <rob@landley.net>
Sat, 27 Jan 2007 20:10:48 +0000 (15:10 -0500)
toys/e2fs.h
toys/mke2fs.c

index b50a881..49eb4c4 100644 (file)
@@ -64,6 +64,17 @@ struct ext2_superblock {
        uint32_t reserved[172];      // Padding to the end of the block
 };
 
+struct ext2_group
+{
+       uint32_t block_bitmap;       // Block number of block bitmap
+       uint32_t inode_bitmap;       // Block number of inode bitmap
+       uint32_t inode_table;        // Block number of inode table
+       uint16_t free_blocks_count;  // How many free blocks in this group?
+       uint16_t free_inodes_count;  // How many free inodes in this group?
+       uint16_t used_dirs_count;    // How many directories?
+       uint16_t reserved[7];        // pad to 256 bits.
+};
+
 struct ext2_dentry {
        uint32_t inode;         // Inode number
     uint16_t rec_len;       // Directory entry length
index 0c71da8..b50068a 100644 (file)
@@ -79,13 +79,11 @@ int mke2fs_main(void)
        // Determine appropriate block size, set log_block_size and log_frag_size.
 
        if (!TT.blocksize) TT.blocksize = (length && length < 1<<29) ? 1024 : 4096;
-       if (TT.blocksize == 1024) temp = 0;
-       else if (TT.blocksize == 2048) temp = 1;
-       else if (TT.blocksize == 4096) temp = 2;
-       else error_exit("bad blocksize");
+       for (temp = 0; temp < 7; temp++) if (TT.blocksize == 1024<<temp) break;
+       if (temp==7) error_exit("bad blocksize");
        sb->log_block_size = sb->log_frag_size = SWAP_LE32(temp);
 
-       // Fill out blocks_count and r_blocks_count
+       // Fill out blocks_count, r_blocks_count, first_data_block
 
        if (!TT.blocks) TT.blocks = length/TT.blocksize;
        sb->blocks_count = SWAP_LE32(TT.blocks);
@@ -94,6 +92,8 @@ int mke2fs_main(void)
        temp = (TT.blocks * (uint64_t)TT.reserved_percent) /100;
        sb->r_blocks_count = SWAP_LE32(temp);
 
+       sb->first_data_block = TT.blocksize == 1024 ? 1 : 0;
+
        // Set blocks_per_group and frags_per_group, which is the size of an
        // allocation bitmap that fits in one block (I.E. how many bits per block)?