e2fsck: fix XML validity problem with the problem log
Also fix a gcc warning.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index 2af6105..3770bfc 100644
--- a/e2fsck/e2fsck.c
+++ b/e2fsck/e2fsck.c
@@ -218,9 +218,10 @@
if (ctx->problem_log_fn)
free(ctx->problem_log_fn);
- if (ctx->problem_logf)
+ if (ctx->problem_logf) {
+ fputs("</problem_log>\n", ctx->problem_logf);
fclose(ctx->problem_logf);
-
+ }
ext2fs_free_mem(&ctx);
}
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 01f0867..360eb33 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -2196,7 +2196,7 @@
struct problem_context *pctx)
{
if (ptr->flags & PR_HEADER) {
- fprintf(f, "<header code=\"0x%06x\">\n", code);
+ fprintf(f, "<header code=\"0x%06x\"/>\n", code);
return;
}
fprintf(f, "<problem code=\"0x%06x\" answer=\"%d\"", code, answer);
@@ -2317,7 +2317,8 @@
if (ptr->count == ptr->max_count + 1) {
if (ctx->problem_logf)
fprintf(ctx->problem_logf,
- "<suppressed code=\"0x%06x\">\n", code);
+ "<suppressed code=\"0x%06x\"/>\n",
+ code);
printf("...problem 0x%06x suppressed\n",
ptr->e2p_code);
fflush(stdout);
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index f8c4983..68f4987 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1438,11 +1438,13 @@
fputs("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
ctx->problem_logf);
+ fprintf(ctx->problem_logf, "<problem_log time=\"%lu\">\n",
+ ctx->now);
fprintf(ctx->problem_logf, "<invocation prog=\"%s\"",
argv[0]);
for (i = 1; i < argc; i++)
- fprintf(ctx->problem_logf, " arg=\"%s\"", argv[i]);
- fputs(">\n", ctx->problem_logf);
+ fprintf(ctx->problem_logf, " arg%d=\"%s\"", i, argv[i]);
+ fputs("/>\n", ctx->problem_logf);
}
init_resource_track(&ctx->global_rtrack, NULL);
@@ -1712,11 +1714,10 @@
}
if (sb->s_volume_name[0]) {
memset(buf, 0, sizeof(buf));
- strncpy(buf, sb->s_volume_name,
- sizeof(sb->s_volume_name));
+ strncpy(buf, sb->s_volume_name, sizeof(buf));
fprintf(ctx->problem_logf, " label=\"%s\"", buf);
}
- fputs(">\n", ctx->problem_logf);
+ fputs("/>\n", ctx->problem_logf);
}
ehandler_init(fs->io);