2024-02-17 00:57:30 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2024-02-17 01:20:20 +01:00
|
|
|
/// @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.
|
|
|
|
char* backing_file;
|
|
|
|
} DiskInfo;
|
|
|
|
|
2024-02-17 02:18:16 +01:00
|
|
|
/// @brief Creates a root disk at the given path, with the given size and with the given permissions.
|
2024-02-17 00:57:30 +01:00
|
|
|
/// @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.
|
2024-02-17 02:18:16 +01:00
|
|
|
Result create_root_disk(const char* path, uint64_t size, mode_t permissions);
|
2024-02-17 00:57:30 +01:00
|
|
|
|
|
|
|
/// @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);
|
|
|
|
|
|
|
|
/// @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);
|
2024-02-17 01:20:20 +01:00
|
|
|
|
|
|
|
/// @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);
|