Files
linuxinstall/src/container.h

91 lines
4.8 KiB
C
Raw Normal View History

2024-02-19 16:01:53 +01:00
#pragma once
#include "utils.h"
2024-02-20 14:54:04 +01:00
#include "disk.h"
2024-02-19 16:01:53 +01:00
#define CONTAINER_IDENTIFIER_MAX_LENGTH 64
/// @brief Checks whether the given string is a valid container identifier. If the string is not a valid container identifier, the call will return a failure result with an error message.
/// @param container The string to check.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t check_container_identifier(const char* container);
/// @brief Checks whether the given container exists. If the container does not exist, the call will return a failure result with an error message.
/// @param container The container to check.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t check_container_exists(const char* container);
/// @brief Gets the container pool path.
/// @param _path The string pointer to store the resulting path in. The caller is responsible for freeing the string.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t get_container_pool_path(char** _path);
/// @brief Gets the container path.
/// @param _path The string pointer to store the resulting path in. The caller is responsible for freeing the string.
/// @param container The container to get the path of.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t get_container_path(char** _path, const char* container);
/// @brief Adds a root (empty) container to the pool, with the given size. If the container already exists, the call will return a failure result with an error message.
/// @param container The container to add.
/// @param size The size of the container to add, in bytes.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t add_root_container(const char* container, uint64_t size);
/// @brief Adds a backed container to the pool, with the given backing. If the container already exists, or the backing does not, the call will return a failure result with an error message.
/// @param container The container to add.
/// @param backing The backing to use for the container.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t add_backed_container(const char* container, const char* backing);
/// @brief Removes the given container from the pool. If the container does not exist, the call will return a failure result with an error message.
/// @param container The container to remove.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t remove_container(const char* container);
/// @brief Trims (removes unused space) the given container.
/// @param container The container to trim.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t trim_container(const char* container);
/// @brief Resets the given container to its initial state.
/// @param container The container to reset.
/// @return The result of the operation.
2024-02-19 16:01:53 +01:00
result_t reset_container(const char* container);
/// @brief Checks that the given file is a container. This function is used as a filter for listing containers.
/// @param file The file to check.
/// @return Whether the file is a container.
2024-02-19 16:01:53 +01:00
bool container_filter(const char* file);
/// @brief Lists the containers in the pool.
/// @param _containers The string pointer array to store the resulting array in. The caller is responsible for freeing the strings and the array.
/// @return The result of the operation.
result_t list_containers(char*** _containers);
/// @brief Gets the backing of the given container. If the container does not exist, the call will return a failure result with an error message.
/// @param _backing The string pointer to store the resulting backing in.
/// @param container The container to get the backing of.
/// @return The result of the operation.
2024-02-20 14:54:04 +01:00
result_t get_container_backing(char** _backing, const char* container);
/// @brief Gets information about the given container. If the container does not exist, the call will return a failure result with an error message.
/// @param _info The string pointer to store the resulting disk information in. The caller is responsible for freeing the string.
/// @param container The container to get information about.
/// @return The result of the operation.
result_t get_container_info(disk_info_t* _info, const char* container);
/// @brief Gets the oldest container in the pool.
/// @param _container The string pointer to store the resulting container in. The caller is responsible for freeing the string.
/// @return The result of the operation.
result_t get_oldest_container(char** _container);
/// @brief Gets the available space in the pool.
/// @param _space The string pointer to store the resulting space in, in bytes. The caller is responsible for freeing the string.
/// @return The result of the operation.
result_t get_container_pool_space(uint64_t* _space);
/// @brief Reserves the given space in the pool. If the pool does not have enough space, the oldest containers will be removed to make space.
/// @param size The size to reserve, in bytes.
/// @return The result of the operation.
result_t reserve_container_pool_space(uint64_t size);