Added some documentation on disk operations

This commit is contained in:
Alexei KADIR 2024-02-19 19:48:11 +01:00
parent 4c22e13ad9
commit a9be69eed7

View File

@ -2,18 +2,50 @@
#include "utils.h" #include "utils.h"
/// @brief The disk information structure.
typedef struct { typedef struct {
/// @brief The virtual size of the disk, in bytes.
uint64_t size; uint64_t size;
/// @brief The actual size of the disk, in bytes.
uint64_t allocated; uint64_t allocated;
/// @brief The path to the backing file of the disk, or NULL if the disk is not backed.
char* backing_path; char* backing_path;
} disk_info_t; } 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.
/// @param size The size of the disk to create.
/// @return The result of the operation.
result_t create_root_disk(const char* path, uint64_t size); result_t create_root_disk(const char* path, 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.
/// @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* path, const char* backing_path);
/// @brief Trims (removes unused space) the given disk.
/// @param path The path to the disk to trim.
/// @return The result of the operation.
result_t trim_disk(const char* path); result_t trim_disk(const char* path);
/// @brief Resets the given disk to its original state.
/// @param path The path to the disk to reset.
/// @return The result of the operation.
result_t reset_disk(const char* path); result_t reset_disk(const char* path);
/// @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.
/// @return The result of the operation.
result_t reback_disk(const char* path, const char* backing_path); 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 result 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); 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); void free_disk_info(disk_info_t* _info);