summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init/main.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/init/main.c b/init/main.c
index 0ead83e86b5a..db0621dfbb04 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1457,15 +1457,19 @@ static int __ref kernel_init(void *unused)
"See Linux Documentation/admin-guide/init.rst for guidance.");
}
+/* Open /dev/console, for stdin/stdout/stderr, this should never fail */
void console_on_rootfs(void)
{
- /* Open the /dev/console as stdin, this should never fail */
- if (ksys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
- pr_err("Warning: unable to open an initial console.\n");
+ struct file *file = filp_open("/dev/console", O_RDWR, 0);
- /* create stdout/stderr */
- (void) ksys_dup(0);
- (void) ksys_dup(0);
+ if (IS_ERR(file)) {
+ pr_err("Warning: unable to open an initial console.\n");
+ return;
+ }
+ get_file_rcu_many(file, 2);
+ fd_install(get_unused_fd_flags(0), file);
+ fd_install(get_unused_fd_flags(0), file);
+ fd_install(get_unused_fd_flags(0), file);
}
static noinline void __init kernel_init_freeable(void)