aboutsummaryrefslogtreecommitdiff
path: root/e2fsck
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-03-26 09:09:09 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-03-26 09:11:46 -0400
commit1dc506cbe956419f0eafb8e84bae108ec2f0b2de (patch)
tree4de3c583e51dc6e079d30e513e54225e1f5ed7f3 /e2fsck
parentbf209ab7950ca2a06c5837f47756f6e0ae326e85 (diff)
downloade2fsprogs-1dc506cbe956419f0eafb8e84bae108ec2f0b2de.tar.gz
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>
Diffstat (limited to 'e2fsck')
-rw-r--r--e2fsck/e2fsck.c6
-rw-r--r--e2fsck/unix.c12
2 files changed, 15 insertions, 3 deletions
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index e2434da8..9afd906e 100644
--- a/e2fsck/e2fsck.c
+++ b/e2fsck/e2fsck.c
@@ -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);
}
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index e8432447..3eb30647 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -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.