Rewrote a cleaner version of container / backing systems
This commit is contained in:
64
src/disk.h
Executable file → Normal file
64
src/disk.h
Executable file → Normal file
@@ -2,50 +2,52 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
/// @brief The disk information structure.
|
||||
/// @brief Structure used to store information about a qcow2 disk.
|
||||
typedef struct {
|
||||
/// @brief The virtual size of the disk, in bytes.
|
||||
uint64_t size;
|
||||
uint64_t virtual_size;
|
||||
/// @brief The actual size of the disk, in bytes.
|
||||
uint64_t allocated;
|
||||
/// @brief The path to the backing file of the disk, or NULL if the disk is not backed.
|
||||
uint64_t actual_size;
|
||||
/// @brief The path of the backing disk of this disk. If this disk is not a backing disk, this field is NULL.
|
||||
char* backing_path;
|
||||
/// @brief The name of the backing disk of this disk. If this disk is not a backing disk, this field is NULL.
|
||||
char* backing_name;
|
||||
} disk_info_t;
|
||||
|
||||
/// @brief Creates a root disk (empty disk) at the given path with the given size.
|
||||
/// @param path The path to create the disk at. Any existing file at this path will be overwritten.
|
||||
/// @brief Reads the information of the specified qcow2 disk.
|
||||
/// @param _info The pointer to where the disk information should be stored. The caller is responsible for freeing the disk information.
|
||||
/// @param disk The disk to read the information of.
|
||||
/// @return The result of the operation.
|
||||
result_t read_disk_info(disk_info_t** _info, const char* disk);
|
||||
|
||||
/// @brief Frees the specified disk information.
|
||||
/// @param info The disk information to free.
|
||||
void free_disk_info(disk_info_t* info);
|
||||
|
||||
/// @brief Creates a new root (empty) qcow2 disk with the specified size.
|
||||
/// @param disk The path of the disk to create. Any existing file at this path will be overwritten.
|
||||
/// @param size The size of the disk to create, in bytes.
|
||||
/// @return The result of the operation.
|
||||
result_t create_root_disk(const char* path, uint64_t size);
|
||||
result_t create_root_disk(const char* disk, uint64_t size);
|
||||
|
||||
/// @brief Creates a backed disk at the given path with the given backing path.
|
||||
/// @param path The path to create the disk at. Any existing file at this path will be overwritten.
|
||||
/// @param backing_path The path to the backing file to use for the disk.
|
||||
/// @brief Creates a new backed qcow2 disk with the specified backing disk.
|
||||
/// @param disk The path of the disk to create. Any existing file at this path will be overwritten.
|
||||
/// @param backing The backing disk to use.
|
||||
/// @return The result of the operation.
|
||||
result_t create_backed_disk(const char* path, const char* backing_path);
|
||||
result_t create_backed_disk(const char* disk, const char* backing);
|
||||
|
||||
/// @brief Trims (removes unused space) the given disk.
|
||||
/// @param path The path to the disk to trim.
|
||||
/// @brief Rebacks the specified qcow2 disk to the specified backing disk.
|
||||
/// @param disk The disk to reback.
|
||||
/// @param backing The backing disk to use.
|
||||
/// @return The result of the operation.
|
||||
result_t trim_disk(const char* path);
|
||||
result_t reback_disk(const char* disk, const char* backing);
|
||||
|
||||
/// @brief Resets the given disk to its initial state.
|
||||
/// @param path The path to the disk to reset.
|
||||
/// @brief Resets the specified qcow2 disk to its original state.
|
||||
/// @param disk The disk to reset.
|
||||
/// @return The result of the operation.
|
||||
result_t reset_disk(const char* path);
|
||||
result_t reset_disk(const char* disk);
|
||||
|
||||
/// @brief Changes the backing of the given disk to the given backing path. This call does not change the contents of the disk, but only the backing file path.
|
||||
/// @param path The path to the disk to reback.
|
||||
/// @param backing_path The path to the new backing file to use for the disk.
|
||||
/// @brief Trims (removes unused sparse space) the specified qcow2 disk.
|
||||
/// @param disk The disk to trim.
|
||||
/// @return The result of the operation.
|
||||
result_t reback_disk(const char* path, const char* backing_path);
|
||||
|
||||
/// @brief Gets the disk information of the disk at the given path.
|
||||
/// @param _info The disk information pointer to store the resulting disk information in. The caller is responsible for freeing the disk information.
|
||||
/// @param path The path to the disk to get the information of.
|
||||
/// @return The result of the operation.
|
||||
result_t get_disk_info(disk_info_t* _info, const char* path);
|
||||
|
||||
/// @brief Frees the given disk information.
|
||||
/// @param _info The disk information to free.
|
||||
void free_disk_info(disk_info_t* _info);
|
||||
result_t trim_disk(const char* disk);
|
||||
|
Reference in New Issue
Block a user