diff --git a/src/backing.c b/src/backing.c index 160b332..43faecc 100755 --- a/src/backing.c +++ b/src/backing.c @@ -419,3 +419,28 @@ result_t get_backing_parent(char** _parent, const char* backing) { *_parent = parent; return success(); } + +result_t get_backing_info(disk_info_t* _info, const char* backing) { + // Initialize the output parameters + _info->size = 0; + _info->allocated = 0; + _info->backing_path = NULL; + + // Check that the backing exists + result_t result = check_backing_exists(backing); + if (result != success()) + return result; + + // Get the backing path + char* path; + result = get_backing_path(&path, backing); + if (result != success()) + return result; + + // Get the disk information + result = get_disk_info(_info, path); + + free(path); + + return result; +} diff --git a/src/backing.h b/src/backing.h index c94d4a0..55f628f 100755 --- a/src/backing.h +++ b/src/backing.h @@ -74,4 +74,10 @@ result_t set_default_backing(const char* backing); /// @param _parent The string pointer to store the resulting backing parent identifier in. The caller is responsible for freeing the string. /// @param backing The backing to get the parent of. /// @return The result of the operation. -result_t get_backing_parent(char** _parent, const char* backing); \ No newline at end of file +result_t get_backing_parent(char** _parent, const char* backing); + +/// @brief Gets information about the given backing. If the backing 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 backing The backing to get information about. +/// @return The result of the operation. +result_t get_backing_info(disk_info_t* _info, const char* backing);