Added disk resetting

This commit is contained in:
2024-02-17 12:35:33 +01:00
parent 694092e12e
commit 2d1f228ad0
3 changed files with 50 additions and 0 deletions

View File

@@ -230,6 +230,33 @@ Result remove_entry(const char* entry_id) {
return SUCCESS;
}
Result reset_entry(const char* entry_id) {
// Check that it exists
bool exists;
Result result = entry_exists(entry_id, &exists);
if (result != SUCCESS)
return result;
if (!exists) {
log_message(LOG_LEVEL_ERROR, "The entry '%s' does not exist.", entry_id);
return FAILURE;
}
// Get the path of the disk
char* disk_path;
result = get_entry_disk_path(entry_id, &disk_path);
if (result != SUCCESS)
return result;
// Reset the disk
result = reset_disk(disk_path);
// Free the disk path
free(disk_path);
return result;
}
Result get_entry_info(const char* entry_id, EntryInfo* out_info) {
out_info->backing_id = NULL;
out_info->type = ENTRY_TYPE_UNKNOWN;