@@ -13,7 +13,7 @@ use std::sync::Arc;
1313
1414use anyhow:: { Context , Result } ;
1515use bootc_utils:: { AsyncCommandRunExt , CommandRunExt , ExitStatusExt } ;
16- use camino:: Utf8Path ;
16+ use camino:: Utf8PathBuf ;
1717use cap_std_ext:: cap_std;
1818use cap_std_ext:: cap_std:: fs:: Dir ;
1919use 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.
3636const 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
4242const 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
146- . try_exists ( subpath)
147+ . 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)
@@ -163,7 +164,7 @@ impl Storage {
163164 . context ( "Initializing images" ) ?;
164165 drop ( storage_root) ;
165166 sysroot
166- . rename ( & tmp, sysroot, subpath)
167+ . rename ( & tmp, sysroot, & subpath)
167168 . context ( "Renaming tmpdir" ) ?;
168169 tracing:: debug!( "Created image store" ) ;
169170 }
@@ -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+ [ crate :: store:: BOOTC_ROOT , SUBPATH ] . iter ( ) . collect ( )
311+ }
306312}
307313
308314#[ cfg( test) ]
0 commit comments