fix slightly incorrect cluster boundaries written by shadow_image
This commit is contained in:
@@ -106,6 +106,7 @@ enum ec3_status shadow_image_init(
|
|||||||
cluster_table_init_empty_table(&out->img_cluster_table);
|
cluster_table_init_empty_table(&out->img_cluster_table);
|
||||||
|
|
||||||
out->img_nr_bytes = sizeof header;
|
out->img_nr_bytes = sizeof header;
|
||||||
|
out->img_cluster_data_offset = out->img_nr_bytes;
|
||||||
out->img_extent_table = b_buffer_create(sizeof(struct ec3_extent_info));
|
out->img_extent_table = b_buffer_create(sizeof(struct ec3_extent_info));
|
||||||
out->img_tag_table = b_buffer_create(sizeof(struct ec3_tag_info));
|
out->img_tag_table = b_buffer_create(sizeof(struct ec3_tag_info));
|
||||||
|
|
||||||
@@ -434,7 +435,7 @@ static enum ec3_status put_empty_cluster(
|
|||||||
|
|
||||||
struct cluster cluster = {0};
|
struct cluster cluster = {0};
|
||||||
cluster.c_id = image->img_nr_clusters;
|
cluster.c_id = image->img_nr_clusters;
|
||||||
cluster.c_base = image->img_nr_bytes;
|
cluster.c_base = image->img_nr_bytes - image->img_cluster_data_offset;
|
||||||
cluster.c_len = encoded_size;
|
cluster.c_len = encoded_size;
|
||||||
|
|
||||||
image->img_nr_clusters++;
|
image->img_nr_clusters++;
|
||||||
@@ -493,7 +494,7 @@ static enum ec3_status copy_cached_cluster(
|
|||||||
|
|
||||||
struct cluster cluster = {0};
|
struct cluster cluster = {0};
|
||||||
cluster.c_id = image->img_nr_clusters;
|
cluster.c_id = image->img_nr_clusters;
|
||||||
cluster.c_base = image->img_nr_bytes;
|
cluster.c_base = image->img_nr_bytes - image->img_cluster_data_offset;
|
||||||
cluster.c_len = encoded_size;
|
cluster.c_len = encoded_size;
|
||||||
|
|
||||||
image->img_nr_clusters++;
|
image->img_nr_clusters++;
|
||||||
@@ -577,7 +578,8 @@ static enum ec3_status copy_cluster_range(
|
|||||||
}
|
}
|
||||||
|
|
||||||
cluster.c_id = dest->img_nr_clusters;
|
cluster.c_id = dest->img_nr_clusters;
|
||||||
cluster.c_base = dest->img_nr_bytes;
|
cluster.c_base
|
||||||
|
= dest->img_nr_bytes - dest->img_cluster_data_offset;
|
||||||
|
|
||||||
size_t nr_written = 0;
|
size_t nr_written = 0;
|
||||||
status2 = b_file_write(
|
status2 = b_file_write(
|
||||||
@@ -611,7 +613,7 @@ static enum ec3_status write_wseq_tag(
|
|||||||
{
|
{
|
||||||
size_t cluster_id_offset = dest->img_nr_clusters;
|
size_t cluster_id_offset = dest->img_nr_clusters;
|
||||||
size_t cluster_id_limit = cluster_id_offset;
|
size_t cluster_id_limit = cluster_id_offset;
|
||||||
size_t data_offset = dest->img_nr_bytes;
|
size_t data_offset = dest->img_nr_bytes - dest->img_cluster_data_offset;
|
||||||
size_t first_logical_cluster = 0;
|
size_t first_logical_cluster = 0;
|
||||||
|
|
||||||
struct cluster_table *clusters = &ioctx->io_cluster_table;
|
struct cluster_table *clusters = &ioctx->io_cluster_table;
|
||||||
@@ -785,7 +787,7 @@ enum ec3_status shadow_image_write_tag(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t last_cluster = dest->img_nr_clusters;
|
size_t nr_clusters = dest->img_nr_clusters - first_cluster;
|
||||||
|
|
||||||
struct ec3_extent_info *extent = NULL;
|
struct ec3_extent_info *extent = NULL;
|
||||||
b_buffer_push_back(dest->img_extent_table, 1, (void **)&extent);
|
b_buffer_push_back(dest->img_extent_table, 1, (void **)&extent);
|
||||||
@@ -793,7 +795,7 @@ enum ec3_status shadow_image_write_tag(
|
|||||||
extent->ex_owner = tag->tag_ident;
|
extent->ex_owner = tag->tag_ident;
|
||||||
extent->ex_logical_cluster = 0;
|
extent->ex_logical_cluster = 0;
|
||||||
extent->ex_physical_cluster = first_cluster;
|
extent->ex_physical_cluster = first_cluster;
|
||||||
extent->ex_count = last_cluster - first_cluster;
|
extent->ex_count = nr_clusters;
|
||||||
|
|
||||||
b_buffer_append(dest->img_tag_table, tag, 1);
|
b_buffer_append(dest->img_tag_table, tag, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ struct ec3_tag_info;
|
|||||||
struct shadow_image {
|
struct shadow_image {
|
||||||
size_t img_nr_clusters;
|
size_t img_nr_clusters;
|
||||||
size_t img_nr_bytes;
|
size_t img_nr_bytes;
|
||||||
|
size_t img_cluster_data_offset;
|
||||||
struct b_file *img_f_data;
|
struct b_file *img_f_data;
|
||||||
struct b_file *img_f_cluster_table;
|
struct b_file *img_f_cluster_table;
|
||||||
struct cluster_table img_cluster_table;
|
struct cluster_table img_cluster_table;
|
||||||
|
|||||||
Reference in New Issue
Block a user