Started adding some documentation
This commit is contained in:
@@ -377,3 +377,43 @@ result_t set_default_backing(const char* backing) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result_t get_backing_parent(char** _parent, const char* backing) {
|
||||
// Initialize the output parameters
|
||||
*_parent = NULL;
|
||||
|
||||
// Get the backing path
|
||||
char* path;
|
||||
result_t result = get_backing_path(&path, backing);
|
||||
if (result != success())
|
||||
return result;
|
||||
|
||||
// Get the disk info
|
||||
disk_info_t info;
|
||||
result = get_disk_info(&info, path);
|
||||
if (result != success()) {
|
||||
free(path);
|
||||
return result;
|
||||
}
|
||||
|
||||
// If the disk is not backed, return success and a null parent
|
||||
if (info.backing_path == NULL) {
|
||||
free_disk_info(&info);
|
||||
free(path);
|
||||
return success();
|
||||
}
|
||||
|
||||
// Get the backing identifier of the parent
|
||||
char* parent = strdup(basename(info.backing_path));
|
||||
if (parent == NULL) {
|
||||
free_disk_info(&info);
|
||||
free(path);
|
||||
return failure("Failed to get the backing identifier of the parent.");
|
||||
}
|
||||
|
||||
free_disk_info(&info);
|
||||
free(path);
|
||||
|
||||
*_parent = parent;
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user