From 723ad8c8b7c6a988b250f6b395b67398be289ef5 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 17 Jul 2024 12:55:35 -0400 Subject: [PATCH] install: Use rustix instead of nix in one place Was looking at cleaning up the blockdev stuff a bit more; the unsafe nix ioctl code we have is a bit of a wart. Some searching turns up this use of nix, but rustix exposes what we want here. (rustix and nix heavily overlap, I think rustix is a bit better designed, though nix has been doing some breaking changes to catch up) Signed-off-by: Colin Walters --- lib/src/install.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/install.rs b/lib/src/install.rs index fcb8c3b9..98e7bb14 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -774,7 +774,11 @@ pub(crate) fn exec_in_host_mountns(args: &[std::ffi::OsString]) -> Result<()> { .ok_or_else(|| anyhow::anyhow!("Missing command"))?; tracing::trace!("{cmd:?} {args:?}"); let pid1mountns = std::fs::File::open("/proc/1/ns/mnt").context("open pid1 mountns")?; - nix::sched::setns(pid1mountns.as_fd(), nix::sched::CloneFlags::CLONE_NEWNS).context("setns")?; + rustix::thread::move_into_link_name_space( + pid1mountns.as_fd(), + Some(rustix::thread::LinkNameSpaceType::Mount), + ) + .context("setns")?; rustix::process::chdir("/").context("chdir")?; // Work around supermin doing chroot() and not pivot_root // https://github.com/libguestfs/supermin/blob/5230e2c3cd07e82bd6431e871e239f7056bf25ad/init/init.c#L288