Commit Graph

41 Commits

Author SHA1 Message Date
Mateusz Piotrowski
5fce57dd12 efibootmgr: Use the hier(7) ESP mount point in examples
MFC after:	1 week
2022-04-03 14:52:07 +02:00
Emmanuel Vadot
d8d41d3b84 pkgbase: Remove libefivar package and add a efi-tools one
Put all the efi related tools into FreeBSD-efi-tools.

Differential Revision:	https://reviews.freebsd.org/D31803
2021-09-07 10:24:21 +02:00
Warner Losh
7fe2f504f8 efibootmgr: Check for efi supported after parsing args
Move the check for efi variables being supported to after parsing the args. This
allows '-h' to produce both as a normal user as well as on all systems.
2021-02-11 16:09:51 -07:00
Mitchell Horne
2e085395e1 efibootmgr: fix an incorrect error handling check
efivar_device_path_to_unix_path() returns standard error codes on
failure and zero on success. Checking for a return value less than zero
means that the actual failure cases won't be handled. This could
manifest as a segfault during the subsequent call to printf().

Reviewed by:	imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D27424
2020-11-30 22:16:11 +00:00
Ryan Moeller
b8adbe1c15 efibootmgr: Use returned error code for error message, not errno
efivar_unix_path_to_device_path returns the error code, it does not set errno.

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26852
2020-10-19 10:38:40 +00:00
Toomas Soome
b95807751a efibootmgr: wrong check for opts.order
opts.order && !(opts.order) does not really make sense.

Reported by:	swildner
2020-08-26 14:02:38 +00:00
D Scott Phillips
83c4237258 efibootmgr: Add option to request booting to the firmware user interface
The OsIndications UEFI variable can request the firware to stop at
its UI instead of continuing with boot. Add flags for setting and
clearing this request.

Reviewed by:	manu, bcr (manpages)
Approved by:	scottl (implicit)
MFC after:	1 week
Sponsored by:	Ampere Computing, Inc.
Differential Revision:	https://reviews.freebsd.org/D25839
2020-08-26 02:05:58 +00:00
John-Mark Gurney
98b765e5c2 update example to make it active when creating a new boot method...
Clean up some of the sentences and grammar...

make igor happy..
2020-07-23 22:28:35 +00:00
Toomas Soome
6b8b1bfef0 efibootmgr: typo in long option name
del-timout should be del-timeout

Reported by:	mjg
MFC after:	1 week
2020-07-16 10:20:35 +00:00
Warner Losh
1cdb8eb8fe Add --esp/-E argument to print the currently booted ESP
Add code to decode the BootCurrent and BootXXXX variable it points at
to deduce the ESP used to boot the system. By default, it prints the
path to that device. With --unix-path (-p) it will instead print the
current mount point for the ESP, if any (or an error). With
--device-path (-d) it wil print the UEFI device path for the ESP.

Note: This is the best guess based on the UEFI variables. If the ESP
is part of a gmirror, etc, that won't be reported. If by some weird
chance there was a complicated series of chain boots, this may not be
what you want. For setups that don't add layers on top of the raw
devices, it is accurate.

Differential Revision: https://reviews.freebsd.org/D22432
2019-11-20 23:58:36 +00:00
Yuri Pankov
736dcdb75a efibootmgr(8): fix markup and style issues
- split synopsis into separate options that can't be used together
- sort options
- fix (style) issues reported by mandoc lint

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D21710
2019-09-25 21:23:30 +00:00
Emmanuel Vadot
67a5e53398 efibootmgr: Do not add the new boot entry in dry-run is specified
While here fix a typo.

Sponsored-by: Ampere Computing, LLC
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D20212
2019-05-10 16:44:35 +00:00
Warner Losh
52467047aa Regularize the Netflix copyright
Use recent best practices for Copyright form at the top of
the license:
1. Remove all the All Rights Reserved clauses on our stuff. Where we
   piggybacked others, use a separate line to make things clear.
2. Use "Netflix, Inc." everywhere.
3. Use a single line for the copyright for grep friendliness.
4. Use date ranges in all places for our stuff.

Approved by: Netflix Legal (who gave me the form), adrian@ (pmc files)
2019-02-04 21:28:25 +00:00
Rebecca Cran
70de14d82f Update the efibootmgr(8) man page to document changes to options. 2019-01-01 04:57:46 +00:00
Rebecca Cran
9ed0802914 Change the way efibootmgr works by specifying bootnum via -b parameter
Instead of passing the bootnum to each different parameter, require users
to specify -b when running operations that need a bootnum.

This allows activation of a new boot entry at the same time it's created
by adding -a onto the command line.

Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D18648
2018-12-31 00:09:45 +00:00
Rebecca Cran
557a5ad425 Improve the efibootmgr(8) man page
Fix formatting, typos, and attempt to improve the wording.

Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D18646
2018-12-28 21:26:45 +00:00
Rebecca Cran
a2581e8021 Activate support for efibootmgr(8) -b --bootnum parameter
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D18647
2018-12-24 15:38:36 +00:00
Warner Losh
de6b4aa8c4 Make -a (to make the entry active) apply to creation of a new boot
variable.

Approved by: re@ (rgrimes)
PR: 231013
Differential Revision:  https://reviews.freebsd.org/D16977
2018-09-02 18:40:18 +00:00
Warner Losh
de26ba4d82 Add -b bootnum to allow creation of a specific boot number (rather
than the auotmatic selection). This is important in some scripting
environments.

Also, remove bogus checks for bootnum != 0. 0 is a valid bootnum.

Sponsored by: Netflix
2018-07-27 18:18:20 +00:00
Warner Losh
83caf7e590 Remove ignored command line options
The --device and --part command line options were planned for Linux
compatibility mode. However, that mode will never happen, so remove
them as last vestiges of a false start.

Submitted by: Vlad Movchan
2018-05-08 20:02:44 +00:00
Warner Losh
39c0a13bc7 efibootmgr.8: fix example
The example given was for the old, and now deleted, Linux
compatibility mode. Update the example for the current code.

Submitted by: Vlad Movchan
2018-05-08 20:02:39 +00:00
Warner Losh
51922c697b Improve printing the boot variables.
Print the boot variables in the order in the BootOrder variable, if it
exists, and then in verbose mode print any unreferneced BootXXXX
variables. If BootOrder isn't set, fall back to printing all the
variables.

Sponsored by: Netflix
2018-05-08 19:43:57 +00:00
Warner Losh
12f409ff75 Inline print_order(). It's used one palce. 2018-05-08 18:25:37 +00:00
Warner Losh
3fcd5d6e92 Make not getting BootOrder a warning, not a fatal error when printing.
Sponsored by: Netflix
2018-03-16 18:16:31 +00:00
Warner Losh
018caaaed0 Fix error in determining the next available boot slot.
Sponsored by: Netflix
2018-01-12 15:30:48 +00:00
Warner Losh
cac7bbe16a There's no need / benefit from deleting the variable before we set it.
Sponsored by: Netflix
2018-01-06 06:00:40 +00:00
Warner Losh
af9d0c273f Fix usage strings. -d and -p were removed before this was committed to
FreeBSD, but the strings weren't updated.

Sponsored by: Netflix
2018-01-06 06:00:34 +00:00
Warner Losh
63b5669494 Free options before setting them. This will prevent us from leaking
memory when we have multiple copies of the same option from being
specified.

Sponsored by: Netflix
2018-01-05 07:09:19 +00:00
Warner Losh
da15338df8 Ensure that we have a description string. When unspecified, default to "".
Sponsored by: Netflix
2018-01-05 07:09:09 +00:00
Alexander Kabaev
96289d0961 Remove write-only opt and useless optlen variables.
This squashes the warning gebnerated by GCC 6.x. Since
variables that are now removed had come documentation
value, put relevant bits in comment, so they can be
resurrected from there when actually needed.
2017-12-24 16:39:57 +00:00
Warner Losh
155b183ad2 Actually insert the free(d) call missed in r326802.
Noticed by: rpokala@
2017-12-12 19:45:24 +00:00
Warner Losh
af934ea3ba Add sanity testing against maximum sane lengths for device paths for
loader and kernel.

CID: 1383608
Sponsored by: Netflix
2017-12-12 19:26:24 +00:00
Warner Losh
a6b6f888b5 Free load_opt_buf after we're done with it.
CID: 1383607
Sponsored by: Netflix
2017-12-12 19:26:19 +00:00
Warner Losh
8354d13d9b Fix resource leak. Free converted description after printing it.
Also minor style sort of local vars.

CID: 1383606
Sponsored by: Netflix
2017-12-12 19:26:15 +00:00
Warner Losh
3af42ca7c1 Don't leak new_data.
CID: 1383605
Sponsored by: Netflix
2017-12-12 19:26:10 +00:00
Warner Losh
c66805a5d5 Check return value for set_bootvar and give a good error message.
CID: 1383601
Sponsored by: Netflix
2017-12-12 19:25:54 +00:00
Warner Losh
6604afe9c7 Unbreak gcc build by using (void) for functions that take no args.
Sponsored by: Netflix
2017-12-11 16:17:53 +00:00
Warner Losh
a2aa66719e Indent multiple device path entries correctly.
Sponsored by: Netflix
2017-12-09 07:44:00 +00:00
Warner Losh
1127aea3e7 Remove vestiges of -d and -p commands.
Fix two core dumps when optional data isn't specified.

Sponsored by: Netflix
2017-12-09 07:43:55 +00:00
Warner Losh
a3e6c4a6fc Forgotten in 326725
Release Notes: Yes
2017-12-09 06:57:19 +00:00
Warner Losh
1285bcc833 Import Netflix's efibootmgr to help manage UEFI boot variables
efibootmgr manages the UEFI BootXXXX variables that implement the UEFI
Boot Manager protocol defined in the UEFI standards. It is modeled
after the Linux program of the same name with a mostly compatible set
of command line options. Since there's a fair amount of OS specifioc
code due to differeing names and methods of doing things, the
compatibility isn't 100%.

Basic functionality is implemented, though the more advanced next boot
functionality that's been defined elsewhere is unimplemented.

Submitted by: Matt Williams (with unix / efi path xlate by me)
Sponsored by: Netflix
2017-12-09 06:52:20 +00:00