diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-04-30 20:00:05 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-05-02 02:49:07 +0200 |
| commit | 370b3de68bd9862f69b34b1b69c9ded503250054 (patch) | |
| tree | e783bea43a23f2c78c4432b250703ce4fbb77e57 | |
| parent | 054612f2417b666ef0ae906dea3646674d2be5ed (diff) | |
Add some more debugging.
| -rw-r--r-- | blockdev/linux/file_dev.c | 23 | ||||
| -rw-r--r-- | src/ext4_mbr.c | 8 |
2 files changed, 24 insertions, 7 deletions
diff --git a/blockdev/linux/file_dev.c b/blockdev/linux/file_dev.c index 4dc53f3..fa29f30 100644 --- a/blockdev/linux/file_dev.c +++ b/blockdev/linux/file_dev.c @@ -32,6 +32,7 @@ #include <ext4_config.h> #include <ext4_blockdev.h> #include <ext4_errno.h> +#include <ext4_debug.h> #include <stdio.h> #include <stdbool.h> #include <string.h> @@ -71,8 +72,10 @@ static int file_dev_open(struct ext4_blockdev *bdev) { dev_file = fopen(fname, "r+b"); - if (!dev_file) + if (!dev_file) { + printf("fopen of %s failed %d\n", fname, errno); return EIO; + } /*No buffering at file.*/ setbuf(dev_file, 0); @@ -83,11 +86,13 @@ static int file_dev_open(struct ext4_blockdev *bdev) */ uint64_t sectors = 0; if (ioctl(fileno(dev_file), DKIOCGETBLOCKCOUNT, §ors) < 0) { + printf("ioctl DKIOCGETBLOCKCOUNT failed %d\n", errno); fclose(dev_file); return EFAULT; } uint32_t sector_size = 0; if (ioctl(fileno(dev_file), DKIOCGETBLOCKSIZE, §or_size) < 0) { + printf("ioctl DKIOCGETBLOCKSIZE failed %d\n", errno); fclose(dev_file); return EFAULT; } @@ -112,12 +117,16 @@ static int file_dev_open(struct ext4_blockdev *bdev) static int file_dev_bread(struct ext4_blockdev *bdev, void *buf, uint64_t blk_id, uint32_t blk_cnt) { - if (fseeko(dev_file, blk_id * bdev->bdif->ph_bsize, SEEK_SET)) + if (fseeko(dev_file, blk_id * bdev->bdif->ph_bsize, SEEK_SET)) { + printf("fseeko failed %d\n", errno); return EIO; + } if (!blk_cnt) return EOK; - if (!fread(buf, bdev->bdif->ph_bsize * blk_cnt, 1, dev_file)) + if (!fread(buf, bdev->bdif->ph_bsize * blk_cnt, 1, dev_file)) { + printf("fread failed %d\n", errno); return EIO; + } return EOK; } @@ -139,12 +148,16 @@ static void drop_cache(void) static int file_dev_bwrite(struct ext4_blockdev *bdev, const void *buf, uint64_t blk_id, uint32_t blk_cnt) { - if (fseeko(dev_file, blk_id * bdev->bdif->ph_bsize, SEEK_SET)) + if (fseeko(dev_file, blk_id * bdev->bdif->ph_bsize, SEEK_SET)) { + printf("fseeko failed %d\n", errno); return EIO; + } if (!blk_cnt) return EOK; - if (!fwrite(buf, bdev->bdif->ph_bsize * blk_cnt, 1, dev_file)) + if (!fwrite(buf, bdev->bdif->ph_bsize * blk_cnt, 1, dev_file)) { + printf("fwrite failed %d\n", errno); return EIO; + } drop_cache(); return EOK; diff --git a/src/ext4_mbr.c b/src/ext4_mbr.c index c143c02..63aeeda 100644 --- a/src/ext4_mbr.c +++ b/src/ext4_mbr.c @@ -139,8 +139,10 @@ int ext4_mbr_write(struct ext4_blockdev *parent, struct ext4_mbr_parts *parts, u ext4_dbg(DEBUG_MBR, DBG_INFO "ext4_mbr_write\n"); r = ext4_block_init(parent); - if (r != EOK) + if (r != EOK) { + ext4_dbg(DEBUG_MBR, DBG_INFO "ext4_mbr_write failed\n"); return r; + } disk_size = parent->part_size; @@ -193,8 +195,10 @@ int ext4_mbr_write(struct ext4_blockdev *parent, struct ext4_mbr_parts *parts, u mbr->signature = MBR_SIGNATURE; r = ext4_block_writebytes(parent, 0, parent->bdif->ph_bbuf, 512); - if (r != EOK) + if (r != EOK) { + ext4_dbg(DEBUG_MBR, DBG_INFO "ext4_block_writebytes failed\n"); goto blockdev_fini; + } blockdev_fini: |
