Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port a few things from nix to rustix #4610

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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