Skip to content

Commit

Permalink
Merge pull request #980 from jeckersb/sysroot_dir
Browse files Browse the repository at this point in the history
utils: Add sysroot_dir helper
  • Loading branch information
cgwalters authored Dec 18, 2024
2 parents 3370758 + 29c5366 commit f443cd4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result
.init_osname(stateroot, cancellable)
.context("initializing stateroot")?;

let sysroot_dir = Dir::reopen_dir(&crate::utils::sysroot_fd(&sysroot))?;
let sysroot_dir = crate::utils::sysroot_dir(&sysroot)?;

state.tempdir.create_dir("temp-run")?;
let temp_run = state.tempdir.open_dir("temp-run")?;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/install/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ pub(crate) async fn impl_completion(
let deployment = &sysroot
.merge_deployment(stateroot)
.ok_or_else(|| anyhow::anyhow!("Failed to find deployment (stateroot={stateroot:?}"))?;
let sysroot_dir = Dir::reopen_dir(&crate::utils::sysroot_fd(&sysroot))?;
let sysroot_dir = crate::utils::sysroot_dir(&sysroot)?;

// Create a subdir in /run
let rundir = "run/bootc-install";
Expand Down
2 changes: 1 addition & 1 deletion lib/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Storage {
if let Some(imgstore) = self.imgstore.get() {
return Ok(imgstore);
}
let sysroot_dir = Dir::reopen_dir(&crate::utils::sysroot_fd(&self.sysroot))?;
let sysroot_dir = crate::utils::sysroot_dir(&self.sysroot)?;
let imgstore = crate::imgstorage::Storage::create(&sysroot_dir, &self.run)?;
Ok(self.imgstore.get_or_init(|| imgstore))
}
Expand Down
5 changes: 5 additions & 0 deletions lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ pub(crate) fn sysroot_fd(sysroot: &ostree::Sysroot) -> BorrowedFd {
unsafe { BorrowedFd::borrow_raw(sysroot.fd()) }
}

// Return a cap-std `Dir` type for a sysroot
pub(crate) fn sysroot_dir(sysroot: &ostree::Sysroot) -> Result<Dir> {
Dir::reopen_dir(&sysroot_fd(sysroot)).map_err(Into::into)
}

// Return a cap-std `Dir` type for a deployment.
// TODO: in the future this should perhaps actually mount via composefs
pub(crate) fn deployment_fd(
Expand Down

0 comments on commit f443cd4

Please sign in to comment.