@@ -4,6 +4,7 @@ use std::io::IsTerminal;
44use std:: io:: Read ;
55use std:: io:: Write ;
66use std:: str:: FromStr ;
7+ use std:: sync:: OnceLock ;
78
89use anyhow:: { Context , Result } ;
910use bootc_utils:: try_deserialize_timestamp;
@@ -14,7 +15,6 @@ use ostree::glib;
1415use ostree_container:: OstreeImageReference ;
1516use ostree_ext:: container as ostree_container;
1617use ostree_ext:: container:: deploy:: ORIGIN_CONTAINER ;
17- use ostree_ext:: container_utils:: composefs_booted;
1818use ostree_ext:: container_utils:: ostree_booted;
1919use ostree_ext:: containers_image_proxy;
2020use ostree_ext:: keyfileext:: KeyFileExt ;
@@ -56,6 +56,21 @@ impl From<ImageSignature> for ostree_container::SignatureSource {
5656 }
5757}
5858
59+ /// Detect if we have composefs=<digest> in /proc/cmdline
60+ pub ( crate ) fn composefs_booted ( ) -> Result < Option < & ' static str > > {
61+ static CACHED_DIGEST_VALUE : OnceLock < Option < String > > = OnceLock :: new ( ) ;
62+ if let Some ( v) = CACHED_DIGEST_VALUE . get ( ) {
63+ return Ok ( v. as_deref ( ) ) ;
64+ }
65+ let cmdline = crate :: kernel_cmdline:: Cmdline :: from_proc ( ) ?;
66+ let Some ( kv) = cmdline. find_str ( "composefs" ) else {
67+ return Ok ( None ) ;
68+ } ;
69+ let Some ( v) = kv. value else { return Ok ( None ) } ;
70+ let r = CACHED_DIGEST_VALUE . get_or_init ( || Some ( v. to_owned ( ) ) ) ;
71+ Ok ( r. as_deref ( ) )
72+ }
73+
5974/// Fixme lower serializability into ostree-ext
6075fn transport_to_string ( transport : ostree_container:: Transport ) -> String {
6176 match transport {
@@ -484,7 +499,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
484499 let booted_deployment = sysroot. booted_deployment ( ) ;
485500 let ( _deployments, host) = get_status ( & sysroot, booted_deployment. as_ref ( ) ) ?;
486501 host
487- } else if composefs_booted ( ) ? {
502+ } else if composefs_booted ( ) ?. is_some ( ) {
488503 composefs_deployment_status ( ) . await ?
489504 } else {
490505 Default :: default ( )
0 commit comments