]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
In mke2fs and e2fsck, specifying the -c option twice will now do
authorTheodore Ts'o <tytso@mit.edu>
Mon, 24 Dec 2001 20:01:59 +0000 (15:01 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 24 Dec 2001 20:01:59 +0000 (15:01 -0500)
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.

e2fsck/ChangeLog
e2fsck/badblocks.c
e2fsck/e2fsck.8.in
e2fsck/e2fsck.h
e2fsck/unix.c
misc/ChangeLog
misc/badblocks.8.in
misc/mke2fs.8.in
misc/mke2fs.c

index 9748f6503bf31ec9b56214356a569bfb17446d5a..41734f448ba2740103557213a85202c2afbe4980 100644 (file)
@@ -1,3 +1,17 @@
+2001-12-24  Theodore Tso  <tytso@valinux.com>
+
+       * unix.c (PRS): Don't allow the -c and -l/-L options to be
+               specified at the same time.
+
+       * e2fsck.h (E2F_OPT_WRITECHECK), unix.c (PRS), 
+               badblocks.c (read_bad_blocks_file): If two -c options are
+               specified, then perform a non-destructive read/write scan
+               of the disk.
+
+       * e2fsck.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.
+
 2001-12-23  Theodore Tso  <tytso@valinux.com>
 
        * util.c (get_backup_sb): This function now searches for the
index c7cc8ccc850893ab8d24f3df2e81244aae1e2dae..92aa3c11121acee8c738aa2c3e831456b0c53407 100644 (file)
@@ -72,8 +72,9 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
                        goto fatal;
                }
        } else {
-               sprintf(buf, "badblocks -b %d %s%s %d", fs->blocksize,
+               sprintf(buf, "badblocks -b %d %s%s%s %d", fs->blocksize,
                        (ctx->options & E2F_OPT_PREEN) ? "" : "-s ",
+                       (ctx->options & E2F_OPT_WRITECHECK) ? "-n " : "",
                        fs->device_name, fs->super->s_blocks_count);
                f = popen(buf, "r");
                if (!f) {
index 8701af7273a86583db5a5cc0eb028d0f7177844a..ad517c12389c52e7ffab70eab1aedff5a8e274e9 100644 (file)
@@ -95,6 +95,8 @@ to run the
 .BR badblocks (8)
 program to find any blocks which are bad on the filesystem, 
 and then marks them as bad by adding them to the bad block inode.
+If this option is specified twice, then the bad block scan will be done
+using a non-destructive read-write test.
 .TP
 .B \-C
 This option causes
@@ -127,11 +129,21 @@ time trials.
 @JDEV@found.
 .TP
 .BI \-l " filename"
-Add the blocks listed in the file specified by 
+Add the block numbers listed in the file specified by 
 .I filename
 to the list of bad blocks.  The format of this file is the same as the
 one generated by the 
 .BR badblocks (8)
+program.  Note that the block numbers are based on the blocksize
+of the filesystem.  Hence, 
+.BR badblocks (8)
+must be given the blocksize of the filesystem in order to obtain correct
+results.  As a result, it is much simpler and safer to use the 
+.B -c
+option to 
+.BR e2fsck ,
+since it will assure that the correct parameters are passed to the
+.B badblocks
 program.
 .TP
 .BI \-L " filename"
index d3eeedf79248e214ea26e1c25ba49aae3d5d4738..e1e92baad44b28934edc41c5adc9b426c7f64fcb 100644 (file)
@@ -102,6 +102,7 @@ struct resource_track {
 #define E2F_OPT_CHECKBLOCKS    0x0040
 #define E2F_OPT_DEBUG          0x0080
 #define E2F_OPT_FORCE          0x0100
+#define E2F_OPT_WRITECHECK     0x0200
 
 /*
  * E2fsck flags
index 43a235f35d245313b7712c973ec9a548ae250e38..cbedd5d8ab3ff75e291171e49ea12b902de3f59f 100644 (file)
@@ -511,7 +511,8 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
 #endif
                        break;
                case 'c':
-                       cflag++;
+                       if (cflag++)
+                               ctx->options |= E2F_OPT_WRITECHECK;
                        ctx->options |= E2F_OPT_CHECKBLOCKS;
                        break;
                case 'r':
@@ -610,11 +611,16 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
        if (swapfs) {
                if (cflag || bad_blocks_file) {
                        fprintf(stderr, _("Incompatible options not "
-                               "allowed when byte-swapping.\n"));
+                                         "allowed when byte-swapping.\n"));
                        exit(FSCK_USAGE);
                }
        }
 #endif
+       if (cflag && bad_blocks_file) {
+               fprintf(stderr, _("The -c and the -l/-L options may "
+                                 "not be both used at the same time.\n"));
+               exit(FSCK_USAGE);
+       }
 #ifdef HAVE_SIGNAL_H
        /*
         * Set up signal action
index bcdeefe755748bdc7da15288488acbe0708f6ef0..8f8ff02dad47110675fe6576fa7847f3020e0056 100644 (file)
@@ -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
index 868b30a2c5b8147ecdb378948fb0c437d3b3e8e7..44517b3c31cf8dfbba55544aa7cbf8aaf47ab7ed 100644 (file)
@@ -46,6 +46,28 @@ on the device is used as a default.
 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"
index 32de86702e27a68b40e17f2cd195607c18759c9a..59fa974d235cfb396060d3f55c94ca09091a57d9 100644 (file)
@@ -141,8 +141,9 @@ of the filesystem (see the
 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 @@ The journal must fit within the newly created filesystem.
 .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.
index 92f3463d4b93c8cba648006a5f23c32f750a2e52..c55aab0ea96b08cef9e129bb021131fd5401d148 100644 (file)
@@ -216,9 +216,9 @@ static void test_disk(ext2_filsys fs, badblocks_list *bb_list)
        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 @@ static void PRS(int argc, char *argv[])
                        break;
                case 'c':       /* Check for bad blocks */
                case 't':       /* deprecated */
-                       cflag = 1;
+                       cflag++;
                        break;
                case 'f':
                        size = strtoul(optarg, &tmp, 0);