Whamcloud - gitweb
ChangeLog, mke2fs.c:
authorTheodore Ts'o <tytso@mit.edu>
Mon, 14 May 2001 04:19:25 +0000 (04:19 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 14 May 2001 04:19:25 +0000 (04:19 +0000)
  mke2fs.c: don't zap the superblock if we are running with noaction!
   Zap the end of the device to remove stale RAID superblocks.

misc/ChangeLog
misc/mke2fs.c

index 0937b19..63da39a 100644 (file)
@@ -1,3 +1,8 @@
+2001-05-11  Andreas Dilger  <adilger@turbolinux.com>
+
+       * mke2fs.c: don't zap the superblock if we are running with noaction!
+               Zap the end of the device to remove stale RAID superblocks.
+
 2001-05-14  Theodore Tso  <tytso@valinux.com>
 
        * tune2fs.c (update_feature_set): Clean up some printf messages.
index b154ea3..ba1545f 100644 (file)
@@ -1105,7 +1105,10 @@ int main (int argc, char *argv[])
        /*
         * Wipe out the old on-disk superblock
         */
-       zap_sector(fs, 2);
+       if (!noaction) {
+               zap_sector(fs, 2);
+               zap_sector(fs, 3);
+       }
 
        /*
         * Generate a UUID for it...
@@ -1187,14 +1190,32 @@ int main (int argc, char *argv[])
                fs->super->s_state |= EXT2_ERROR_FS;
                fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY);
        } else {
+               int rsv = 65536 / EXT2_BLOCK_SIZE(fs->super);
+               unsigned long blocks = fs->super->s_blocks_count;
+               unsigned long start = (blocks & ~(rsv - 1)) - rsv;
+               blk_t ret_blk;
+
+#ifdef ZAP_BOOTBLOCK
+               zap_sector(fs, 0);
+#endif
+               /*
+                * Wipe out any old MD RAID (or other) metadata at the end
+                * of the device.  This will also verify that the device is
+                * as large as we think it is.
+                */
+               retval = zero_blocks(fs, start, blocks - start,
+                                    NULL, &ret_blk, NULL);
+               if (retval) {
+                       com_err(program_name, retval,
+                               _("zeroing block %u at end of filesystem"),
+                               ret_blk);
+                       exit(1);
+               }
                write_inode_tables(fs);
                create_root_dir(fs);
                create_lost_and_found(fs);
                reserve_inodes(fs);
                create_bad_block_inode(fs, bb_list);
-#ifdef ZAP_BOOTBLOCK
-               zap_sector(fs, 0);
-#endif
        }
 
        if (journal_device) {