From 1400bbb60bf2667ab5514abd074baf4959fe475a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 14 May 2001 04:19:25 +0000 Subject: [PATCH] ChangeLog, mke2fs.c: 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 | 5 +++++ misc/mke2fs.c | 29 +++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/misc/ChangeLog b/misc/ChangeLog index 0937b19..63da39a 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,8 @@ +2001-05-11 Andreas Dilger + + * 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 * tune2fs.c (update_feature_set): Clean up some printf messages. diff --git a/misc/mke2fs.c b/misc/mke2fs.c index b154ea3..ba1545f 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -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) { -- 1.8.3.1