Re: [PATCH 4/5] init: unify opening /dev/console as stdin/stdout/stderr
From: youling 257
Date: Thu Dec 19 2019 - 04:34:40 EST
Test this patch not work, still has system/bin/sh warning.
ls -al /proc/1/fd
total 0
dr-x------ 2 root root 0 2019-12-19 17:19 [1;34m. [0m
dr-xr-xr-x 9 root root 0 2019-12-19 17:19 [1;34m.. [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m0 [0m ->
[1;31m/android/sys/fs/selinux/null [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m1 [0m ->
[1;31m/android/sys/fs/selinux/null [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m10 [0m ->
[1;31msocket:[12337] [0m
l-wx------ 1 root root 64 2019-12-19 17:19 [1;36m11 [0m ->
[1;31m/android/dev/pmsg0 [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m2 [0m ->
[1;31m/android/sys/fs/selinux/null [0m
l-wx------ 1 root root 64 2019-12-19 17:19 [1;36m3 [0m ->
[1;31m/android/dev/__kmsg__ (deleted) [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m4 [0m ->
[1;31manon_inode:[eventpoll] [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m5 [0m ->
[1;31msocket:[857] [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m6 [0m ->
[1;31msocket:[858] [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m7 [0m ->
[1;31msocket:[859] [0m
lrwx------ 1 root root 64 2019-12-19 17:19 [1;36m9 [0m ->
[1;31msocket:[10698] [0m
Revert "fs: remove ksys_dup()", no the system/bin/sh warning.
ls -al /proc/1/fd
total 0
dr-x------ 2 root root 0 2019-12-19 17:28 [1;34m. [0m
dr-xr-xr-x 9 root root 0 2019-12-19 17:28 [1;34m.. [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m0 [0m ->
[1;31m/android/sys/fs/selinux/null [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m1 [0m ->
[1;31m/android/sys/fs/selinux/null [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m10 [0m ->
[1;31msocket:[12506] [0m
l-wx------ 1 root root 64 2019-12-19 17:28 [1;36m11 [0m ->
[1;31m/android/dev/pmsg0 [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m2 [0m ->
[1;31m/android/sys/fs/selinux/null [0m
l-wx------ 1 root root 64 2019-12-19 17:28 [1;36m3 [0m ->
[1;31m/android/dev/__kmsg__ (deleted) [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m4 [0m ->
[1;31manon_inode:[eventpoll] [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m5 [0m ->
[1;31msocket:[1957] [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m6 [0m ->
[1;31msocket:[1958] [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m7 [0m ->
[1;31msocket:[1959] [0m
lrwx------ 1 root root 64 2019-12-19 17:28 [1;36m9 [0m ->
[1;31msocket:[2040] [0m
2019-12-19 15:08 GMT+08:00, Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>:
> On Thu, Dec 19, 2019 at 05:50:19AM +0800, youling 257 wrote:
>> 2019-12-18 5:14 GMT+08:00, Linus Torvalds
>> <torvalds@xxxxxxxxxxxxxxxxxxxx>:
>> > This should be fixed by 2d3145f8d280 ("early init: fix error handling
>> > when opening /dev/console")
>>
>> this fix no help for me.
>>
>> > I'm not sure what you did to trigger that bug, but it was a bug.
>>
>> alt+f1, type bash command,
>> bash: cannot set terminal process group (-1): Inappropriate ioctl for
>> device
>> bash: no job control in this shell
>
> Could you test this patch, please? And if it does not work: What is the
> content of /proc/1/fd/ and /proc/1/fdinfo/* for the working and non-working
> case? That are the only changes visible to userspace...
>
> Thanks,
> Dominik
>
> diff --git a/init/main.c b/init/main.c
> index 1ecfd43ed464..8886530e9dec 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -1162,7 +1162,7 @@ void console_on_rootfs(void)
> unsigned int i;
>
> /* Open /dev/console in kernelspace, this should never fail */
> - file = filp_open("/dev/console", O_RDWR, 0);
> + file = filp_open("/dev/console", force_o_largefile() ? O_LARGEFILE |
> O_RDWR : O_RDWR, 0);
> if (IS_ERR(file))
> goto err_out;
>
>