mirror of
https://github.com/limine-bootloader/limine
synced 2025-02-08 05:04:14 +03:00
host/limine: Improve error reporting from uninstall()
This commit is contained in:
parent
8f14ccf1e8
commit
2cb61f4744
@ -496,7 +496,11 @@ skip_save:;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uninstall(void) {
|
static bool uninstall(bool quiet_arg) {
|
||||||
|
bool print_cache_flush_fail = false;
|
||||||
|
bool print_write_fail = false;
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
uninstalling = true;
|
uninstalling = true;
|
||||||
|
|
||||||
cache_state = CACHE_CLEAN;
|
cache_state = CACHE_CLEAN;
|
||||||
@ -507,14 +511,15 @@ static void uninstall(void) {
|
|||||||
bool retry = false;
|
bool retry = false;
|
||||||
while (!_device_write(ud->data, ud->loc, ud->count)) {
|
while (!_device_write(ud->data, ud->loc, ud->count)) {
|
||||||
if (retry) {
|
if (retry) {
|
||||||
fprintf(stderr, "%s: error: Uninstall data index %zu failed to write. Uninstall may be incomplete!\n", program_name, i);
|
fprintf(stderr, "%s: warning: Retry failed.\n", program_name);
|
||||||
|
print_write_fail = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
fprintf(stderr, "%s: warning: Uninstall data index %zu failed to write, retrying...\n", program_name, i);
|
fprintf(stderr, "%s: warning: Uninstall data index %zu failed to write, retrying...\n", program_name, i);
|
||||||
}
|
}
|
||||||
if (!device_flush_cache()) {
|
if (!device_flush_cache()) {
|
||||||
fprintf(stderr, "%s: error: Device cache flush failure. Uninstall may be incomplete!\n", program_name);
|
print_cache_flush_fail = true;
|
||||||
}
|
}
|
||||||
cache_state = CACHE_CLEAN;
|
cache_state = CACHE_CLEAN;
|
||||||
cached_block = (uint64_t)-1;
|
cached_block = (uint64_t)-1;
|
||||||
@ -523,12 +528,24 @@ static void uninstall(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!device_flush_cache()) {
|
if (!device_flush_cache()) {
|
||||||
fprintf(stderr, "%s: error: Device cache flush failure. Uninstall may be incomplete!\n", program_name);
|
print_cache_flush_fail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quiet) {
|
if (print_write_fail) {
|
||||||
fprintf(stderr, "Uninstall data restored successfully. Limine uninstalled!\n");
|
fprintf(stderr, "%s: error: Some data failed to be uninstalled correctly.\n", program_name);
|
||||||
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (print_cache_flush_fail) {
|
||||||
|
fprintf(stderr, "%s: error: Device cache flush failure. Uninstall may be incomplete.\n", program_name);
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == true && !quiet && !quiet_arg) {
|
||||||
|
fprintf(stderr, "Uninstall data restored successfully.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define device_read(BUFFER, LOC, COUNT) \
|
#define device_read(BUFFER, LOC, COUNT) \
|
||||||
@ -639,9 +656,11 @@ static int bios_install(int argc, char *argv[]) {
|
|||||||
goto uninstall_mode_cleanup;
|
goto uninstall_mode_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
uninstall();
|
if (uninstall(false) == false) {
|
||||||
|
ok = EXIT_FAILURE;
|
||||||
ok = EXIT_SUCCESS;
|
} else {
|
||||||
|
ok = EXIT_SUCCESS;
|
||||||
|
}
|
||||||
goto uninstall_mode_cleanup;
|
goto uninstall_mode_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1005,7 +1024,8 @@ cleanup:
|
|||||||
reverse_uninstall_data();
|
reverse_uninstall_data();
|
||||||
if (ok != EXIT_SUCCESS) {
|
if (ok != EXIT_SUCCESS) {
|
||||||
// If we failed, attempt to reverse install process
|
// If we failed, attempt to reverse install process
|
||||||
uninstall();
|
fprintf(stderr, "%s: Install failed, undoing work...\n", program_name);
|
||||||
|
uninstall(true);
|
||||||
} else if (uninstall_file != NULL) {
|
} else if (uninstall_file != NULL) {
|
||||||
store_uninstall_data(uninstall_file);
|
store_uninstall_data(uninstall_file);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user