unwrap: support unwrapping tags with odd-sized clusters
This commit is contained in:
@@ -86,6 +86,8 @@ static int unwrap(
|
||||
const struct ec3_tag_info *target_tag_info
|
||||
= ec3_image_ioctx_get_tag_info_by_id(image, target_tag_ident);
|
||||
size_t tag_length = target_tag_info->tag_total_length;
|
||||
size_t total_clusters;
|
||||
ec3_tag_ioctx_get_nr_clusters(tag, &total_clusters);
|
||||
|
||||
printf("reading %zu bytes from tag %s...\n", tag_length, ident_str);
|
||||
|
||||
@@ -93,7 +95,7 @@ static int unwrap(
|
||||
|
||||
int ret = 0;
|
||||
FILE *outp = fopen("data.bin", "wb");
|
||||
for (size_t i = 0;; i++) {
|
||||
for (size_t i = 0; i < total_clusters; i++) {
|
||||
size_t nr_read = 0;
|
||||
enum ec3_status status
|
||||
= ec3_tag_ioctx_read_cluster(tag, i, buf, &nr_read);
|
||||
@@ -108,10 +110,6 @@ static int unwrap(
|
||||
|
||||
printf("read %zu bytes from cluster %zu\n", nr_read, i);
|
||||
fwrite(buf, 1, nr_read, outp);
|
||||
|
||||
if (nr_read < c_info->img_cluster_size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
Reference in New Issue
Block a user