diff options
author | Petr Tesarik <ptesarik@suse.com> | 2020-03-13 15:09:28 +0100 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2020-04-01 14:37:11 +0200 |
commit | 4f77da6340356de40af70473d3c3ae6ec663fbdf (patch) | |
tree | deeadaf7cc39485d06f750cb8d4063e7025da9ca /kexec/kexec.h | |
parent | a4afe68d9afaeb219c734e73bc4042ac3aa64836 (diff) | |
download | kexec-tools-4f77da6340356de40af70473d3c3ae6ec663fbdf.tar.gz |
kexec-tools: Fix kexec_file_load(2) error handling
The handling of kexec_file_load() error conditions needs some
improvement.
First, on failure, the system call itself returns -1 and sets
errno. It is wrong to check the return value itself.
Second, do_kexec_file_load() mixes different types of error
codes (-1, return value of a load method, negative kernel error
number). Let it always return one of the reason codes defined in
kexec/kexec.h.
Third, the caller of do_kexec_file_load() cannot know what exactly
failed inside that function, so it should not check errno directly.
All it needs to know is whether it makes sense to fall back to the
other syscall. Add an error code for that purpose (EFALLBACK), and
let do_kexec_file_load() decide.
Fourth, do_kexec_file_load() should not print any error message if
it returns EFALLBACK, because the fallback syscall may succeed
later, and the user is confused whether the command failed, or not.
Move the error message towards the end of main().
Signed-off-by: Petr Tesarik <ptesarik@suse.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/kexec.h')
-rw-r--r-- | kexec/kexec.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/kexec/kexec.h b/kexec/kexec.h index a97b9ce..28fd129 100644 --- a/kexec/kexec.h +++ b/kexec/kexec.h @@ -63,6 +63,7 @@ */ #define EFAILED -1 /* default error code */ #define ENOCRASHKERNEL -2 /* no memory reserved for crashkernel */ +#define EFALLBACK -3 /* fallback to kexec_load(2) may work */ /* * This function doesn't actually exist. The idea is that when someone |