+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
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) {
.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
@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"
#define E2F_OPT_CHECKBLOCKS 0x0040
#define E2F_OPT_DEBUG 0x0080
#define E2F_OPT_FORCE 0x0100
+#define E2F_OPT_WRITECHECK 0x0200
/*
* E2fsck flags
#endif
break;
case 'c':
- cflag++;
+ if (cflag++)
+ ctx->options |= E2F_OPT_WRITECHECK;
ctx->options |= E2F_OPT_CHECKBLOCKS;
break;
case 'r':
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
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
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"
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.
.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.
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");
break;
case 'c': /* Check for bad blocks */
case 't': /* deprecated */
- cflag = 1;
+ cflag++;
break;
case 'f':
size = strtoul(optarg, &tmp, 0);