aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/efibootmgr/efibootmgr.c
Commit message (Collapse)AuthorAgeFilesLines
* efibootmgr: Check for efi supported after parsing argsWarner Losh2021-02-111-2/+3
| | | | | 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.
* efibootmgr: fix an incorrect error handling checkMitchell Horne2020-11-301-1/+1
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=368200
* efibootmgr: Use returned error code for error message, not errnoRyan Moeller2020-10-191-4/+9
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=366830
* efibootmgr: wrong check for opts.orderToomas Soome2020-08-261-1/+1
| | | | | | | | | opts.order && !(opts.order) does not really make sense. Reported by: swildner Notes: svn path=/head/; revision=364818
* efibootmgr: Add option to request booting to the firmware user interfaceD Scott Phillips2020-08-261-1/+81
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=364795
* efibootmgr: typo in long option nameToomas Soome2020-07-161-1/+1
| | | | | | | | | | del-timout should be del-timeout Reported by: mjg MFC after: 1 week Notes: svn path=/head/; revision=363241
* Add --esp/-E argument to print the currently booted ESPWarner Losh2019-11-201-1/+84
| | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=354925
* efibootmgr: Do not add the new boot entry in dry-run is specifiedEmmanuel Vadot2019-05-101-2/+3
| | | | | | | | | | | While here fix a typo. Sponsored-by: Ampere Computing, LLC Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D20212 Notes: svn path=/head/; revision=347441
* Regularize the Netflix copyrightWarner Losh2019-02-041-1/+0
| | | | | | | | | | | | | | | 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) Notes: svn path=/head/; revision=343755
* Change the way efibootmgr works by specifying bootnum via -b parameterRebecca Cran2018-12-311-17/+22
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=342635
* Activate support for efibootmgr(8) -b --bootnum parameterRebecca Cran2018-12-241-1/+2
| | | | | | | | Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D18647 Notes: svn path=/head/; revision=342396
* Make -a (to make the entry active) apply to creation of a new bootWarner Losh2018-09-021-2/+4
| | | | | | | | | | | variable. Approved by: re@ (rgrimes) PR: 231013 Differential Revision: https://reviews.freebsd.org/D16977 Notes: svn path=/head/; revision=338432
* Add -b bootnum to allow creation of a specific boot number (ratherWarner Losh2018-07-271-9/+30
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=336768
* Remove ignored command line optionsWarner Losh2018-05-081-2/+0
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=333385
* Improve printing the boot variables.Warner Losh2018-05-081-28/+73
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=333383
* Inline print_order(). It's used one palce.Warner Losh2018-05-081-22/+8
| | | | Notes: svn path=/head/; revision=333381
* Make not getting BootOrder a warning, not a fatal error when printing.Warner Losh2018-03-161-2/+4
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=331069
* Fix error in determining the next available boot slot.Warner Losh2018-01-121-1/+1
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=327877
* There's no need / benefit from deleting the variable before we set it.Warner Losh2018-01-061-1/+0
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=327611
* Fix usage strings. -d and -p were removed before this was committed toWarner Losh2018-01-061-3/+3
| | | | | | | | | FreeBSD, but the strings weren't updated. Sponsored by: Netflix Notes: svn path=/head/; revision=327610
* Free options before setting them. This will prevent us from leakingWarner Losh2018-01-051-0/+5
| | | | | | | | | | memory when we have multiple copies of the same option from being specified. Sponsored by: Netflix Notes: svn path=/head/; revision=327573
* Ensure that we have a description string. When unspecified, default to "".Warner Losh2018-01-051-9/+6
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=327572
* Remove write-only opt and useless optlen variables.Alexander Kabaev2017-12-241-8/+5
| | | | | | | | | | 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. Notes: svn path=/head/; revision=327163
* Actually insert the free(d) call missed in r326802.Warner Losh2017-12-121-0/+1
| | | | | | | Noticed by: rpokala@ Notes: svn path=/head/; revision=326806
* Add sanity testing against maximum sane lengths for device paths forWarner Losh2017-12-121-0/+6
| | | | | | | | | | loader and kernel. CID: 1383608 Sponsored by: Netflix Notes: svn path=/head/; revision=326804
* Free load_opt_buf after we're done with it.Warner Losh2017-12-121-1/+2
| | | | | | | | CID: 1383607 Sponsored by: Netflix Notes: svn path=/head/; revision=326803
* Fix resource leak. Free converted description after printing it.Warner Losh2017-12-121-3/+4
| | | | | | | | | | Also minor style sort of local vars. CID: 1383606 Sponsored by: Netflix Notes: svn path=/head/; revision=326802
* Don't leak new_data.Warner Losh2017-12-121-0/+1
| | | | | | | | CID: 1383605 Sponsored by: Netflix Notes: svn path=/head/; revision=326801
* Check return value for set_bootvar and give a good error message.Warner Losh2017-12-121-1/+2
| | | | | | | | CID: 1383601 Sponsored by: Netflix Notes: svn path=/head/; revision=326800
* Unbreak gcc build by using (void) for functions that take no args.Warner Losh2017-12-111-3/+3
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=326771
* Indent multiple device path entries correctly.Warner Losh2017-12-091-2/+5
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=326728
* Remove vestiges of -d and -p commands.Warner Losh2017-12-091-12/+9
| | | | | | | | | Fix two core dumps when optional data isn't specified. Sponsored by: Netflix Notes: svn path=/head/; revision=326727
* Forgotten in 326725Warner Losh2017-12-091-1/+1
| | | | | | | Release Notes: Yes Notes: svn path=/head/; revision=326726
* Import Netflix's efibootmgr to help manage UEFI boot variablesWarner Losh2017-12-091-0/+874
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 Notes: svn path=/head/; revision=326725