Reimplemented most functions

This commit is contained in:
2024-02-17 23:59:38 +01:00
parent 1cd34dd514
commit 487982a182
10 changed files with 577 additions and 1207 deletions

View File

@@ -2,53 +2,17 @@
#include "utils.h"
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
/// @brief The information about a disk.
typedef struct {
/// @brief The virtual size of the disk.
uint64_t virtual_size;
/// @brief The actual size of the disk.
uint64_t actual_size;
/// @brief The path to the backing file of the disk. This is NULL if the disk is not backed.
uint64_t size;
uint64_t allocated;
char* backing_file;
} DiskInfo;
/// @brief Creates a root disk at the given path, with the given size and with the given permissions.
/// @param path The path to the disk to create.
/// @param size The size of the disk to create.
/// @param permissions The permissions to set on the disk.
/// @return The result of the operation.
Result create_root_disk(const char* path, uint64_t size, mode_t permissions);
Status CreateRootDisk(const char* path, uint64_t disk_size);
Status CreateBackedDisk(const char* path, const char* backing_file);
/// @brief Creates a backed disk at the given path, with the given backing disk and with the given permissions.
/// @param path The path to the disk to create.
/// @param backing_disk The disk to back the new disk with.
/// @param permissions The permissions to set on the disk.
/// @return The result of the operation.
Result create_backed_disk(const char* path, const char* backing_disk, mode_t permissions);
Status TrimDisk(const char* path);
Status RebaseDisk(const char* path, const char* backing_file);
/// @brief Trims a disk to remove any unused space.
/// @param path The path to the disk to trim.
/// @return The result of the operation.
Result trim_disk(const char* path);
/// @brief Moves a disk's backing file to the given path.
/// @param path The path to the disk to move.
/// @param backing_disk The new path to the backing disk.
/// @return The result of the operation.
Result rebase_disk(const char* path, const char* backing_disk);
/// @brief Gathers information about a disk.
/// @param path The path to the disk to gather information about.
/// @param out_info The information about the disk.
/// @return The result of the operation.
Result get_disk_info(const char* path, DiskInfo* out_info);
/// @brief Frees the resources used by the given disk information.
/// @param info The disk information to free.
void free_disk_info(DiskInfo* info);
Status GetDiskInfo(const char* path, DiskInfo* _info);
void FreeDiskInfo(DiskInfo* info);