Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115702733
D38617.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D38617.diff
View Options
diff --git a/usr.sbin/efibootmgr/efibootmgr.8 b/usr.sbin/efibootmgr/efibootmgr.8
--- a/usr.sbin/efibootmgr/efibootmgr.8
+++ b/usr.sbin/efibootmgr/efibootmgr.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 3, 2022
+.Dd February 15, 2023
.Dt EFIBOOTMGR 8
.Os
.Sh NAME
@@ -69,6 +69,7 @@
.Fl t Ar timeout
.Nm
.Fl T
+.Nm Fl u Ar unix-path
.Sh "DESCRIPTION"
The
.Nm
@@ -174,6 +175,9 @@
Delete the
.Cm BootTimeout
variable.
+.It Fl u -efidev Ar unix-path
+Displays the UEFI device path of
+.Ar unix-path .
.It Fl v -verbose
Display the device path of boot entries in the output.
.El
diff --git a/usr.sbin/efibootmgr/efibootmgr.c b/usr.sbin/efibootmgr/efibootmgr.c
--- a/usr.sbin/efibootmgr/efibootmgr.c
+++ b/usr.sbin/efibootmgr/efibootmgr.c
@@ -70,6 +70,7 @@
#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
typedef struct _bmgr_opts {
+ char *dev;
char *env;
char *loader;
char *label;
@@ -85,6 +86,7 @@
bool dry_run;
bool device_path;
bool esp_device;
+ bool find_dev;
bool fw_ui;
bool no_fw_ui;
bool has_bootnum;
@@ -114,6 +116,7 @@
{"dry-run", no_argument, NULL, 'D'},
{"env", required_argument, NULL, 'e'},
{"esp", no_argument, NULL, 'E'},
+ {"efidev", required_argument, NULL, 'u'},
{"fw-ui", no_argument, NULL, 'f'},
{"no-fw-ui", no_argument, NULL, 'F'},
{"help", no_argument, NULL, 'h'},
@@ -284,6 +287,9 @@
opts.set_timeout = true;
opts.timeout = strtoul(optarg, NULL, 10);
break;
+ case 'u':
+ opts.find_dev = true;
+ opts.dev = strdup(optarg);
case 'v':
opts.verbose = true;
break;
@@ -996,7 +1002,7 @@
char *name, *dev, *relpath, *abspath;
uint8_t *walker, *ep;
efi_char *descr;
- efidp dp, edp;
+ efidp dp;
char buf[PATH_MAX];
if (do_dp && do_unix)
@@ -1026,7 +1032,6 @@
// Now we have fplen bytes worth of file path stuff
dp = (efidp)walker;
walker += fplen;
- edp = (efidp)walker;
if (walker > ep)
errx(1, "malformed boot variable %s", name);
if (do_dp) {
@@ -1068,6 +1073,26 @@
errx(1, "failed to set boot to fw ui");
}
+static void
+find_efi_device(const char *path)
+{
+ efidp dp = NULL;
+ size_t len;
+ int ret;
+ char buf[1024];
+
+ ret = efivar_unix_path_to_device_path(path, &dp);
+ if (ret != 0)
+ errc(1, ret,
+ "Cannot translate path '%s' to UEFI", path);
+ len = efidp_size(dp);
+ if (len > MAX_DP_LEN)
+ errx(1, "Resulting device path too long.");
+ efidp_format_device_path(buf, sizeof(buf), dp, len);
+ printf("%s -> %s\n", path, buf);
+ exit (0);
+}
+
int
main(int argc, char *argv[])
{
@@ -1075,7 +1100,10 @@
memset(&opts, 0, sizeof (bmgr_opts_t));
parse_args(argc, argv);
- if (!efi_variables_supported())
+ /*
+ * find_dev can operate without any efi variables
+ */
+ if (!efi_variables_supported() && !opts.find_dev)
errx(1, "efi variables not supported on this system. root? kldload efirt?");
read_vars();
@@ -1107,6 +1135,8 @@
set_boot_to_fw_ui(true);
else if (opts.no_fw_ui)
set_boot_to_fw_ui(false);
+ else if (opts.find_dev)
+ find_efi_device(opts.dev);
print_boot_vars(opts.verbose);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 28, 9:27 AM (14 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17828389
Default Alt Text
D38617.diff (3 KB)
Attached To
Mode
D38617: efibootmgr: Add --efidev (-u) to discover UEFI's device path to a dev or file
Attached
Detach File
Event Timeline
Log In to Comment