@@ -712,6 +712,27 @@ async fn initialize_ostree_root(
712
712
Ok ( ( Storage :: new ( sysroot, & temp_run) ?, has_ostree, imgstore) )
713
713
}
714
714
715
+ fn check_disk_space (
716
+ repo_fd : impl AsFd ,
717
+ image_meta : & PreparedImportMeta ,
718
+ imgref : & ImageReference ,
719
+ ) -> Result < ( ) > {
720
+ let stat = rustix:: fs:: fstatvfs ( repo_fd) ?;
721
+ let bytes_avail: u64 = stat. f_bsize * stat. f_bavail ;
722
+ tracing:: trace!( "bytes_avail: {bytes_avail}" ) ;
723
+
724
+ if image_meta. bytes_to_fetch > bytes_avail {
725
+ anyhow:: bail!(
726
+ "Insufficient free space for {image} (available: {bytes_avail} required: {bytes_to_fetch})" ,
727
+ bytes_avail = ostree_ext:: glib:: format_size( bytes_avail) ,
728
+ bytes_to_fetch = ostree_ext:: glib:: format_size( image_meta. bytes_to_fetch) ,
729
+ image = imgref. image,
730
+ ) ;
731
+ }
732
+
733
+ Ok ( ( ) )
734
+ }
735
+
715
736
#[ context( "Creating ostree deployment" ) ]
716
737
async fn install_container (
717
738
state : & State ,
@@ -760,6 +781,7 @@ async fn install_container(
760
781
match prepare_for_pull ( repo, & spec_imgref, Some ( & state. target_imgref ) ) . await ? {
761
782
PreparedPullResult :: AlreadyPresent ( existing) => existing,
762
783
PreparedPullResult :: Ready ( image_meta) => {
784
+ check_disk_space ( root_setup. physical_root . as_fd ( ) , & image_meta, & spec_imgref) ?;
763
785
pull_from_prepared (
764
786
repo,
765
787
& spec_imgref,
0 commit comments