From a9be69eed774739d8a6fbd2bae21e9c272272f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexe=C3=AF=20KADIR?= Date: Mon, 19 Feb 2024 19:48:11 +0100 Subject: [PATCH] Added some documentation on disk operations --- src/disk.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/disk.h b/src/disk.h index f0ddc1f..07425f3 100755 --- a/src/disk.h +++ b/src/disk.h @@ -2,18 +2,50 @@ #include "utils.h" +/// @brief The disk information structure. typedef struct { + /// @brief The virtual size of the disk, in bytes. uint64_t 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. char* backing_path; } 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); + +/// @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); +/// @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); + +/// @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); + +/// @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); +/// @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); + +/// @brief Frees the given disk information. +/// @param _info The disk information to free. void free_disk_info(disk_info_t* _info);