Thread (7 messages) 7 messages, 3 authors, 2021-05-28
STALE1877d
Revisions (6)
  1. v1 [diff vs current]
  2. v2 current
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v5 [diff vs current]
  6. v6 [diff vs current]

[PATCH v2 1/3] init/main.c: introduce function ramdisk_exec_exist()

From: <hidden>
Date: 2021-05-25 14:15:52
Also in: lkml
Subsystem: filesystems (vfs and infrastructure), the rest · Maintainers: Alexander Viro, Christian Brauner, Linus Torvalds

From: Menglong Dong <redacted>

Introduce the function ramdisk_exec_exist, which is used to check
the exist of 'ramdisk_execute_command'.

Add the flag 'LOOKUP_DOWN' to 'init_eaccess' to make it follow the
mount on '/' while path lookup.

Signed-off-by: Menglong Dong <redacted>
---
 fs/init.c   | 2 +-
 init/main.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/init.c b/fs/init.c
index 5c36adaa9b44..a1839fdcf467 100644
--- a/fs/init.c
+++ b/fs/init.c
@@ -115,7 +115,7 @@ int __init init_eaccess(const char *filename)
 	struct path path;
 	int error;
 
-	error = kern_path(filename, LOOKUP_FOLLOW, &path);
+	error = kern_path(filename, LOOKUP_FOLLOW | LOOKUP_DOWN, &path);
 	if (error)
 		return error;
 	error = path_permission(&path, MAY_ACCESS);
diff --git a/init/main.c b/init/main.c
index eb01e121d2f1..1153571ca977 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1522,6 +1522,11 @@ void __init console_on_rootfs(void)
 	fput(file);
 }
 
+bool __init ramdisk_exec_exist(void)
+{
+	return init_eaccess(ramdisk_execute_command) == 0;
+}
+
 static noinline void __init kernel_init_freeable(void)
 {
 	/*
@@ -1568,7 +1573,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()) {
 		ramdisk_execute_command = NULL;
 		prepare_namespace();
 	}
-- 
2.32.0.rc0

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help