2024-02-17 00:57:30 +01:00
# pragma once
# include "utils.h"
2024-02-19 19:48:11 +01:00
/// @brief The disk information structure.
2024-02-17 01:20:20 +01:00
typedef struct {
2024-02-19 19:48:11 +01:00
/// @brief The virtual size of the disk, in bytes.
2024-02-17 23:59:38 +01:00
uint64_t size ;
2024-02-19 19:48:11 +01:00
/// @brief The actual size of the disk, in bytes.
2024-02-17 23:59:38 +01:00
uint64_t allocated ;
2024-02-19 19:48:11 +01:00
/// @brief The path to the backing file of the disk, or NULL if the disk is not backed.
2024-02-19 16:01:53 +01:00
char * backing_path ;
} disk_info_t ;
2024-02-17 01:20:20 +01:00
2024-02-19 19:48:11 +01:00
/// @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.
2024-02-19 16:01:53 +01:00
result_t create_root_disk ( const char * path , uint64_t size ) ;
2024-02-19 19:48:11 +01:00
/// @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.
2024-02-19 16:01:53 +01:00
result_t create_backed_disk ( const char * path , const char * backing_path ) ;
2024-02-17 01:20:20 +01:00
2024-02-19 19:48:11 +01:00
/// @brief Trims (removes unused space) the given disk.
/// @param path The path to the disk to trim.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t trim_disk ( const char * path ) ;
2024-02-19 19:48:11 +01:00
/// @brief Resets the given disk to its original state.
/// @param path The path to the disk to reset.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t reset_disk ( const char * path ) ;
2024-02-19 19:48:11 +01:00
/// @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.
2024-02-19 16:01:53 +01:00
result_t reback_disk ( const char * path , const char * backing_path ) ;
2024-02-19 19:48:11 +01:00
/// @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.
2024-02-19 16:01:53 +01:00
result_t get_disk_info ( disk_info_t * _info , const char * path ) ;
2024-02-19 19:48:11 +01:00
/// @brief Frees the given disk information.
/// @param _info The disk information to free.
2024-02-19 16:01:53 +01:00
void free_disk_info ( disk_info_t * _info ) ;