From 6547d1ae4ca34942d6da71c7e379217ff63acd29 Mon Sep 17 00:00:00 2001 From: Mikhail Zaslonko Date: Tue, 15 Jul 2025 18:07:02 +0200 Subject: [PATCH] zdump/ngdump: Add error messages and debug trace logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add debug trace logs for ngdump_read_meta_from_device(). Signed-off-by: Mikhail Zaslonko Signed-off-by: Jan Höppner --- zdump/dfi_ngdump.c | 4 +++- zdump/ngdump.c | 22 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/zdump/dfi_ngdump.c b/zdump/dfi_ngdump.c index dce95027..510ce0e6 100644 --- a/zdump/dfi_ngdump.c +++ b/zdump/dfi_ngdump.c @@ -36,8 +36,10 @@ static int open_dump_file(void) mount_point = util_strdup("/tmp/zdump-ngdump-XXXXXX"); /* Create a mount point directory */ - if (mkdtemp(mount_point) == NULL) + if (mkdtemp(mount_point) == NULL) { + warnx("Could not create directory \"%s\"", mount_point); goto fail_free; + } if (mount(l.device, mount_point, NGDUMP_FSTYPE, MS_RDONLY, NULL)) { warnx("Could not mount \"%s\" (%s)", l.device, strerror(errno)); diff --git a/zdump/ngdump.c b/zdump/ngdump.c index b94973af..95d26893 100644 --- a/zdump/ngdump.c +++ b/zdump/ngdump.c @@ -42,11 +42,19 @@ static int read_meta_from_file(const char *filename, struct ngdump_meta *meta) FILE *fp = NULL; char *line = NULL; + util_log_print(UTIL_LOG_TRACE, + "%s: Reading meta file \"%s\"\n", + __func__, filename); + memset(meta, 0, sizeof(*meta)); fp = fopen(filename, "r"); - if (!fp) + if (!fp) { + util_log_print(UTIL_LOG_TRACE, + "%s: Could not open \"%s\" (%s)\n", + __func__, filename, strerror(errno)); return -1; + } while (fscanf(fp, "%m[^\n]\n", &line) == 1) { char *ptr, *param = NULL, *value = NULL; @@ -154,8 +162,11 @@ static int validate_meta(const char *mount_point, struct ngdump_meta *meta) * that the given partition is a valid NGDump partition but with no * dump present. */ - if (!meta->file) + if (!meta->file) { + util_log_print(UTIL_LOG_TRACE, + "%s: No dump file present\n", __func__); return 0; + } if (!meta->sha256sum) { warnx("Invalid NGDump SHA256 checksum"); return -1; @@ -189,13 +200,18 @@ int ngdump_read_meta_from_device(const char *device, struct ngdump_meta *meta) /* Create a mount point directory */ if (mkdtemp(mount_point) == NULL) { + warnx("Could not create directory \"%s\"", mount_point); rc = -1; goto out; } rc = mount(device, mount_point, NGDUMP_FSTYPE, MS_RDONLY, NULL); - if (rc) + if (rc) { + util_log_print(UTIL_LOG_TRACE, + "%s: Could not mount \"%s\" (%s)\n", + __func__, device, strerror(errno)); goto out_rmdir; + } util_asprintf(&filename, "%s/%s", mount_point, NGDUMP_META_FILENAME);