[pbs-devel] [PATCH proxmox-backup 1/2] node: status: added bootmode

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Nov 23 17:32:53 CET 2023


Am 23/11/2023 um 14:09 schrieb Gabriel Goller:
> @@ -79,6 +83,27 @@ async fn get_status(
>  
>      let disk = crate::tools::fs::fs_info_static(proxmox_lang::c_str!("/")).await?;
>  
> +    let boot_info: BootModeInformation;
> +    if Path::new("/sys/firmware/efi").exists() {
> +        // Check if SecureBoot is enabled
> +        // Attention: this file is not seekable!
> +        let efivar =
> +            File::open("/sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c");
> +        if let Ok(mut file) = efivar {
> +            let mut buf = [0; 5];
> +            file.read_exact(&mut buf)?;
> +            if buf[4..] == [1] {
> +                boot_info = BootModeInformation::EfiSecureBoot;
> +            } else {
> +                boot_info = BootModeInformation::Efi;
> +            }
> +        } else {
> +            boot_info = BootModeInformation::Efi;
> +        }
> +    } else {
> +        boot_info = BootModeInformation::Bios;
> +    }

please move above into it's own helper method, it could even live in
some more common module (but we can still move it later, so no hard
feelings on that).

And I'd also like if this caches the boot mode, e.g. in a LazyStatic,
similar to how Proxmox VE does it, as I know that lots of firmware is
rather a mess, so constantly reading EFI vars might make trigger some
bugs (or just hang suddenly).

> +
>      Ok(NodeStatus {
>          memory,
>          swap,
> @@ -96,6 +121,7 @@ async fn get_status(





More information about the pbs-devel mailing list