Skip to contentSkip to conversation

Add /dev/std{in, out, err} symlinks to inittabs

PATCH New Jörg Krause 2 participants 7 messages Apr 4, 2018 – Jun 17, 2018

lore
Share & tools
lore
#0 lore raw

cover Add /dev/std{in, out, err} symlinks to inittabs

Some applications, e.g. bashs process subsitution feature, rely on the convention of /dev/fd being a symbolic link to /proc/self/fd.

This symbolic link and his companions /dev/std* are created by (e)udev [1], but not by mdev, resulting in the following error when using the following expression:

```
bash: /dev/fd/62: No such file or directory
```

For the sake of simplicity, lets fix this by creating the symlinks in busybox' and sysvinits inittab file. It is only really needed if eudev isn't used, but it doesn't really hurt to create them even if eudev will recreate them afterwards.

Note, that we do not create the symlink /dev/core as /proc/kcore is not available on all platforms, e.g. ARM, and the feature is not much appreciated [2].

[1] https://github.com/gentoo/eudev/blob/8943501993322c59a6eb5be456b0d716aafff21e/src/shared/dev-setup.c#L35-L40
[2] https://lwn.net/Articles/45315/

J?rg Krause (2):
busybox: add /dev/std{in,out,err} symlinks to inittab
sysvinit: add /dev/std{in,out,err} symlinks to inittab

 package/busybox/inittab  | 4 ++++
 package/sysvinit/inittab | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
2.16.3
#1 lore raw

PATCH 1/2 busybox: add /dev/std{in, out, err} symlinks to inittab

Some applications, e.g. bashs process subsitution feature, rely on the convention of /dev/fd being a symbolic link to /proc/self/fd.

This symbolic link and his companions /dev/std* are created by (e)udev [1], but not by mdev, resulting in the following error when using the following expression:

```
bash: /dev/fd/62: No such file or directory
```

For the sake of simplicity, lets fix this by creating the symlinks in inittab. It is only really needed if eudev isn't used, but it doesn't really hurt to create them even if eudev will recreate them afterwards.

Note, that we do not create the symlink /dev/core as /proc/kcore is not available on all platforms, e.g. ARM, and the feature is not much appreciated [2].

[1] https://github.com/gentoo/eudev/blob/8943501993322c59a6eb5be456b0d716aafff21e/src/shared/dev-setup.c#L35-L40
[2] https://lwn.net/Articles/45315/

---
 package/busybox/inittab | 4 ++++
 1 file changed, 4 insertions(+)
package/busybox/inittab +4 -0
index 3f49f6bd7a..0f6b8cbe37 100644
@@ -19,6 +19,10 @@
 ::sysinit:/bin/mkdir -p /dev/pts
 ::sysinit:/bin/mkdir -p /dev/shm
 ::sysinit:/bin/mount -a
+::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
+::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
+::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
+::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
 ::sysinit:/bin/hostname -F /etc/hostname
 # now run any rc scripts
 ::sysinit:/etc/init.d/rcS
Signature · 1 line
2.16.3
#2 lore raw

PATCH 1/2 busybox: add /dev/std{in, out, err} symlinks to inittab

Quoted 35 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"J?rg" == J?rg Krause <[email protected]> writes:

Some applications, e.g. bashs process subsitution feature, rely on the convention of /dev/fd being a symbolic link to /proc/self/fd.

This symbolic link and his companions /dev/std* are created by (e)udev [1], but not by mdev, resulting in the following error when using the following expression:

```
bash: /dev/fd/62: No such file or directory
```

For the sake of simplicity, lets fix this by creating the symlinks in inittab. It is only really needed if eudev isn't used, but it doesn't really hurt to create them even if eudev will recreate them afterwards.

Note, that we do not create the symlink /dev/core as /proc/kcore is not available on all platforms, e.g. ARM, and the feature is not much appreciated [2].

[1]
https://github.com/gentoo/eudev/blob/8943501993322c59a6eb5be456b0d716aafff21e/src/shared/dev-setup.c#L35-L40
[2] https://lwn.net/Articles/45315/

---
 package/busybox/inittab | 4 ++++
 1 file changed, 4 insertions(+)
package/busybox/inittab +0 -0
index 3f49f6bd7a..0f6b8cbe37 100644

package/busybox/inittab line 25

Quoted 7 lines
package/busybox/inittab +4 -0
@@ -19,6 +19,10 @@
 ::sysinit:/bin/mkdir -p /dev/pts
 ::sysinit:/bin/mkdir -p /dev/shm
 ::sysinit:/bin/mount -a
+::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
+::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
+::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
+::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr

This will fail on static /dev on a readonly rootfs, so I've redirected errors to /dev/null.

Committed with that changed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 1/2 busybox: add /dev/std{in, out, err} symlinks to inittab

Quoted 47 lines
Quoted 36 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

"Peter" == Peter Korsgaard <[email protected]> writes:

"J?rg" == J?rg Krause <[email protected]> writes:

Some applications, e.g. bashs process subsitution feature, rely on the convention of /dev/fd being a symbolic link to /proc/self/fd.

This symbolic link and his companions /dev/std* are created by (e)udev [1], but not by mdev, resulting in the following error when using the following expression:

```
bash: /dev/fd/62: No such file or directory
```

For the sake of simplicity, lets fix this by creating the symlinks in inittab. It is only really needed if eudev isn't used, but it doesn't really hurt to create them even if eudev will recreate them afterwards.

Note, that we do not create the symlink /dev/core as /proc/kcore is not available on all platforms, e.g. ARM, and the feature is not much appreciated [2].

[1]
https://github.com/gentoo/eudev/blob/8943501993322c59a6eb5be456b0d716aafff21e/src/shared/dev-setup.c#L35-L40
[2] https://lwn.net/Articles/45315/

---
package/busybox/inittab | 4 ++++

1 file changed, 4 insertions(+)
package/busybox/inittab +0 -0
index 3f49f6bd7a..0f6b8cbe37 100644
@@ -19,6 +19,10 @@
Quoted 7 lines

::sysinit:/bin/mkdir -p /dev/pts ::sysinit:/bin/mkdir -p /dev/shm ::sysinit:/bin/mount -a
+::sysinit:/bin/ln -sf /proc/self/fd /dev/fd +::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin +::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout +::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr

This will fail on static /dev on a readonly rootfs, so I've redirected errors to /dev/null.

Quoted 1 line

Committed with that changed, thanks.

Committed to 2018.02.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH 2/2 sysvinit: add /dev/std{in, out, err} symlinks to inittab

In reply to Jörg Krause

Some applications, e.g. bashs process subsitution feature, rely on the convention of /dev/fd being a symbolic link to /proc/self/fd.

This symbolic link and his companions /dev/std* are created by (e)udev [1], but not by mdev, resulting in the following error when using the following expression:

```
bash: /dev/fd/62: No such file or directory
```

For the sake of simplicity, lets fix this by creating the symlinks in inittab. It is only really needed if eudev isn't used, but it doesn't really hurt to create them even if eudev will recreate them afterwards.

Note, that we do not create the symlink /dev/core as /proc/kcore is not available on all platforms, e.g. ARM, and the feature is not much appreciated [2].

[1] https://github.com/gentoo/eudev/blob/8943501993322c59a6eb5be456b0d716aafff21e/src/shared/dev-setup.c#L35-L40
[2] https://lwn.net/Articles/45315/

---
 package/sysvinit/inittab | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
package/sysvinit/inittab +5 -1
index fad91eae8b..608aabce07 100644
@@ -9,7 +9,11 @@ si1::sysinit:/bin/mount -o remount,rw /
 si2::sysinit:/bin/mkdir -p /dev/pts
 si3::sysinit:/bin/mkdir -p /dev/shm
 si4::sysinit:/bin/mount -a
-si5::sysinit:/bin/hostname -F /etc/hostname
+si5::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
+si6::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
+si7::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
+si8::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
+si9::sysinit:/bin/hostname -F /etc/hostname
 rcS:12345:wait:/etc/init.d/rcS
 
 # S0:1:respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL
Signature · 1 line
2.16.3
#5 lore raw

PATCH 2/2 sysvinit: add /dev/std{in, out, err} symlinks to inittab

Quoted 35 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"J?rg" == J?rg Krause <[email protected]> writes:

Some applications, e.g. bashs process subsitution feature, rely on the convention of /dev/fd being a symbolic link to /proc/self/fd.

This symbolic link and his companions /dev/std* are created by (e)udev [1], but not by mdev, resulting in the following error when using the following expression:

```
bash: /dev/fd/62: No such file or directory
```

For the sake of simplicity, lets fix this by creating the symlinks in inittab. It is only really needed if eudev isn't used, but it doesn't really hurt to create them even if eudev will recreate them afterwards.

Note, that we do not create the symlink /dev/core as /proc/kcore is not available on all platforms, e.g. ARM, and the feature is not much appreciated [2].

[1]
https://github.com/gentoo/eudev/blob/8943501993322c59a6eb5be456b0d716aafff21e/src/shared/dev-setup.c#L35-L40
[2] https://lwn.net/Articles/45315/

---
 package/sysvinit/inittab | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
package/sysvinit/inittab +0 -0
index fad91eae8b..608aabce07 100644

package/sysvinit/inittab si1::sysinit:/bin/mount -o remount,rw / · line 15

Quoted 8 lines
package/sysvinit/inittab +4 -1
@@ -9,7 +9,11 @@ si1::sysinit:/bin/mount -o remount,rw /
 si2::sysinit:/bin/mkdir -p /dev/pts
 si3::sysinit:/bin/mkdir -p /dev/shm
 si4::sysinit:/bin/mount -a
-si5::sysinit:/bin/hostname -F /etc/hostname
+si5::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
+si6::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
+si7::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
+si8::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr

This will fail on static /dev on a readonly rootfs, so I've redirected errors to /dev/null.

Committed with that changed, thanks.

I have also added a patch adding these symlinks in the default skeleton to handle static /dev on readonly rootfs setups.

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw

PATCH 2/2 sysvinit: add /dev/std{in, out, err} symlinks to inittab

Quoted 48 lines
Quoted 39 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

"Peter" == Peter Korsgaard <[email protected]> writes:

"J?rg" == J?rg Krause <[email protected]> writes:

Some applications, e.g. bashs process subsitution feature, rely on the convention of /dev/fd being a symbolic link to /proc/self/fd.

This symbolic link and his companions /dev/std* are created by (e)udev [1], but not by mdev, resulting in the following error when using the following expression:

```
bash: /dev/fd/62: No such file or directory
```

For the sake of simplicity, lets fix this by creating the symlinks in inittab. It is only really needed if eudev isn't used, but it doesn't really hurt to create them even if eudev will recreate them afterwards.

Note, that we do not create the symlink /dev/core as /proc/kcore is not available on all platforms, e.g. ARM, and the feature is not much appreciated [2].

[1]
https://github.com/gentoo/eudev/blob/8943501993322c59a6eb5be456b0d716aafff21e/src/shared/dev-setup.c#L35-L40
[2] https://lwn.net/Articles/45315/

---
package/sysvinit/inittab | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
package/sysvinit/inittab +0 -0
index fad91eae8b..608aabce07 100644
@@ -9,7 +9,11 @@ si1::sysinit:/bin/mount -o remount,rw /

si2::sysinit:/bin/mkdir -p /dev/pts
si3::sysinit:/bin/mkdir -p /dev/shm
si4::sysinit:/bin/mount -a

package/sysvinit/inittab si1::sysinit:/bin/mount -o remount,rw / · line 15

Quoted 5 lines
package/sysvinit/inittab +4 -1
-si5::sysinit:/bin/hostname -F /etc/hostname
+si5::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
+si6::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
+si7::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
+si8::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr

This will fail on static /dev on a readonly rootfs, so I've redirected errors to /dev/null.

Quoted 4 lines

Committed with that changed, thanks.

I have also added a patch adding these symlinks in the default skeleton to handle static /dev on readonly rootfs setups.

Committed to 2018.02.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard