Skip to content

Commit f443cd4

Browse files
authored
Merge pull request #980 from jeckersb/sysroot_dir
utils: Add sysroot_dir helper
2 parents 3370758 + 29c5366 commit f443cd4

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

lib/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result
662662
.init_osname(stateroot, cancellable)
663663
.context("initializing stateroot")?;
664664

665-
let sysroot_dir = Dir::reopen_dir(&crate::utils::sysroot_fd(&sysroot))?;
665+
let sysroot_dir = crate::utils::sysroot_dir(&sysroot)?;
666666

667667
state.tempdir.create_dir("temp-run")?;
668668
let temp_run = state.tempdir.open_dir("temp-run")?;

lib/src/install/completion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub(crate) async fn impl_completion(
276276
let deployment = &sysroot
277277
.merge_deployment(stateroot)
278278
.ok_or_else(|| anyhow::anyhow!("Failed to find deployment (stateroot={stateroot:?}"))?;
279-
let sysroot_dir = Dir::reopen_dir(&crate::utils::sysroot_fd(&sysroot))?;
279+
let sysroot_dir = crate::utils::sysroot_dir(&sysroot)?;
280280

281281
// Create a subdir in /run
282282
let rundir = "run/bootc-install";

lib/src/store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Storage {
7878
if let Some(imgstore) = self.imgstore.get() {
7979
return Ok(imgstore);
8080
}
81-
let sysroot_dir = Dir::reopen_dir(&crate::utils::sysroot_fd(&self.sysroot))?;
81+
let sysroot_dir = crate::utils::sysroot_dir(&self.sysroot)?;
8282
let imgstore = crate::imgstorage::Storage::create(&sysroot_dir, &self.run)?;
8383
Ok(self.imgstore.get_or_init(|| imgstore))
8484
}

lib/src/utils.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ pub(crate) fn sysroot_fd(sysroot: &ostree::Sysroot) -> BorrowedFd {
4040
unsafe { BorrowedFd::borrow_raw(sysroot.fd()) }
4141
}
4242

43+
// Return a cap-std `Dir` type for a sysroot
44+
pub(crate) fn sysroot_dir(sysroot: &ostree::Sysroot) -> Result<Dir> {
45+
Dir::reopen_dir(&sysroot_fd(sysroot)).map_err(Into::into)
46+
}
47+
4348
// Return a cap-std `Dir` type for a deployment.
4449
// TODO: in the future this should perhaps actually mount via composefs
4550
pub(crate) fn deployment_fd(

0 commit comments

Comments
 (0)