Skip to content

Commit

Permalink
Merge pull request #4610 from cgwalters/drop-nix
Browse files Browse the repository at this point in the history
Port a few things from nix to rustix
  • Loading branch information
jmarrero authored Sep 19, 2023
2 parents 15ad997 + 16a9481 commit 76db091
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions rust/src/bwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ impl Bubblewrap {
let lang_var = Path::new(&lang_var);

let launcher = gio::SubprocessLauncher::new(gio::SubprocessFlags::NONE);
let child_rootfs_fd = rootfs_fd.as_raw_fd();
let child_rootfs_fd = std::sync::Arc::new(rootfs_fd.try_clone()?);
launcher.set_child_setup(move || {
nix::unistd::fchdir(child_rootfs_fd).expect("fchdir");
rustix::process::fchdir(&*child_rootfs_fd).expect("fchdir");
});

let path_var = Path::new(PATH_VAR);
Expand Down
8 changes: 4 additions & 4 deletions rust/src/cliwrap/cliutil.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use anyhow::Result;
use nix::sys::statvfs;
use std::os::unix::process::CommandExt;
use std::{thread, time};

use crate::cliwrap;

/// Returns true if /usr is not a read-only bind mount
pub fn is_unlocked() -> Result<bool> {
Ok(!statvfs::statvfs("/usr")?
.flags()
.contains(statvfs::FsFlags::ST_RDONLY))
use rustix::fs::StatVfsMountFlags;
Ok(!rustix::fs::statvfs("/usr")?
.f_flag
.contains(StatVfsMountFlags::RDONLY))
}

/// Returns true if the current process is running as root.
Expand Down
4 changes: 2 additions & 2 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use anyhow::{Context, Result};
use is_terminal::IsTerminal;
use nix::sys::signal;
use rpmostree_rust::builtins;
use std::ffi::OsString;
use std::io::Write;
Expand Down Expand Up @@ -113,7 +112,8 @@ fn inner_main() -> Result<i32> {
if std::env::var("RPMOSTREE_GDB_HOOK").is_ok() {
println!("RPMOSTREE_GDB_HOOK detected; stopping...");
println!("Attach via gdb using `gdb -p {}`.", std::process::id());
signal::raise(signal::Signal::SIGSTOP).expect("signal(SIGSTOP)");
rustix::process::kill_current_process_group(rustix::process::Signal::Stop)
.expect("signal(SIGSTOP)");
}
// Initialize failpoints
let _scenario = fail::FailScenario::setup();
Expand Down

0 comments on commit 76db091

Please sign in to comment.