54 lines
2.3 KiB
C
54 lines
2.3 KiB
C
#pragma once
|
|
|
|
#include "utils.h"
|
|
|
|
/// @brief Structure used to store information about a qcow2 disk.
|
|
typedef struct {
|
|
/// @brief The virtual size of the disk, in bytes.
|
|
uint64_t virtual_size;
|
|
/// @brief The actual size of the disk, in bytes.
|
|
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 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* disk, uint64_t size);
|
|
|
|
/// @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* disk, const char* backing);
|
|
|
|
/// @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 reback_disk(const char* disk, const char* backing);
|
|
|
|
/// @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* 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 trim_disk(const char* disk);
|