Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test multiple blocks at once using badblocks when invoked by e2fsck #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion e2fsck/badblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
goto fatal;
}
} else {
sprintf(buf, "badblocks -b %d -X %s%s%s %llu", fs->blocksize,
sprintf(buf, "badblocks -b %d -c %d -X %s%s%s %llu", fs->blocksize,
ctx->blocks_at_once,
(ctx->options & E2F_OPT_PREEN) ? "" : "-s ",
(ctx->options & E2F_OPT_WRITECHECK) ? "-n " : "",
fs->device_name, ext2fs_blocks_count(fs->super)-1);
Expand Down
1 change: 1 addition & 0 deletions e2fsck/e2fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret)
context->ext_attr_ver = 2;
context->blocks_per_page = 1;
context->htree_slack_percentage = 255;
context->blocks_at_once = 64;

time_env = getenv("E2FSCK_TIME");
if (time_env)
Expand Down
1 change: 1 addition & 0 deletions e2fsck/e2fsck.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ struct e2fsck_struct {
int flags; /* E2fsck internal flags */
int options;
int blocksize; /* blocksize */
int blocks_at_once; /* for badblocks */
blk64_t use_superblock; /* sb requested by user */
blk64_t superblock; /* sb used to open fs */
blk64_t num_blocks; /* Total number of blocks */
Expand Down
6 changes: 5 additions & 1 deletion e2fsck/unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static void usage(e2fsck_t ctx)
" -n Make no changes to the filesystem\n"
" -y Assume \"yes\" to all questions\n"
" -c Check for bad blocks and add them to the badblock list\n"
" -K blocks_at_once The number of blocks which are tested at a time when using badblocks. The default is 64.\n"
" -f Force checking even if filesystem is marked clean\n"));
fprintf(stderr, "%s", _(""
" -v Be verbose\n"
Expand Down Expand Up @@ -835,7 +836,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)

phys_mem_kb = get_memory_size() / 1024;
ctx->readahead_kb = ~0ULL;
while ((c = getopt(argc, argv, "panyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF)
while ((c = getopt(argc, argv, "panyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:K:")) != EOF)
switch (c) {
case 'C':
ctx->progress = e2fsck_update_progress;
Expand Down Expand Up @@ -902,6 +903,9 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
ctx->options |= E2F_OPT_WRITECHECK;
ctx->options |= E2F_OPT_CHECKBLOCKS;
break;
case 'K':
ctx->blocks_at_once = atoi(optarg);
break;
case 'r':
/* What we do by default, anyway! */
break;
Expand Down