]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: fix XML validity problem with the problem log
authorTheodore Ts'o <tytso@mit.edu>
Fri, 10 May 2019 17:20:59 +0000 (13:20 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 10 May 2019 22:36:46 +0000 (18:36 -0400)
Also fix a gcc warning.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/e2fsck.c
e2fsck/problem.c
e2fsck/unix.c

index 2af610529ba32a8442465c0eb9db9b60b7968790..3770bfcb71c5c4f00b5b823e8c592228bf24f4fd 100644 (file)
@@ -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("</problem_log>\n", ctx->problem_logf);
                fclose(ctx->problem_logf);
-
+       }
        ext2fs_free_mem(&ctx);
 }
 
index 01f0867376adf4d2c07ec3980a721cf4d7dd1a03..360eb331d9b685a9c82d9ef78d4fa6520f2efc8a 100644 (file)
@@ -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, "<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 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
                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);
index f8c4983d94be2cabe0b8c2506a1ff152ad852980..68f4987398624d171e93a82de0797dc9457f96fc 100644 (file)
@@ -1438,11 +1438,13 @@ int main (int argc, char *argv[])
 
                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 @@ 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);