patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [PATCH] host/rootfs: add /dev/fd and /dev/std*
@ 2025-08-07 16:54 Demi Marie Obenour
  2025-08-08 18:03 ` Alyssa Ross
  0 siblings, 1 reply; 4+ messages in thread
From: Demi Marie Obenour @ 2025-08-07 16:54 UTC (permalink / raw)
  To: Spectrum OS Development; +Cc: Alyssa Ross, Demi Marie Obenour

This is the same as 14483e1a690c (img/app: add /dev/fd and /dev/std*),
but for the host.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
 host/rootfs/etc/s6-linux-init/scripts/rc.init | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/host/rootfs/etc/s6-linux-init/scripts/rc.init b/host/rootfs/etc/s6-linux-init/scripts/rc.init
index 674fd38cc76837c7be25a5ef060f0f4d4b786394..ec654dd0ff329e01a25c03bdd80ee839e679e4d0 100755
--- a/host/rootfs/etc/s6-linux-init/scripts/rc.init
+++ b/host/rootfs/etc/s6-linux-init/scripts/rc.init
@@ -2,6 +2,11 @@
 # SPDX-License-Identifier: EUPL-1.2+
 # SPDX-FileCopyrightText: 2020-2022, 2024 Alyssa Ross <hi@alyssa.is>
 
+if { ln -s /proc/self/fd /dev }
+if { ln -s /proc/self/fd/0 /dev/stdin }
+if { ln -s /proc/self/fd/1 /dev/stdout }
+if { ln -s /proc/self/fd/2 /dev/stderr }
+
 if { s6-rc-init -c /etc/s6-rc /run/service }
 
 if { mount --make-shared /run }

---
base-commit: 39baa378367d95fac6ce4d0140b25203b2ee9b53
change-id: 20250805-host-dev-fd-51d57d8341bb
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] host/rootfs: add /dev/fd and /dev/std*
  2025-08-07 16:54 [PATCH] host/rootfs: add /dev/fd and /dev/std* Demi Marie Obenour
@ 2025-08-08 18:03 ` Alyssa Ross
  2025-08-08 18:06   ` Demi Marie Obenour
  0 siblings, 1 reply; 4+ messages in thread
From: Alyssa Ross @ 2025-08-08 18:03 UTC (permalink / raw)
  To: Demi Marie Obenour, Spectrum OS Development

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

Demi Marie Obenour <demiobenour@gmail.com> writes:

> This is the same as 14483e1a690c (img/app: add /dev/fd and /dev/std*),
> but for the host.
>
> Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
> ---
>  host/rootfs/etc/s6-linux-init/scripts/rc.init | 5 +++++
>  1 file changed, 5 insertions(+)

Hmm.  I did it only for img/app on purpose, because that's the only
place we run arbitrary executables.  In host/rootfs (and vm/sys/net),
we only run a limited set of code that we control.  WDYT?

> diff --git a/host/rootfs/etc/s6-linux-init/scripts/rc.init b/host/rootfs/etc/s6-linux-init/scripts/rc.init
> index 674fd38cc76837c7be25a5ef060f0f4d4b786394..ec654dd0ff329e01a25c03bdd80ee839e679e4d0 100755
> --- a/host/rootfs/etc/s6-linux-init/scripts/rc.init
> +++ b/host/rootfs/etc/s6-linux-init/scripts/rc.init
> @@ -2,6 +2,11 @@
>  # SPDX-License-Identifier: EUPL-1.2+
>  # SPDX-FileCopyrightText: 2020-2022, 2024 Alyssa Ross <hi@alyssa.is>
>  
> +if { ln -s /proc/self/fd /dev }
> +if { ln -s /proc/self/fd/0 /dev/stdin }
> +if { ln -s /proc/self/fd/1 /dev/stdout }
> +if { ln -s /proc/self/fd/2 /dev/stderr }
> +
>  if { s6-rc-init -c /etc/s6-rc /run/service }
>  
>  if { mount --make-shared /run }
>
> ---
> base-commit: 39baa378367d95fac6ce4d0140b25203b2ee9b53
> change-id: 20250805-host-dev-fd-51d57d8341bb
> -- 
> Sincerely,
> Demi Marie Obenour (she/her/hers)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] host/rootfs: add /dev/fd and /dev/std*
  2025-08-08 18:03 ` Alyssa Ross
@ 2025-08-08 18:06   ` Demi Marie Obenour
  2025-08-31 11:06     ` Alyssa Ross
  0 siblings, 1 reply; 4+ messages in thread
From: Demi Marie Obenour @ 2025-08-08 18:06 UTC (permalink / raw)
  To: Alyssa Ross, Spectrum OS Development


[-- Attachment #1.1.1: Type: text/plain, Size: 895 bytes --]

On 8/8/25 14:03, Alyssa Ross wrote:
> Demi Marie Obenour <demiobenour@gmail.com> writes:
> 
>> This is the same as 14483e1a690c (img/app: add /dev/fd and /dev/std*),
>> but for the host.
>>
>> Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
>> ---
>>  host/rootfs/etc/s6-linux-init/scripts/rc.init | 5 +++++
>>  1 file changed, 5 insertions(+)
> 
> Hmm.  I did it only for img/app on purpose, because that's the only
> place we run arbitrary executables.  In host/rootfs (and vm/sys/net),
> we only run a limited set of code that we control.  WDYT?

We control the code to some degree, but third-party dependencies might
depend on these files existing, and failures due to these being
missing could be extremely difficult to debug.  In particular,
portable code might use /dev/fd intentionally, as the BSDs have it.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] host/rootfs: add /dev/fd and /dev/std*
  2025-08-08 18:06   ` Demi Marie Obenour
@ 2025-08-31 11:06     ` Alyssa Ross
  0 siblings, 0 replies; 4+ messages in thread
From: Alyssa Ross @ 2025-08-31 11:06 UTC (permalink / raw)
  To: Demi Marie Obenour, Spectrum OS Development

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

Demi Marie Obenour <demiobenour@gmail.com> writes:

> On 8/8/25 14:03, Alyssa Ross wrote:
>> Demi Marie Obenour <demiobenour@gmail.com> writes:
>> 
>>> This is the same as 14483e1a690c (img/app: add /dev/fd and /dev/std*),
>>> but for the host.
>>>
>>> Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
>>> ---
>>>  host/rootfs/etc/s6-linux-init/scripts/rc.init | 5 +++++
>>>  1 file changed, 5 insertions(+)
>> 
>> Hmm.  I did it only for img/app on purpose, because that's the only
>> place we run arbitrary executables.  In host/rootfs (and vm/sys/net),
>> we only run a limited set of code that we control.  WDYT?
>
> We control the code to some degree, but third-party dependencies might
> depend on these files existing, and failures due to these being
> missing could be extremely difficult to debug.  In particular,
> portable code might use /dev/fd intentionally, as the BSDs have it.

Makes sense.  In that case we should also do it in vm/sys/net as well.
Do you think we even need to do it in host/initramfs?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-31 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 16:54 [PATCH] host/rootfs: add /dev/fd and /dev/std* Demi Marie Obenour
2025-08-08 18:03 ` Alyssa Ross
2025-08-08 18:06   ` Demi Marie Obenour
2025-08-31 11:06     ` Alyssa Ross

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).