X-Git-Url: https://git.sven.stormbind.net/?p=sven%2Fexfatprogs.git;a=blobdiff_plain;f=dump%2Fdump.c;h=7ede5508cf8dd839b258951c0862281f5d46a83a;hp=1bd6ab23f6d904c317ba854469b5198909df6b70;hb=20b882b37d525f27c85037871c4f35f7ad2c55ba;hpb=4d5b0617d5bbdb7c887c479899b22a56d75d4c15 diff --git a/dump/dump.c b/dump/dump.c index 1bd6ab2..7ede550 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -64,7 +64,7 @@ static unsigned int exfat_count_used_clusters(unsigned char *bitmap, return count; } -int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) +static int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) { struct pbr *ppbr; struct bsx64 *pbsx; @@ -76,17 +76,17 @@ int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) unsigned char *bitmap; char *volume_label; - ppbr = malloc(bd->sector_size); + ppbr = malloc(EXFAT_MAX_SECTOR_SIZE); if (!ppbr) { exfat_err("Cannot allocate pbr: out of memory\n"); - return -1; + return -ENOMEM; } /* read main boot sector */ - ret = exfat_read_sector(bd, (char *)ppbr, BOOT_SEC_IDX); - if (ret < 0) { + if (exfat_read(bd->dev_fd, (char *)ppbr, EXFAT_MAX_SECTOR_SIZE, + 0) != (ssize_t)EXFAT_MAX_SECTOR_SIZE) { exfat_err("main boot sector read failed\n"); - ret = -1; + ret = -EIO; goto free_ppbr; } @@ -96,20 +96,19 @@ int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) pbsx->sect_size_bits > EXFAT_MAX_SECT_SIZE_BITS) { exfat_err("bogus sector size bits : %u\n", pbsx->sect_size_bits); - return -EINVAL; + ret = -EINVAL; + goto free_ppbr; } if (pbsx->sect_per_clus_bits > 25 - pbsx->sect_size_bits) { exfat_err("bogus sectors bits per cluster : %u\n", pbsx->sect_per_clus_bits); - return -EINVAL; + ret = -EINVAL; + goto free_ppbr; } - if (bd->sector_size != 1 << pbsx->sect_size_bits) { - exfat_err("bogus sectors size : %u(sector size bits : %u)\n", - bd->sector_size, pbsx->sect_size_bits); - - } + bd->sector_size_bits = pbsx->sect_size_bits; + bd->sector_size = 1 << pbsx->sect_size_bits; clu_offset = le32_to_cpu(pbsx->clu_offset); total_clus = le32_to_cpu(pbsx->clu_count); @@ -148,7 +147,7 @@ int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) goto free_entry; } - volume_label = exfat_conv_volume_serial(&ed[0]); + volume_label = exfat_conv_volume_label(&ed[0]); if (!volume_label) { ret = -EINVAL; goto free_entry; @@ -177,6 +176,7 @@ int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) bitmap = malloc(bitmap_len); if (!bitmap) { exfat_err("bitmap allocation failed\n"); + ret = -ENOMEM; goto free_volume_label; } @@ -195,6 +195,7 @@ int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd) exfat_info("Cluster size: \t\t\t\t%u\n", bd->cluster_size); exfat_info("Total Clusters: \t\t\t%u\n", total_clus); exfat_info("Free Clusters: \t\t\t\t%u\n", total_clus-used_clus); + ret = 0; free(bitmap);