From nobody Mon Feb 12 18:53:40 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TYYWn1ntpz5BMfr; Mon, 12 Feb 2024 18:53:41 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TYYWn0B20z4m3g; Mon, 12 Feb 2024 18:53:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707764021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C6Df42PcBBD+Wh0mqmKRIPZuUTJERO8U5or1j2h+rQw=; b=qEL18ZdC1FaNF+YwKmMkBoj4TgKBpNR3eZbdje8L6zZcb3TexkGzz9bOMBSYZAl2/d6LFz LqbQBBAAvjB5ThQPhjDZsMvLONCQfPUKOTqfdQiydVLyyNPbHXQwMLxEkJSqkcpq5TB/dZ 7lApaXpLdSQc3KPltzxS3sOyBhS5BAaAkwvsbJswZfkg2rT0u82JE3442fLByn2urTbgN9 pX15Xidjlod6PP5zsFTkD7TmEX7hK4kZWUmfbPnkgQQ8hjWG0+68xBJxrp28rhJB865Yz4 WCaFrt/XCveqOyL6m0SyIJRoYgv+rRtua3EdjmJHcAUlkPw+q5K3UU/GFNg1Eg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707764021; a=rsa-sha256; cv=none; b=YYcnpO4op2bkRa/1NWqhnidysX0zjzdMoR7sJdSdbUynz4x96O66ykfo8UslC6lXHTbpG6 KHklIDBdt+RsosOlFPXeL9U7qhhcazFrqa6U5ukbHC0DbuNfuuAsDlOrpGHWNsJliF1D9t 3bAUAgUI6N50aAsr0cd9l0ojN+y4cx8fNhGYUi6sCjsFCQRc9hC7KlE95wNipV6d3XUkjn LHxelxacFC1E9IuifDz+DVa7y+zJLNbDDLBnw6y22EG3jj7Y2HJoKSPndpHsPRQ9dpxWhR ALJ6UEFbX2tThjfWdxIOAGvGCFzVWoWdRViGI4y26CvOIeW4+MvAYyaIBc1Giw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707764021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C6Df42PcBBD+Wh0mqmKRIPZuUTJERO8U5or1j2h+rQw=; b=ZAt8aAecNdiVrzOtqfxu/SL5zJrCKuEOfshHavF5puaL8OfpRZAf19sDemaeOGteix+pKg xDf41V0JTlr3W70LyA3brU3FUdIEJK4gYhiTApQPY4IVRhTGIVkgh83uUjxx8uzlK/NJce nLINZNczU0i3LRFzjqDhesqFcArcu3Q5kID3Vm4DCZ9qypx2V/qOexv7zzjVKZnPWQ7Pvy eS92igb7nne0gdJP3mGzvE1LWfhg5mjedCmoC7HFGFPgdpeLwQTy/xbh1JiOBQ4ZW72N+1 I0znSlVbhuI+jlr/WbB6Kh53PH0N0PBoL35GyYUQfrG4b1g6gwvC033UH5Axxg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TYYWm666BzjcH; Mon, 12 Feb 2024 18:53:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41CIres7030568; Mon, 12 Feb 2024 18:53:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41CIreLA030565; Mon, 12 Feb 2024 18:53:40 GMT (envelope-from git) Date: Mon, 12 Feb 2024 18:53:40 GMT Message-Id: <202402121853.41CIreLA030565@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 2c479548119a - main - reboot: Implement -D from nextboot List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2c479548119a11058fe8947ba021fd49d4169920 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=2c479548119a11058fe8947ba021fd49d4169920 commit 2c479548119a11058fe8947ba021fd49d4169920 Author: Warner Losh AuthorDate: 2024-02-12 18:45:29 +0000 Commit: Warner Losh CommitDate: 2024-02-12 18:45:29 +0000 reboot: Implement -D from nextboot Implement -D from nextboot.sh which deletes the nextboot.conf file and exists. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43822 --- sbin/reboot/reboot.8 | 12 ++++++++---- sbin/reboot/reboot.c | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/sbin/reboot/reboot.8 b/sbin/reboot/reboot.8 index 0a2fb91b6b0b..e53de69e97ae 100644 --- a/sbin/reboot/reboot.8 +++ b/sbin/reboot/reboot.8 @@ -36,16 +36,16 @@ .Nd stopping and restarting the system .Sh SYNOPSIS .Nm halt -.Op Fl flNnpq +.Op Fl DflNnpq .Op Fl k Ar kernel .Nm -.Op Fl cdflNnpqr +.Op Fl cDdflNnpqr .Op Fl k Ar kernel .Nm fasthalt -.Op Fl flNnpq +.Op Fl DflNnpq .Op Fl k Ar kernel .Nm fastboot -.Op Fl dflNnpq +.Op Fl dDflNnpq .Op Fl k Ar kernel .Sh DESCRIPTION The @@ -77,6 +77,10 @@ driver implements the power cycle functionality and only on hardware with a BMC that supports power cycling. Unlike power off, the amount of hardware that supports power cycling is small. +.It Fl D +Delete existing +.Nm nextboot +configuration and exit. .It Fl d The system is requested to create a crash dump. This option is diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 74f8cf01b3b7..d91fc6c97b0f 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -95,7 +95,7 @@ main(int argc, char *argv[]) struct utmpx utx; const struct passwd *pw; int ch, howto, i, sverrno; - bool fflag, lflag, nflag, qflag, Nflag; + bool Dflag, fflag, lflag, Nflag, nflag, qflag; uint64_t pageins; const char *user, *kernel = NULL; @@ -104,12 +104,15 @@ main(int argc, char *argv[]) howto = RB_HALT; } else howto = 0; - fflag = lflag = nflag = qflag = Nflag = false; - while ((ch = getopt(argc, argv, "cdk:lNnpqr")) != -1) + Dflag = fflag = lflag = Nflag = nflag = qflag = false; + while ((ch = getopt(argc, argv, "cDdk:lNnpqr")) != -1) switch(ch) { case 'c': howto |= RB_POWERCYCLE; break; + case 'D': + Dflag = true; + break; case 'd': howto |= RB_DUMP; break; @@ -148,6 +151,8 @@ main(int argc, char *argv[]) if (argc != 0) usage(); + if (Dflag && ((howto & ~RB_HALT) != 0 || kernel != NULL)) + errx(1, "cannot delete existing nextboot config and do anything else"); if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT)) errx(1, "cannot dump (-d) when halting; must reboot instead"); if (Nflag && (howto & RB_NOSYNC) != 0) @@ -163,6 +168,12 @@ main(int argc, char *argv[]) err(1, NULL); } + if (Dflag) { + if (unlink(PATH_NEXTBOOT) != 0) + err(1, "unlink %s", PATH_NEXTBOOT); + exit(0); + } + if (qflag) { reboot(howto); err(1, NULL);