@@ -13,7 +13,7 @@ use std::sync::Arc;
13
13
14
14
use anyhow:: { Context , Result } ;
15
15
use bootc_utils:: { AsyncCommandRunExt , CommandRunExt , ExitStatusExt } ;
16
- use camino:: Utf8Path ;
16
+ use camino:: { Utf8Path , Utf8PathBuf } ;
17
17
use cap_std_ext:: cap_std;
18
18
use cap_std_ext:: cap_std:: fs:: Dir ;
19
19
use cap_std_ext:: cap_tempfile:: TempDir ;
@@ -35,8 +35,8 @@ pub(crate) const STORAGE_ALIAS_DIR: &str = "/run/bootc/storage";
35
35
/// We pass this via /proc/self/fd to the child process.
36
36
const STORAGE_RUN_FD : i32 = 3 ;
37
37
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" ;
40
40
/// The path to the "runroot" with transient runtime state; this is
41
41
/// relative to the /run directory
42
42
const RUNROOT : & str = "bootc/storage" ;
@@ -139,14 +139,15 @@ impl Storage {
139
139
#[ context( "Creating imgstorage" ) ]
140
140
pub ( crate ) fn create ( sysroot : & Dir , run : & Dir ) -> Result < Self > {
141
141
Self :: init_globals ( ) ?;
142
- let subpath = Utf8Path :: new ( SUBPATH ) ;
142
+ let subpath = & Self :: subpath ( ) ;
143
+
143
144
// SAFETY: We know there's a parent
144
145
let parent = subpath. parent ( ) . unwrap ( ) ;
145
146
if !sysroot
146
147
. try_exists ( subpath)
147
148
. with_context ( || format ! ( "Querying {subpath}" ) ) ?
148
149
{
149
- let tmp = format ! ( "{SUBPATH }.tmp" ) ;
150
+ let tmp = format ! ( "{subpath }.tmp" ) ;
150
151
sysroot. remove_all_optional ( & tmp) . context ( "Removing tmp" ) ?;
151
152
sysroot
152
153
. create_dir_all ( parent)
@@ -174,9 +175,10 @@ impl Storage {
174
175
pub ( crate ) fn open ( sysroot : & Dir , run : & Dir ) -> Result < Self > {
175
176
tracing:: trace!( "Opening container image store" ) ;
176
177
Self :: init_globals ( ) ?;
178
+ let subpath = & Self :: subpath ( ) ;
177
179
let storage_root = sysroot
178
- . open_dir ( SUBPATH )
179
- . with_context ( || format ! ( "Opening {SUBPATH }" ) ) ?;
180
+ . open_dir ( subpath )
181
+ . with_context ( || format ! ( "Opening {subpath }" ) ) ?;
180
182
// Always auto-create this if missing
181
183
run. create_dir_all ( RUNROOT )
182
184
. with_context ( || format ! ( "Creating {RUNROOT}" ) ) ?;
@@ -303,6 +305,10 @@ impl Storage {
303
305
temp_runroot. close ( ) ?;
304
306
Ok ( ( ) )
305
307
}
308
+
309
+ fn subpath ( ) -> Utf8PathBuf {
310
+ Utf8Path :: new ( crate :: store:: BOOTC_ROOT ) . join ( SUBPATH )
311
+ }
306
312
}
307
313
308
314
#[ cfg( test) ]
0 commit comments