kumquat-buildroot/fs
Peter Korsgaard b9026e83f9 fs/cpio/init: unbreak ttyname_r() on glibc after dropping /dev/console exec
Commit 98a6f1fc02 (fs/cpio: make initramfs init script survive 'console='
kernel argument) dropped the explicit /dev/console execs for fd 0,1,2, as
they fail when booted with console= and aren't really needed as the kernel
will setup fd 0,1,2 from /dev/console before executing the initramfs anyway.

Not doing this unfortunately confuses glibc's ttyname_r(3) implementation
(used by E.G.  busybox/coreutils 'tty'), causing it to fail with ENOENT as
it does a fstat on fd 0 and tries to match up st_ino / st_dev against the
entries in /dev (since glibc 2.26):

 commit 15e9a4f378c8607c2ae1aa465436af4321db0e23
 Author: Christian Brauner <christian.brauner@canonical.com>
 Date:   Fri Jan 27 15:59:59 2017 +0100

    linux ttyname and ttyname_r: do not return wrong results

    If a link (say /proc/self/fd/0) pointing to a device, say /dev/pts/2, in a
    parent mount namespace is passed to ttyname, and a /dev/pts/2 exists (in a
    different devpts) in the current namespace, then it returns /dev/pts/2.
    But /dev/pts/2 is NOT the current tty, it is a different file and device.

    Detect this case and return ENODEV.  Userspace can choose to take this as a hint
    that the fd points to a tty device but to act on the fd rather than the link.

    Signed-off-by: Serge Hallyn <serge@hallyn.com>
    Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

The reason it fails is that we manually mount devtmpfs on /dev in /init, so
the /dev/console used by the kernel (in rootfs) is not the same file as
/dev/console at runtime (in devtmpfs).

Notice: Once logged in, tty does work correctly.  Presumably login reopens
stdin/stdout/stderr.

To fix this, re-add the exec of /dev/console for fd 0,1,2, but only do so if
possible.  Because of the above mentioned shell behaviour (specified by
POSIX [0]), perform this check in a subshell.

[0] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_20_01

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2020-08-29 16:32:33 +02:00
..
axfs
btrfs fs: don't use := when not needed 2019-10-27 10:35:06 +01:00
cloop
cpio fs/cpio/init: unbreak ttyname_r() on glibc after dropping /dev/console exec 2020-08-29 16:32:33 +02:00
cramfs
erofs fs/erofs: add support for creating EROFS rootfs image 2020-03-19 18:43:15 +01:00
ext2 fs/ext2: pass a default string to filesystem label 2020-04-15 22:49:26 +02:00
f2fs fs: don't use := when not needed 2019-10-27 10:35:06 +01:00
initramfs fs/initramfs: fix show-info 2020-03-18 22:44:19 +01:00
iso9660
jffs2 fs: don't use := when not needed 2019-10-27 10:35:06 +01:00
romfs
squashfs fs: squashfs: Add config option to pass nopad parameter to mksquashfs 2020-06-17 23:01:23 +02:00
tar fs: don't use := when not needed 2019-10-27 10:35:06 +01:00
ubi fs/ubi: expose BINARIES_DIR to ubinize.cfg 2020-06-06 13:43:43 +02:00
ubifs
yaffs2
common.mk fs/common.mk: enable multithreaded xz compression 2019-08-03 19:29:47 +02:00
Config.in fs/erofs: add support for creating EROFS rootfs image 2020-03-19 18:43:15 +01:00