each tag ioctx now keeps its own copy of the ec3_tag_info describing it
this fixes an issue where pointers to ec3_tag_info would become invalid when the b_buffer containing them was resized.
This commit is contained in:
10
src/image.c
10
src/image.c
@@ -16,12 +16,12 @@ B_BTREE_DEFINE_SIMPLE_GET(
|
||||
struct ec3_tag_ioctx,
|
||||
uint64_t,
|
||||
io_node,
|
||||
io_tag_info->tag_ident,
|
||||
io_tag_info.tag_ident,
|
||||
get_opened_tag)
|
||||
B_BTREE_DEFINE_SIMPLE_INSERT(
|
||||
struct ec3_tag_ioctx,
|
||||
io_node,
|
||||
io_tag_info->tag_ident,
|
||||
io_tag_info.tag_ident,
|
||||
put_opened_tag)
|
||||
|
||||
static enum ec3_status decode_header(
|
||||
@@ -729,7 +729,7 @@ enum ec3_status ec3_image_ioctx_open_tag_by_type(
|
||||
|
||||
tag_ioctx->io_mode = mode;
|
||||
tag_ioctx->io_parent = image;
|
||||
tag_ioctx->io_tag_info = tag_info;
|
||||
tag_ioctx->io_tag_info = *tag_info;
|
||||
tag_ioctx->io_f_image = b_file_retain(image->io_main);
|
||||
|
||||
if (mode & EC3_TAG_IO_WRITE) {
|
||||
@@ -791,7 +791,7 @@ enum ec3_status ec3_image_ioctx_open_tag_by_id(
|
||||
|
||||
tag_ioctx->io_mode = mode;
|
||||
tag_ioctx->io_parent = image;
|
||||
tag_ioctx->io_tag_info = tag_info;
|
||||
tag_ioctx->io_tag_info = *tag_info;
|
||||
tag_ioctx->io_f_image = b_file_retain(image->io_main);
|
||||
|
||||
if (mode & EC3_TAG_IO_WRITE) {
|
||||
@@ -862,7 +862,7 @@ enum ec3_status ec3_image_ioctx_create_tag(
|
||||
|
||||
tag_ioctx->io_mode = mode;
|
||||
tag_ioctx->io_parent = image;
|
||||
tag_ioctx->io_tag_info = tag_info;
|
||||
tag_ioctx->io_tag_info = *tag_info;
|
||||
tag_ioctx->io_f_image = b_file_retain(image->io_main);
|
||||
|
||||
status = init_tag_ioctx_create(image, tag_info, tag_ioctx);
|
||||
|
||||
@@ -44,14 +44,6 @@ struct ec3_image_info {
|
||||
uint64_t img_id;
|
||||
};
|
||||
|
||||
struct ec3_tag_info {
|
||||
unsigned long tag_type;
|
||||
unsigned long tag_flags;
|
||||
unsigned long tag_checksum;
|
||||
unsigned long long tag_ident;
|
||||
unsigned long long tag_total_length;
|
||||
};
|
||||
|
||||
struct ec3_extent_info {
|
||||
unsigned long long ex_owner;
|
||||
unsigned long ex_logical_cluster;
|
||||
|
||||
@@ -142,7 +142,7 @@ enum ec3_status ec3_tag_ioctx_read_cluster(
|
||||
size_t physical_cluster_id = 0;
|
||||
status = ec3_image_ioctx_cluster_logical_to_physical(
|
||||
tag->io_parent,
|
||||
tag->io_tag_info,
|
||||
&tag->io_tag_info,
|
||||
cluster_id,
|
||||
&physical_cluster_id);
|
||||
|
||||
@@ -276,7 +276,7 @@ enum ec3_status ec3_tag_ioctx_get_nr_clusters(
|
||||
|
||||
for (size_t i = 0; i < nr_extents; i++) {
|
||||
const struct ec3_extent_info *x = &extents[i];
|
||||
if (x->ex_owner != tag->io_tag_info->tag_ident) {
|
||||
if (x->ex_owner != tag->io_tag_info.tag_ident) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
10
src/tag.h
10
src/tag.h
@@ -20,6 +20,14 @@ enum ec3_tag_ioctx_mode {
|
||||
EC3_TAG_IO_CLOSED = 0x10u,
|
||||
};
|
||||
|
||||
struct ec3_tag_info {
|
||||
unsigned long tag_type;
|
||||
unsigned long tag_flags;
|
||||
unsigned long tag_checksum;
|
||||
unsigned long long tag_ident;
|
||||
unsigned long long tag_total_length;
|
||||
};
|
||||
|
||||
struct ec3_tag_ioctx {
|
||||
struct ec3_image_ioctx *io_parent;
|
||||
b_btree_node io_node;
|
||||
@@ -32,7 +40,7 @@ struct ec3_tag_ioctx {
|
||||
size_t io_cluster_data_offset;
|
||||
|
||||
/* this points to memory belonging to ec3_image_ioctx */
|
||||
const struct ec3_tag_info *io_tag_info;
|
||||
struct ec3_tag_info io_tag_info;
|
||||
|
||||
/* io_f_rotag is a reference to the main image file. a data and cluster
|
||||
* table offset will be used to read clusters from the image if the tag
|
||||
|
||||
Reference in New Issue
Block a user