public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Gabriel Goller <g.goller@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup 1/2] node: status: added bootmode
Date: Thu, 23 Nov 2023 17:32:53 +0100	[thread overview]
Message-ID: <b847fbaa-2e67-44fa-9bd2-3de99f3e907c@proxmox.com> (raw)
In-Reply-To: <20231123130935.207013-2-g.goller@proxmox.com>

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(




  reply	other threads:[~2023-11-23 16:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23 13:09 [pbs-devel] [PATCH proxmox-backup 0/2] Add bootmode, improve kernel version Gabriel Goller
2023-11-23 13:09 ` [pbs-devel] [PATCH proxmox-backup 1/2] node: status: added bootmode Gabriel Goller
2023-11-23 16:32   ` Thomas Lamprecht [this message]
2023-11-24  9:04     ` Gabriel Goller
2023-11-24  9:11       ` Thomas Lamprecht
2023-11-23 13:09 ` [pbs-devel] [PATCH proxmox-backup 2/2] node: status: declutter kernel-version Gabriel Goller
2023-11-23 16:15   ` Dietmar Maurer
2023-11-23 16:29     ` Thomas Lamprecht
2023-11-23 16:35       ` Thomas Lamprecht
2023-11-24  9:13       ` Gabriel Goller
2023-11-23 16:28   ` Thomas Lamprecht
2023-11-24 12:02 ` [pbs-devel] [PATCH proxmox-backup 0/2] Add bootmode, improve kernel version Gabriel Goller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b847fbaa-2e67-44fa-9bd2-3de99f3e907c@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=g.goller@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal