efibootmgr: support '-b bootXXXX' as an alias for '-b XXXX'

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-05-17 10:47:03 -06:00
parent 93d4bad645
commit 98d2608a2a
2 changed files with 11 additions and 2 deletions

View file

@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.Dd February 15, 2023 .Dd October 26, 2023
.Dt EFIBOOTMGR 8 .Dt EFIBOOTMGR 8
.Os .Os
.Sh NAME .Sh NAME
@ -115,6 +115,11 @@ When creating or modifying an entry, use
.Ar bootnum .Ar bootnum
as the index. as the index.
When creating a new entry, fail if it already exists. When creating a new entry, fail if it already exists.
For convenience, if
.Ar bootnum
is prefixed with
.Dq boot ,
that prefix is ignored.
.It Fl B -delete .It Fl B -delete
Delete the given Delete the given
.Ar bootnum .Ar bootnum

View file

@ -202,6 +202,7 @@ static void
parse_args(int argc, char *argv[]) parse_args(int argc, char *argv[])
{ {
int ch; int ch;
const char *arg;
while ((ch = getopt_long(argc, argv, "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:v", while ((ch = getopt_long(argc, argv, "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:v",
lopts, NULL)) != -1) { lopts, NULL)) != -1) {
@ -214,7 +215,10 @@ parse_args(int argc, char *argv[])
break; break;
case 'b': case 'b':
opts.has_bootnum = true; opts.has_bootnum = true;
opts.bootnum = strtoul(optarg, NULL, 16); arg = optarg;
if (strncasecmp(arg, "boot", 4) == 0)
arg += 4;
opts.bootnum = strtoul(arg, NULL, 16);
break; break;
case 'B': case 'B':
opts.delete = true; opts.delete = true;