1 Star 0 Fork 46

Linux_zhang/kexec-tools

forked from src-openEuler/kexec-tools 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
kexec-tools-Reset-getopt-before-falling-back-to-legacy.patch 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
zhangruifang2020 提交于 2020-09-14 13:53 +08:00 . Sychronize git patches to enhance quality
From 9cf721279f6cb0dec09c8752e471f15fb662406b Mon Sep 17 00:00:00 2001
From: Petr Tesarik <ptesarik@suse.com>
Date: Fri, 13 Mar 2020 15:09:29 +0100
Subject: [PATCH] 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>
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 33c1b4b..6601f1f 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,
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Linux_zhang2024/kexec-tools.git
git@gitee.com:Linux_zhang2024/kexec-tools.git
Linux_zhang2024
kexec-tools
kexec-tools
master

搜索帮助