File diskdump-Separate-init_private-from-open_common.patch of Package libkdumpfile.36085
From: Petr Tesarik <petr@tesarici.cz>
Date: Mon, 6 Nov 2023 10:18:21 +0100
Subject: diskdump: Separate init_private() from open_common()
References: bsc#1223399
Upstream: merged
Git-commit: c57e98722c44093054711b01e7e7922c21071bba
For flattened dumps, this initialization will be needed earlier, so let's
put it into its own function.
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
src/kdumpfile/diskdump.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
--- a/src/kdumpfile/diskdump.c
+++ b/src/kdumpfile/diskdump.c
@@ -858,18 +858,17 @@ try_header_64(struct setup_data *sdp, st
return ret;
}
+/** Initialize diskdump private data.
+ * @param ctx Dump file object.
+ * @returns Error status.
+ *
+ * Allocate and initialize diskdump format private data. The private data
+ * should be eventually cleaned up by @ref diskdump_cleanup().
+ */
static kdump_status
-open_common(kdump_ctx_t *ctx, void *hdr)
+init_private(kdump_ctx_t *ctx)
{
- struct disk_dump_header_32 *dh32 = hdr;
- struct disk_dump_header_64 *dh64 = hdr;
struct disk_dump_priv *ddp;
- struct setup_data sd;
- kdump_bmp_t *bmp;
- kdump_status ret;
-
- memset(&sd, 0, sizeof sd);
- sd.ctx = ctx;
ddp = calloc(1, sizeof *ddp);
if (!ddp)
@@ -882,6 +881,21 @@ open_common(kdump_ctx_t *ctx, void *hdr)
ddp->cbuf_slot = -1;
ctx->shared->fmtdata = ddp;
+ return KDUMP_OK;
+}
+
+static kdump_status
+open_common(kdump_ctx_t *ctx, void *hdr)
+{
+ struct disk_dump_priv *ddp = ctx->shared->fmtdata;;
+ struct disk_dump_header_32 *dh32 = hdr;
+ struct disk_dump_header_64 *dh64 = hdr;
+ struct setup_data sd;
+ kdump_bmp_t *bmp;
+ kdump_status ret;
+
+ memset(&sd, 0, sizeof sd);
+ sd.ctx = ctx;
set_addrspace_caps(ctx->xlat, ADDRXLAT_CAPS(ADDRXLAT_MACHPHYSADDR));
@@ -949,6 +963,10 @@ diskdump_probe(kdump_ctx_t *ctx)
return set_error(ctx, KDUMP_NOPROBE,
"Unrecognized diskdump signature");
+ status = init_private(ctx);
+ if (status != KDUMP_OK)
+ return status;
+
return open_common(ctx, hdr);
}