Skip to content

Commit 608d681

Browse files
committed
store: add BOOTC_ROOT
Also refactor imgstore to base its subpath to be relative to BOOTC_ROOT. This is prep for store::Storage to update the mtime on BOOTC_ROOT. Signed-off-by: John Eckersberg <[email protected]>
1 parent f95d43c commit 608d681

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

lib/src/imgstorage.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::sync::Arc;
1313

1414
use anyhow::{Context, Result};
1515
use bootc_utils::{AsyncCommandRunExt, CommandRunExt, ExitStatusExt};
16-
use camino::Utf8Path;
16+
use camino::{Utf8Path, Utf8PathBuf};
1717
use cap_std_ext::cap_std;
1818
use cap_std_ext::cap_std::fs::Dir;
1919
use cap_std_ext::cap_tempfile::TempDir;
@@ -35,8 +35,8 @@ pub(crate) const STORAGE_ALIAS_DIR: &str = "/run/bootc/storage";
3535
/// We pass this via /proc/self/fd to the child process.
3636
const STORAGE_RUN_FD: i32 = 3;
3737

38-
/// The path to the storage, relative to the physical system root.
39-
pub(crate) const SUBPATH: &str = "ostree/bootc/storage";
38+
/// The path to the image storage, relative to the bootc root directory.
39+
pub(crate) const SUBPATH: &str = "storage";
4040
/// The path to the "runroot" with transient runtime state; this is
4141
/// relative to the /run directory
4242
const RUNROOT: &str = "bootc/storage";
@@ -139,14 +139,15 @@ impl Storage {
139139
#[context("Creating imgstorage")]
140140
pub(crate) fn create(sysroot: &Dir, run: &Dir) -> Result<Self> {
141141
Self::init_globals()?;
142-
let subpath = Utf8Path::new(SUBPATH);
142+
let subpath = &Self::subpath();
143+
143144
// SAFETY: We know there's a parent
144145
let parent = subpath.parent().unwrap();
145146
if !sysroot
146147
.try_exists(subpath)
147148
.with_context(|| format!("Querying {subpath}"))?
148149
{
149-
let tmp = format!("{SUBPATH}.tmp");
150+
let tmp = format!("{subpath}.tmp");
150151
sysroot.remove_all_optional(&tmp).context("Removing tmp")?;
151152
sysroot
152153
.create_dir_all(parent)
@@ -174,9 +175,10 @@ impl Storage {
174175
pub(crate) fn open(sysroot: &Dir, run: &Dir) -> Result<Self> {
175176
tracing::trace!("Opening container image store");
176177
Self::init_globals()?;
178+
let subpath = &Self::subpath();
177179
let storage_root = sysroot
178-
.open_dir(SUBPATH)
179-
.with_context(|| format!("Opening {SUBPATH}"))?;
180+
.open_dir(subpath)
181+
.with_context(|| format!("Opening {subpath}"))?;
180182
// Always auto-create this if missing
181183
run.create_dir_all(RUNROOT)
182184
.with_context(|| format!("Creating {RUNROOT}"))?;
@@ -303,6 +305,10 @@ impl Storage {
303305
temp_runroot.close()?;
304306
Ok(())
305307
}
308+
309+
fn subpath() -> Utf8PathBuf {
310+
Utf8Path::new(crate::store::BOOTC_ROOT).join(SUBPATH)
311+
}
306312
}
307313

308314
#[cfg(test)]

lib/src/store/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ use crate::spec::ImageStatus;
1515

1616
mod ostree_container;
1717

18+
/// The path to the bootc root directory, relative to the physical
19+
/// system root
20+
pub(crate) const BOOTC_ROOT: &str = "ostree/bootc";
21+
1822
pub(crate) struct Storage {
1923
pub sysroot: SysrootLock,
2024
run: Dir,

0 commit comments

Comments
 (0)