Skip to content

Commit

Permalink
install: Use rustix instead of nix in one place
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cgwalters committed Jul 17, 2024
1 parent 298a336 commit 723ad8c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 723ad8c

Please sign in to comment.