summaryrefslogtreecommitdiffstats
path: root/kexec
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.com>2020-03-13 15:09:29 +0100
committerSimon Horman <horms@verge.net.au>2020-04-01 14:39:27 +0200
commit9cf721279f6cb0dec09c8752e471f15fb662406b (patch)
tree56835b2b4e4098ad0cf222e1fc76660c9a9e8259 /kexec
parent4f77da6340356de40af70473d3c3ae6ec663fbdf (diff)
downloadkexec-tools-9cf721279f6cb0dec09c8752e471f15fb662406b.tar.gz
kexec-tools: Reset getopt before falling back to legacy syscall
The modules may need to parse the arguments again after kexec_file_load(2) failed, but getopt is not reset. This change fixes the --initrd option on s390x. Without this patch, it will fail to load the initrd on kernels that do not implement kexec_file_load(2). Signed-off-by: Petr Tesarik <ptesarik@suse.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec')
-rw-r--r--kexec/kexec.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 33c1b4be..6601f1f6 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -1538,8 +1538,12 @@ int main(int argc, char *argv[])
if (do_unload) {
if (do_kexec_file_syscall) {
result = kexec_file_unload(kexec_file_flags);
- if (result == EFALLBACK && do_kexec_fallback)
+ if (result == EFALLBACK && do_kexec_fallback) {
+ /* Reset getopt for fallback */
+ opterr = 1;
+ optind = 1;
do_kexec_file_syscall = 0;
+ }
}
if (!do_kexec_file_syscall)
result = k_unload(kexec_flags);
@@ -1548,8 +1552,12 @@ int main(int argc, char *argv[])
if (do_kexec_file_syscall) {
result = do_kexec_file_load(fileind, argc, argv,
kexec_file_flags);
- if (result == EFALLBACK && do_kexec_fallback)
+ if (result == EFALLBACK && do_kexec_fallback) {
+ /* Reset getopt for fallback */
+ opterr = 1;
+ optind = 1;
do_kexec_file_syscall = 0;
+ }
}
if (!do_kexec_file_syscall)
result = my_load(type, fileind, argc, argv,