]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mkfs.minix: standardize superblock attribute settings
authorDavidlohr Bueso <dave@gnu.org>
Thu, 9 Jun 2011 16:01:09 +0000 (12:01 -0400)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Jun 2011 14:39:04 +0000 (16:39 +0200)
Because of the dependence of fs_version, some superblock attributes will vary,
so simplify the logic of assigning values to maxsize and the amount of zones
related to each filesystem, thus making setup_tables() more readable.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
disk-utils/mkfs.minix.c

index d2d800f355fddfc3f94f3368ce13f890819bfa25..213b98fa12a0a9f041d6f931e194361c78edc162 100644 (file)
@@ -370,6 +370,29 @@ static void make_root_inode(void)
        return make_root_inode_v2();
 }
 
+static void super_set_nzones(void)
+{
+       switch (fs_version) {
+       case 2:
+               Super.s_zones = BLOCKS;
+               break;
+       default: /* v1 */
+               Super.s_nzones = BLOCKS;
+               break;
+       }
+}
+
+static void super_init_maxsize(void)
+{
+       switch (fs_version) {
+       case 2:
+               Super.s_max_size =  0x7fffffff;
+       default: /* v1 */
+               Super.s_max_size = (7+512+512*512)*1024;
+               break;
+       }
+}
+
 static void setup_tables(void) {
        int i;
        unsigned long inodes, zmaps, imaps, zones;
@@ -382,11 +405,10 @@ static void setup_tables(void) {
        memset(boot_block_buffer,0,512);
        Super.s_magic = magic;
        Super.s_log_zone_size = 0;
-       Super.s_max_size = version2 ? 0x7fffffff : (7+512+512*512)*1024;
-       if (fs_version == 2)
-               zones = Super.s_zones = BLOCKS;
-       else
-               zones = Super.s_nzones = BLOCKS;
+
+       super_init_maxsize();
+       super_set_nzones();
+       zones = get_nzones();
 
 /* some magic nrs: 1 inode / 3 blocks */
        if ( req_nr_inodes == 0 )