From 4e689b7d63e21db21f5bbc0e06b011648265705d Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Thu, 25 Jul 2013 21:48:32 +0200 Subject: [PATCH] DDF: load_ddf_header: more error logging Try to determine problem if load_ddf_header fails. --- super-ddf.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/super-ddf.c b/super-ddf.c index 234d816..fdfc1d5 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -754,18 +754,24 @@ static int load_ddf_header(int fd, unsigned long long lba, if (read(fd, hdr, 512) != 512) return 0; - if (!be32_eq(hdr->magic, DDF_HEADER_MAGIC)) + if (!be32_eq(hdr->magic, DDF_HEADER_MAGIC)) { + pr_err("%s: bad header magic\n", __func__); return 0; - if (!be32_eq(calc_crc(hdr, 512), hdr->crc)) + } + if (!be32_eq(calc_crc(hdr, 512), hdr->crc)) { + pr_err("%s: bad CRC\n", __func__); return 0; + } if (memcmp(anchor->guid, hdr->guid, DDF_GUID_LEN) != 0 || memcmp(anchor->revision, hdr->revision, 8) != 0 || !be64_eq(anchor->primary_lba, hdr->primary_lba) || !be64_eq(anchor->secondary_lba, hdr->secondary_lba) || hdr->type != type || memcmp(anchor->pad2, hdr->pad2, 512 - - offsetof(struct ddf_header, pad2)) != 0) + offsetof(struct ddf_header, pad2)) != 0) { + pr_err("%s: header mismatch\n", __func__); return 0; + } /* Looks good enough to me... */ return 1; -- 1.7.1