]> git.sven.stormbind.net Git - sven/exfatprogs.git/blobdiff - dump/dump.c
New upstream version 1.1.1
[sven/exfatprogs.git] / dump / dump.c
index 1bd6ab23f6d904c317ba854469b5198909df6b70..85d5101f40e8653d193d32e4304390aa5902c9f5 100644 (file)
@@ -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;
@@ -79,14 +79,14 @@ int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd)
        ppbr = malloc(bd->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) {
                exfat_err("main boot sector read failed\n");
-               ret = -1;
+               ret = -EIO;
                goto free_ppbr;
        }
 
@@ -96,19 +96,22 @@ 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",
+               exfat_err("bogus sector size : %u (sector size bits : %u)\n",
                                bd->sector_size, pbsx->sect_size_bits);
-
+               ret = -EINVAL;
+               goto free_ppbr;
        }
 
        clu_offset = le32_to_cpu(pbsx->clu_offset);
@@ -148,7 +151,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 +180,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 +199,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);