e2fsck: Include the device name in the progress information

Also make sure the device name has no spaces in it, to avoid confusing
displays, and make ctx->filesystem_name and ctx->device_name allocated
memory to avoid potential problems in the future.

Addresses-Launchpad-Bug: #203323
Addresses-Sourceforge-Bug: #1926023

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2008-03-26 09:09:09 -04:00
parent bf209ab795
commit 1dc506cbe9
2 changed files with 15 additions and 3 deletions

View File

@ -169,6 +169,12 @@ void e2fsck_free_context(e2fsck_t ctx)
if (ctx->profile)
profile_release(ctx->profile);
if (ctx->filesystem_name)
ext2fs_free_mem(&ctx->filesystem_name);
if (ctx->device_name)
ext2fs_free_mem(&ctx->device_name);
ext2fs_free_mem(&ctx);
}

View File

@ -444,14 +444,15 @@ int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent,
static int e2fsck_update_progress(e2fsck_t ctx, int pass,
unsigned long cur, unsigned long max)
{
char buf[80];
char buf[1024];
float percent;
if (pass == 0)
return 0;
if (ctx->progress_fd) {
sprintf(buf, "%d %lu %lu\n", pass, cur, max);
snprintf(buf, sizeof(buf), "%d %lu %lu %s\n",
pass, cur, max, ctx->device_name);
write(ctx->progress_fd, buf, strlen(buf));
} else {
percent = calc_percent(&e2fsck_tbl, pass, cur, max);
@ -774,6 +775,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
argv[optind]);
fatal_error(ctx, 0);
}
ctx->filesystem_name = string_copy(ctx, ctx->filesystem_name, 0);
if (extended_opts)
parse_extended_opts(ctx, extended_opts);
@ -888,6 +890,7 @@ int main (int argc, char *argv[])
int journal_size;
int sysval, sys_page_size = 4096;
__u32 features[3];
char *cp;
clear_problem_context(&pctx);
#ifdef MTRACE
@ -1109,7 +1112,10 @@ restart:
sizeof(sb->s_volume_name));
}
if (ctx->device_name == 0)
ctx->device_name = ctx->filesystem_name;
ctx->device_name = string_copy(ctx, ctx->filesystem_name, 0);
for (cp = ctx->device_name; *cp; cp++)
if (isspace(*cp) || *cp == ':')
*cp = '_';
/*
* Make sure the ext3 superblock fields are consistent.