2025-02-23 20:52:59 +00:00
|
|
|
#ifndef IMAGE_H_
|
|
|
|
|
#define IMAGE_H_
|
|
|
|
|
|
|
|
|
|
#include "status.h"
|
|
|
|
|
#include "tag.h"
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
struct b_file;
|
|
|
|
|
struct b_buffer;
|
|
|
|
|
|
|
|
|
|
struct cluster;
|
|
|
|
|
struct string_table;
|
|
|
|
|
struct chunk_table;
|
|
|
|
|
|
|
|
|
|
enum ec3_tag_ioctx_mode;
|
|
|
|
|
|
|
|
|
|
struct ec3_parameters {
|
|
|
|
|
unsigned int p_cluster_size;
|
|
|
|
|
|
|
|
|
|
unsigned int p_compression_func;
|
|
|
|
|
unsigned int p_encryption_func;
|
|
|
|
|
uint64_t p_ident;
|
|
|
|
|
|
|
|
|
|
const void *p_encryption_key;
|
|
|
|
|
size_t p_encryption_key_size;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ec3_image_info {
|
|
|
|
|
unsigned short img_version;
|
|
|
|
|
unsigned short img_cluster_size;
|
|
|
|
|
size_t img_tag_table_offset;
|
|
|
|
|
size_t img_extent_table_offset;
|
|
|
|
|
size_t img_cluster_table_offset;
|
|
|
|
|
size_t img_cluster_data_offset;
|
|
|
|
|
unsigned int img_nr_tags;
|
|
|
|
|
unsigned int img_nr_extents;
|
|
|
|
|
unsigned int img_nr_cluster_groups;
|
|
|
|
|
|
|
|
|
|
unsigned int img_encryption_function;
|
|
|
|
|
unsigned int img_compression_function;
|
|
|
|
|
|
|
|
|
|
uint64_t img_id;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ec3_extent_info {
|
|
|
|
|
unsigned long long ex_owner;
|
|
|
|
|
unsigned long ex_logical_cluster;
|
|
|
|
|
unsigned long ex_physical_cluster;
|
|
|
|
|
unsigned long ex_count;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ec3_image_ioctx_mode {
|
|
|
|
|
EC3_IMAGE_IO_READ = 0x01u,
|
|
|
|
|
EC3_IMAGE_IO_WRITE = 0x02u,
|
|
|
|
|
EC3_IMAGE_IO_READWRITE = EC3_IMAGE_IO_READ | EC3_IMAGE_IO_WRITE,
|
2025-02-24 15:43:40 +00:00
|
|
|
EC3_IMAGE_IO_TRUNCATE = 0x04u,
|
2025-02-23 20:52:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ec3_image_ioctx {
|
|
|
|
|
enum ec3_image_ioctx_mode io_mode;
|
|
|
|
|
struct ec3_image_info io_header;
|
|
|
|
|
/* buffer of struct ec3_tag_info */
|
|
|
|
|
struct b_buffer *io_tag_table;
|
|
|
|
|
/* buffer of struct ec3_tag_info */
|
|
|
|
|
struct b_buffer *io_extent_table;
|
|
|
|
|
/* btree list of struct ec3_tag_ioctx */
|
|
|
|
|
struct b_btree io_opened_tags;
|
|
|
|
|
|
|
|
|
|
/* when reading existing images, this will reference the on-disk cluster
|
|
|
|
|
* table */
|
|
|
|
|
struct cluster_table io_cluster_table;
|
|
|
|
|
|
|
|
|
|
struct b_file *io_main;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_open(
|
|
|
|
|
const char *path,
|
|
|
|
|
const struct ec3_parameters *param,
|
|
|
|
|
enum ec3_image_ioctx_mode mode,
|
|
|
|
|
struct ec3_image_ioctx **out);
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_close(struct ec3_image_ioctx *image);
|
|
|
|
|
|
|
|
|
|
extern const struct ec3_image_info *ec3_image_ioctx_get_info(
|
|
|
|
|
struct ec3_image_ioctx *image);
|
|
|
|
|
extern const struct ec3_tag_info *ec3_image_ioctx_get_tag_info(
|
|
|
|
|
struct ec3_image_ioctx *image);
|
|
|
|
|
extern const struct ec3_tag_info *ec3_image_ioctx_get_tag_info_by_id(
|
|
|
|
|
struct ec3_image_ioctx *image,
|
|
|
|
|
uint64_t id);
|
|
|
|
|
extern const struct ec3_extent_info *ec3_image_ioctx_get_extent_info(
|
|
|
|
|
struct ec3_image_ioctx *image);
|
|
|
|
|
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_open_string_table(
|
|
|
|
|
struct ec3_image_ioctx *image,
|
|
|
|
|
enum ec3_image_ioctx_mode mode,
|
|
|
|
|
struct string_table **out);
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_open_chunk_table(
|
|
|
|
|
struct ec3_image_ioctx *image,
|
|
|
|
|
enum ec3_image_ioctx_mode mode,
|
|
|
|
|
struct chunk_table **out);
|
|
|
|
|
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_open_tag_by_type(
|
|
|
|
|
struct ec3_image_ioctx *image,
|
|
|
|
|
uint32_t type,
|
|
|
|
|
unsigned int index,
|
|
|
|
|
enum ec3_tag_ioctx_mode mode,
|
|
|
|
|
struct ec3_tag_ioctx **out);
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_open_tag_by_id(
|
|
|
|
|
struct ec3_image_ioctx *image,
|
|
|
|
|
uint64_t id,
|
|
|
|
|
enum ec3_tag_ioctx_mode mode,
|
|
|
|
|
struct ec3_tag_ioctx **out);
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_create_tag(
|
|
|
|
|
struct ec3_image_ioctx *image,
|
|
|
|
|
uint32_t type,
|
|
|
|
|
uint64_t id,
|
|
|
|
|
enum ec3_tag_ioctx_mode mode,
|
|
|
|
|
struct ec3_tag_ioctx **out);
|
|
|
|
|
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_cluster_logical_to_physical(
|
|
|
|
|
struct ec3_image_ioctx *image,
|
|
|
|
|
const struct ec3_tag_info *tag,
|
|
|
|
|
size_t logical_cluster,
|
|
|
|
|
size_t *out_physical_cluster);
|
|
|
|
|
extern enum ec3_status ec3_image_ioctx_get_tag_nr_clusters(
|
|
|
|
|
struct ec3_image_ioctx *image,
|
|
|
|
|
const struct ec3_tag_info *tag,
|
|
|
|
|
size_t *out_nr_cluster);
|
|
|
|
|
|
|
|
|
|
#endif
|