Whamcloud - gitweb
libext2fs: make sure ismounted.c explicitly pulls in <sys/types.h>
[tools/e2fsprogs.git] / lib / ext2fs / initialize.c
index 5afdc27..36c94a9 100644 (file)
@@ -173,6 +173,8 @@ errcode_t ext2fs_initialize(const char *name, int flags,
        set_field(s_raid_stripe_width, 0);      /* default stripe width: 0 */
        set_field(s_log_groups_per_flex, 0);
        set_field(s_flags, 0);
+       assign_field(s_backup_bgs[0]);
+       assign_field(s_backup_bgs[1]);
        if (super->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
                retval = EXT2_ET_UNSUPP_FEATURE;
                goto cleanup;
@@ -272,8 +274,9 @@ retry:
                goto cleanup;
        }
 
-       if (super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
-               super->s_desc_size = EXT2_MIN_DESC_SIZE_64BIT;
+       set_field(s_desc_size,
+                 super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT ?
+                 EXT2_MIN_DESC_SIZE_64BIT : 0);
 
        fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
                                          EXT2_DESC_PER_BLOCK(super));
@@ -421,6 +424,21 @@ ipg_retry:
         * count.
         */
 
+       /* Set up the locations of the backup superblocks */
+       if (super->s_feature_compat & EXT4_FEATURE_COMPAT_SPARSE_SUPER2) {
+               if (super->s_backup_bgs[0] >= fs->group_desc_count)
+                       super->s_backup_bgs[0] = fs->group_desc_count - 1;
+               if (super->s_backup_bgs[1] >= fs->group_desc_count)
+                       super->s_backup_bgs[1] = fs->group_desc_count - 1;
+               if (super->s_backup_bgs[0] == super->s_backup_bgs[1])
+                       super->s_backup_bgs[1] = 0;
+               if (super->s_backup_bgs[0] > super->s_backup_bgs[1]) {
+                       __u32 t = super->s_backup_bgs[0];
+                       super->s_backup_bgs[0] = super->s_backup_bgs[1];
+                       super->s_backup_bgs[1] = t;
+               }
+       }
+
        retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf);
        if (retval)
                goto cleanup;