From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v6 2/3] Add tst_secureboot_enabled() helper function
Date: Thu, 14 Jan 2021 14:38:20 +0100 [thread overview]
Message-ID: <YABJTK2hRHBjJ6lc@yuki.lan> (raw)
In-Reply-To: <20210112095759.11910-2-mdoucha@suse.cz>
Hi!
> +int tst_secureboot_enabled(void)
> +{
> + int fd;
> + char data[5];
> +
> + if (access(EFIVAR_SECUREBOOT, F_OK)) {
> + tst_res(TINFO, "Efivar FS not available");
> + return -1;
> + }
> +
> + fd = open(EFIVAR_SECUREBOOT, O_RDONLY);
> +
> + if (fd == -1) {
> + tst_res(TINFO | TERRNO,
> + "Cannot open SecureBoot Efivar sysfile");
> + return -1;
> + } else if (fd < 0) {
> + tst_brk(TBROK | TERRNO, "Invalid open() return value %d", fd);
> + return -1;
> + }
If we change the access() above to R_OK we can just do SAFE_OPEN() here, right?
Other than this the code looks good.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2021-01-14 13:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 9:57 [LTP] [PATCH v6 1/3] Add tst_kconfig_get() helper function Martin Doucha
2021-01-12 9:57 ` [LTP] [PATCH v6 2/3] Add tst_secureboot_enabled() " Martin Doucha
2021-01-14 13:38 ` Cyril Hrubis [this message]
2021-01-14 13:46 ` Martin Doucha
2021-01-14 14:09 ` Cyril Hrubis
2021-01-12 9:57 ` [LTP] [PATCH v6 3/3] syscalls/iopl02, ioperm02: Skip when kernel is locked down Martin Doucha
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=YABJTK2hRHBjJ6lc@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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