Skip to content

Commit

Permalink
diskdump: Delay private data initialization
Browse files Browse the repository at this point in the history
Since flatmap is now handled outside of format-specific code, private data
need not be initialized until the header signature is checked.

Signed-off-by: Petr Tesarik <[email protected]>
  • Loading branch information
ptesarik committed Sep 30, 2024
1 parent f191d5a commit 4223d5d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/kdumpfile/diskdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,14 +1101,13 @@ open_common(kdump_ctx_t *ctx, void *hdr)
static void
init_desc(kdump_ctx_t *ctx, char *desc)
{
struct disk_dump_priv *ddp = ctx->shared->fmtdata;
unsigned fidx, nflat;

for (nflat = fidx = 0; fidx < ddp->num_files; ++fidx)
for (nflat = fidx = 0; fidx < get_num_files(ctx); ++fidx)
if (flatmap_isflattened(ctx->shared->flatmap, fidx))
++nflat;

if (nflat == ddp->num_files)
if (nflat == fidx)
strcpy(desc, "Flattened ");
else if (nflat)
strcpy(desc, "Mixed ");
Expand All @@ -1128,10 +1127,6 @@ diskdump_probe(kdump_ctx_t *ctx)
char desc[32];
kdump_status status;

status = init_private(ctx);
if (status != KDUMP_OK)
return status;

status = flatmap_pread(ctx->shared->flatmap, hdr, sizeof hdr, 0, 0);
if (status != KDUMP_OK)
return set_error(ctx, status, "Cannot read dump header");
Expand All @@ -1154,6 +1149,10 @@ diskdump_probe(kdump_ctx_t *ctx)
return set_error(ctx, status, "Cannot set %s",
"file.description");

status = init_private(ctx);
if (status != KDUMP_OK)
return status;

return open_common(ctx, hdr);
}

Expand Down

0 comments on commit 4223d5d

Please sign in to comment.