[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210522113155.244796-2-dong.menglong@zte.com.cn>
Date: Sat, 22 May 2021 19:31:53 +0800
From: menglong8.dong@...il.com
To: mcgrof@...nel.org
Cc: viro@...iv.linux.org.uk, keescook@...omium.org,
samitolvanen@...gle.com, johan@...nel.org, ojeda@...nel.org,
jeyu@...nel.org, joe@...ches.com, dong.menglong@....com.cn,
masahiroy@...nel.org, jack@...e.cz, axboe@...nel.dk, hare@...e.de,
gregkh@...uxfoundation.org, tj@...nel.org, song@...nel.org,
neilb@...e.de, akpm@...ux-foundation.org, brho@...gle.com,
f.fainelli@...il.com, wangkefeng.wang@...wei.com, arnd@...db.de,
linux@...musvillemoes.dk, mhiramat@...nel.org, rostedt@...dmis.org,
vbabka@...e.cz, glider@...gle.com, pmladek@...e.com,
ebiederm@...ssion.com, jojing64@...il.com,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] init/main.c: introduce function ramdisk_exec_exist()
From: Menglong Dong <dong.menglong@....com.cn>
Introduce the function ramdisk_exec_exist, which is used to check
the exist of 'ramdisk_execute_command'.
It can do absolute path and relative path check. For relative path,
it will ignore '/' and '.' in the start of
'ramdisk_execute_command'.
Signed-off-by: Menglong Dong <dong.menglong@....com.cn>
---
init/main.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/init/main.c b/init/main.c
index eb01e121d2f1..95cab17046e0 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1522,6 +1522,21 @@ void __init console_on_rootfs(void)
fput(file);
}
+bool __init ramdisk_exec_exist(bool absolute)
+{
+ char *tmp_command = ramdisk_execute_command;
+
+ if (!tmp_command)
+ return false;
+
+ if (!absolute) {
+ while (*tmp_command == '/' || *tmp_command == '.')
+ tmp_command++;
+ }
+
+ return init_eaccess(tmp_command) == 0;
+}
+
static noinline void __init kernel_init_freeable(void)
{
/*
@@ -1568,7 +1583,7 @@ static noinline void __init kernel_init_freeable(void)
* check if there is an early userspace init. If yes, let it do all
* the work
*/
- if (init_eaccess(ramdisk_execute_command) != 0) {
+ if (!ramdisk_exec_exist(true)) {
ramdisk_execute_command = NULL;
prepare_namespace();
}
--
2.31.1
Powered by blists - more mailing lists