From 7cc9cdea86283aebc2847edef702156b53f5e7f1 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 10 May 2019 13:20:59 -0400 Subject: [PATCH] e2fsck: fix XML validity problem with the problem log Also fix a gcc warning. Signed-off-by: Theodore Ts'o --- e2fsck/e2fsck.c | 5 +++-- e2fsck/problem.c | 5 +++-- e2fsck/unix.c | 11 ++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index 2af610529..3770bfcb7 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -218,9 +218,10 @@ void e2fsck_free_context(e2fsck_t ctx) if (ctx->problem_log_fn) free(ctx->problem_log_fn); - if (ctx->problem_logf) + if (ctx->problem_logf) { + fputs("\n", ctx->problem_logf); fclose(ctx->problem_logf); - + } ext2fs_free_mem(&ctx); } diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 01f086737..360eb331d 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -2196,7 +2196,7 @@ static void print_problem(FILE *f, problem_t code, int answer, int fixed, struct problem_context *pctx) { if (ptr->flags & PR_HEADER) { - fprintf(f, "
\n", code); + fprintf(f, "
\n", code); return; } fprintf(f, "count == ptr->max_count + 1) { if (ctx->problem_logf) fprintf(ctx->problem_logf, - "\n", code); + "\n", + code); printf("...problem 0x%06x suppressed\n", ptr->e2p_code); fflush(stdout); diff --git a/e2fsck/unix.c b/e2fsck/unix.c index f8c4983d9..68f498739 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1438,11 +1438,13 @@ int main (int argc, char *argv[]) fputs("\n", ctx->problem_logf); + fprintf(ctx->problem_logf, "\n", + ctx->now); fprintf(ctx->problem_logf, "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 @@ failure: } 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); -- 2.39.2