In mke2fs and e2fsck, specifying the -c option twice will now do
a read/write test on the disk.  Update the man pages to encourage
using the -c option, and to discouraging running badblocks separately,
since users tend to forget to set the blocksize when running 
badblocks.

diff --git a/misc/ChangeLog b/misc/ChangeLog
index bcdeefe..8f8ff02 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,5 +1,16 @@
 2001-12-24  Theodore Tso  <tytso@valinux.com>
 
+	* mke2fs.c (main, test_disk): If two -c options are
+		specified, then perform a destructive read/write test
+		of the disk.
+
+	* mke2fs.8.in: Document the double -c option; also encourage users
+		to use -c instead of the -l/-L options since it's too hard
+		for users to get things like the blocksize parameter correct.
+
+	* badblocks.8.in: Encourage users to use the -c option in mke2fs
+		and e2fsck instead of running badblocks directly.
+
 	* mke2fs.c (create_lost_and_found): The lost+found directory is
 		now created with 0700 permissions, since files which get
 		dropped into that directory may have come from a protected
diff --git a/misc/badblocks.8.in b/misc/badblocks.8.in
index 868b30a..44517b3 100644
--- a/misc/badblocks.8.in
+++ b/misc/badblocks.8.in
@@ -46,6 +46,28 @@
 is an optional parameter specifying the starting block number
 for the test, which allows the testing to start in the middle of the
 disk.  If it is not specified the first block on the disk is used as a default.
+.PP
+.B Important note:
+If the output of 
+.B badblocks
+is going to be fed to the
+.B e2fsck
+or 
+.B mke2fs
+programs, it is important that the block size is properly specified,
+since the block numbers which are generated is very dependent on the 
+block size in use.   For this reason, it is strongly recommended that
+users 
+.B not
+run 
+.B badblocks 
+directly, but rather use the 
+.B \-c
+option of the
+.B e2fsck
+and 
+.B mke2fs
+programs.
 .SH OPTIONS
 .TP
 .BI \-b " block-size"
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 32de867..59fa974 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -141,8 +141,9 @@
 option).
 .TP
 .B \-c
-Check the device for bad blocks before creating the file system, using a
-fast read-only test.
+Check the device for bad blocks before creating the file system.  If
+this option is specified twice, then a slower, destructive, read-write
+test is used instead of a fast read-only test.
 .TP
 .BI \-f " fragment-size"
 Specify the size of fragments in bytes.
@@ -225,7 +226,18 @@
 .TP
 .BI \-l " filename"
 Read the bad blocks list from
-.IR filename .
+.IR filename .  
+Note that the block numbers in the bad block list must be generated
+using the same block size as used by mke2fs.  As a result, the
+.B \-c
+option to 
+.B mke2fs
+is a much simpler and less error-prone method of checking a disk for bad
+blocks before formatting it, as 
+.B mke2fs
+will automatically pass the correct parameters to the
+.B badblocks
+program.
 .TP
 .B \-L
 Set the volume label for the filesystem.
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 92f3463..c55aab0 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -216,9 +216,9 @@
 	errcode_t	retval;
 	char		buf[1024];
 
-	sprintf(buf, "badblocks -b %d %s%s %d", fs->blocksize,
-		quiet ? "" : "-s ", fs->device_name,
-		fs->super->s_blocks_count);
+	sprintf(buf, "badblocks -b %d %s%s%s %d", fs->blocksize,
+		quiet ? "" : "-s ", (cflag > 1) ? "-w " : "",
+		fs->device_name, fs->super->s_blocks_count);
 	if (verbose)
 		printf(_("Running command: %s\n"), buf);
 	f = popen(buf, "r");
@@ -838,7 +838,7 @@
 			break;
 		case 'c':	/* Check for bad blocks */
 		case 't':	/* deprecated */
-			cflag = 1;
+			cflag++;
 			break;
 		case 'f':
 			size = strtoul(optarg, &tmp, 0);