From owner-svn-src-all@freebsd.org Mon Dec 31 00:09:46 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4152A143A7D4; Mon, 31 Dec 2018 00:09:46 +0000 (UTC) (envelope-from bcran@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D61927429D; Mon, 31 Dec 2018 00:09:45 +0000 (UTC) (envelope-from bcran@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C43C9275E; Mon, 31 Dec 2018 00:09:45 +0000 (UTC) (envelope-from bcran@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBV09jU8017570; Mon, 31 Dec 2018 00:09:45 GMT (envelope-from bcran@FreeBSD.org) Received: (from bcran@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBV09jZO017569; Mon, 31 Dec 2018 00:09:45 GMT (envelope-from bcran@FreeBSD.org) Message-Id: <201812310009.wBV09jZO017569@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bcran set sender to bcran@FreeBSD.org using -f From: Rebecca Cran Date: Mon, 31 Dec 2018 00:09:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342635 - head/usr.sbin/efibootmgr X-SVN-Group: head X-SVN-Commit-Author: bcran X-SVN-Commit-Paths: head/usr.sbin/efibootmgr X-SVN-Commit-Revision: 342635 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D61927429D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-0.998,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Dec 2018 00:09:46 -0000 Author: bcran Date: Mon Dec 31 00:09:45 2018 New Revision: 342635 URL: https://svnweb.freebsd.org/changeset/base/342635 Log: 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 Modified: head/usr.sbin/efibootmgr/efibootmgr.c Modified: head/usr.sbin/efibootmgr/efibootmgr.c ============================================================================== --- head/usr.sbin/efibootmgr/efibootmgr.c Sun Dec 30 23:08:06 2018 (r342634) +++ head/usr.sbin/efibootmgr/efibootmgr.c Mon Dec 31 00:09:45 2018 (r342635) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2017 Netflix, Inc. + * Copyright (c) 2017-2018 Netflix, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -94,16 +94,16 @@ typedef struct _bmgr_opts { } bmgr_opts_t; static struct option lopts[] = { - {"activate", required_argument, NULL, 'a'}, - {"bootnext", required_argument, NULL, 'n'}, /* set bootnext */ + {"activate", no_argument, NULL, 'a'}, + {"bootnext", no_argument, NULL, 'n'}, /* set bootnext */ {"bootnum", required_argument, NULL, 'b'}, {"bootorder", required_argument, NULL, 'o'}, /* set order */ {"copy", required_argument, NULL, 'C'}, /* Copy boot method */ {"create", no_argument, NULL, 'c'}, - {"deactivate", required_argument, NULL, 'A'}, + {"deactivate", no_argument, NULL, 'A'}, {"del-timout", no_argument, NULL, 'T'}, - {"delete", required_argument, NULL, 'B'}, - {"delete-bootnext", required_argument, NULL, 'N'}, + {"delete", no_argument, NULL, 'B'}, + {"delete-bootnext", no_argument, NULL, 'N'}, {"dry-run", no_argument, NULL, 'D'}, {"env", required_argument, NULL, 'e'}, {"help", no_argument, NULL, 'h'}, @@ -171,37 +171,35 @@ set_bootvar(const char *name, uint8_t *data, size_t si #define USAGE \ - " [-aAnNB Bootvar] [-t timeout] [-T] [-o bootorder] [-O] [--verbose] [--help] \n\ - [-c -l loader [-k kernel ] [-L label] [--dry-run] [-b Bootvar]]" + " [-aAnB -b bootnum] [-N] [-t timeout] [-T] [-o bootorder] [-O] [--verbose] [--help]\n\ + [-c -l loader [-k kernel] [-L label] [--dry-run] [-b bootnum]]" #define CREATE_USAGE \ - " efibootmgr -c -l loader [-k kernel] [-L label] [--dry-run]" + " efibootmgr -c -l loader [-k kernel] [-L label] [--dry-run] [-b bootnum] [-a]" #define ORDER_USAGE \ " efibootmgr -o bootvarnum1,bootvarnum2,..." #define TIMEOUT_USAGE \ " efibootmgr -t seconds" #define DELETE_USAGE \ - " efibootmgr -B bootvarnum" + " efibootmgr -B -b bootnum" #define ACTIVE_USAGE \ - " efibootmgr [-a | -A] bootvarnum" + " efibootmgr [-a | -A] -b bootnum" #define BOOTNEXT_USAGE \ - " efibootmgr [-n | -N] bootvarnum" + " efibootmgr [-n | -N] -b bootnum" static void parse_args(int argc, char *argv[]) { int ch; - while ((ch = getopt_long(argc, argv, "A:a:B:b:C:cDe:hk:L:l:Nn:Oo:Tt:v", + while ((ch = getopt_long(argc, argv, "AaBb:C:cDe:hk:L:l:NnOo:Tt:v", lopts, NULL)) != -1) { switch (ch) { case 'A': opts.set_inactive = true; - opts.bootnum = strtoul(optarg, NULL, 16); break; case 'a': opts.set_active = true; - opts.bootnum = strtoul(optarg, NULL, 16); break; case 'b': opts.has_bootnum = true; @@ -209,7 +207,6 @@ parse_args(int argc, char *argv[]) break; case 'B': opts.delete = true; - opts.bootnum = strtoul(optarg, NULL, 16); break; case 'C': opts.copy = true; @@ -246,7 +243,6 @@ parse_args(int argc, char *argv[]) break; case 'n': opts.set_bootnext = true; - opts.bootnum = strtoul(optarg, NULL, 16); break; case 'O': opts.once = true; @@ -275,6 +271,15 @@ parse_args(int argc, char *argv[]) if (opts.order && !(opts.order)) errx(1, "%s", ORDER_USAGE); + + if ((opts.set_inactive || opts.set_active) && !opts.has_bootnum) + errx(1, "%s", ACTIVE_USAGE); + + if (opts.delete && !opts.has_bootnum) + errx(1, "%s", DELETE_USAGE); + + if (opts.set_bootnext && !opts.has_bootnum) + errx(1, "%s", BOOTNEXT_USAGE); }