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

Gabriel Goller g.goller at proxmox.com
Fri Nov 24 10:04:37 CET 2023


Thanks for the review!

On 11/23/23 17:32, Thomas Lamprecht wrote:
> 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).
How about we move it to proxmox-sys?
> 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).
Yep, I would also put the LazyStatic in `proxmox-sys`.
>> +
>>       Ok(NodeStatus {
>>           memory,
>>           swap,
>> @@ -96,6 +121,7 @@ async fn get_status(





More information about the pbs-devel mailing list