From: Andreas Dilger Date: Thu, 30 Aug 2001 21:39:04 +0000 (-0600) Subject: mke2fs.c (main): Zap the second sector of the disk, along with X-Git-Tag: E2FSPROGS-1_24~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59f27247f81fb662ef3b2589b3cceb198ff4dbca;p=thirdparty%2Fe2fsprogs.git mke2fs.c (main): Zap the second sector of the disk, along with any sectors in the same filesystem block after the superblock. The latter will remove (for example) swapspace signatures on 4kB+ blocksize filesystems. Also when zeroing the "end" of the filesystem don't actually zero the start of a very small device (less than 128kB). --- diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index a8d332a85..b51f5521c 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -153,7 +153,7 @@ int e2fsck_pass1_check_device_inode(struct ext2_inode *inode) #ifndef HAVE_STRNLEN /* - * Incredibly, libc5 doesn't appear to have strncpy. So we have to + * Incredibly, libc5 doesn't appear to have strnlen. So we have to * provide our own. */ static int strnlen(const char * s, int count) diff --git a/misc/ChangeLog b/misc/ChangeLog index b82145ca0..df8737cb8 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -2,9 +2,18 @@ * badblocks.8.in: Fix spelling typo. (Addresses Debian bug #110621) +2001-08-30 Andreas Dilger + + * mke2fs.c (main): Zap the second sector of the disk, along with + any sectors in the same filesystem block after the superblock. + The latter will remove (for example) swapspace signatures + on 4kB+ blocksize filesystems. Also when zeroing the "end" + of the filesystem don't actually zero the start of a very + small device (less than 64 blocks). + 2001-08-27 Theodore Tso - * fsck.c (main): Make version display consisstent with the other + * fsck.c (main): Make version display consistent with the other e2fsprogs programs. * lsattr.c, chattr.c, mke2fs.c, tune2fs.c, dumpe2fs.c, e2image.c, diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 070f7a43f..3c96039a4 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -809,8 +809,9 @@ static void PRS(int argc, char *argv[]) param.s_feature_ro_compat = 0; } #endif - fprintf (stderr, "mke2fs %s (%s)\n", E2FSPROGS_VERSION, - E2FSPROGS_DATE); + fprintf (stderr, _("mke2fs %s, %s for EXT2 FS %s, %s\n"), + E2FSPROGS_VERSION, E2FSPROGS_DATE, + EXT2FS_VERSION, EXT2FS_DATE); if (argc && *argv) program_name = *argv; while ((c = getopt (argc, argv, @@ -1220,21 +1221,38 @@ int main (int argc, char *argv[]) fs->super->s_state |= EXT2_ERROR_FS; fs->flags &= ~(EXT2_FLAG_IB_DIRTY|EXT2_FLAG_BB_DIRTY); } else { + /* rsv must be a power of two (64kB is MD RAID sb alignment) */ int rsv = 65536 / EXT2_BLOCK_SIZE(fs->super); unsigned long blocks = fs->super->s_blocks_count; - unsigned long start = (blocks & ~(rsv - 1)) - rsv; + unsigned long start; blk_t ret_blk; #ifdef ZAP_BOOTBLOCK zap_sector(fs, 0); + zap_sector(fs, 1); #endif + + /* + * Zero out sectors after the superblock in the same fs block + * (only needed for 4kB+ block size). We have already done + * the superblock itself earlier, and we will overwrite the + * following blocks with GDT/bitmap/itable also. + */ + for (i = 4; i < (1 << fs->super->s_log_block_size + 1); i++) + zap_sector(fs, i); + /* * 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. + * as large as we think. Be careful with very small devices. */ - retval = zero_blocks(fs, start, blocks - start, - NULL, &ret_blk, NULL); + start = (blocks & ~(rsv - 1)); + if (start > rsv) + start -= rsv; + if (start > 0) + 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"),