lkml.org 
[lkml]   [2021]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 3/3] init/do_mounts.c: fix rootfs_fs_type with ramfs
Date
From: Menglong Dong <dong.menglong@zte.com.cn>

As for the existence of 'user root' which is introduced in previous
patch, 'rootfs_fs_type', which is used as the root of mount tree,
is not used directly any more. So it make no sense to make it tmpfs
while 'INITRAMFS_USER_ROOT' is enabled.

Make 'rootfs_fs_type' ramfs when 'INITRAMFS_USER_ROOT' enabled.

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
---
include/linux/init.h | 5 +++++
init/do_mounts.c | 10 +++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 045ad1650ed1..d65b12fe438c 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -148,7 +148,12 @@ extern unsigned int reset_devices;
/* used by init/main.c */
void setup_arch(char **);
void prepare_namespace(void);
+#ifndef CONFIG_INITRAMFS_USER_ROOT
void __init init_rootfs(void);
+#else
+static inline void __init init_rootfs(void) { }
+#endif
+
extern struct file_system_type rootfs_fs_type;

#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX)
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 2fd168cca480..74f5b0fc8bdf 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -716,7 +716,14 @@ void __init init_user_rootfs(void)
}
}
}
-#endif
+
+struct file_system_type rootfs_fs_type = {
+ .name = "rootfs",
+ .init_fs_context = ramfs_init_fs_context,
+ .kill_sb = kill_litter_super,
+};
+
+#else

static bool is_tmpfs;
static int rootfs_init_fs_context(struct fs_context *fc)
@@ -739,3 +746,4 @@ void __init init_rootfs(void)
(!root_fs_names || strstr(root_fs_names, "tmpfs")))
is_tmpfs = true;
}
+#endif
--
2.32.0.rc0

\
 
 \ /
  Last update: 2021-05-25 16:16    [W:1.127 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site