init: add an init_dup helper

Add a simple helper to grab a reference to a file and install it at
the next available fd, and switch the early init code over to it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Christoph Hellwig
2020-07-28 17:49:47 +02:00
committed by Al Viro
parent 235e57935b
commit f073531070
3 changed files with 17 additions and 4 deletions

View File

@@ -1467,10 +1467,10 @@ void __init console_on_rootfs(void)
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);
init_dup(file);
init_dup(file);
init_dup(file);
fput(file);
}
static noinline void __init kernel_init_freeable(void)