aboutsummaryrefslogtreecommitdiff
path: root/sbin/reboot
Commit message (Collapse)AuthorAgeFilesLines
* reboot: fix openlog(3) callsRicardo Branco2026-07-081-5/+5
| | | | | | | | | | | LOG_CONS was OR'd into the facility argument instead of logopt, leaving logopt as 0. The correct call is openlog(ident, LOG_CONS, LOG_AUTH), as shutdown(8) and init(8) already do. PR: 296315 Signed-off-by: Ricardo Branco <rbranco@suse.de> Reviewed by: imp, des Pull Request: https://github.com/freebsd/freebsd-src/pull/2300
* reboot: Include limits.h for PATH_MAXMark Johnston2026-05-121-0/+1
| | | | MFC after: 1 week
* reboot: Fix halt -p behaviorDag-Erling Smørgrav2025-12-191-2/+2
| | | | | | | | | | | The RB_HALT bit is always set when invoked as `halt`, so to maintain a distinction between `halt` and `halt -p`, we must check the RB_POWEROFF bit first. PR: 291814 Fixes: 4453ec5b8716 ("reboot: Default to a clean shutdown") Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D54320
* reboot: Default to a clean shutdownDag-Erling Smørgrav2025-12-102-32/+88
| | | | | | | | | | | | | | | | | | | | | | | | | * If invoked as fasthalt or fastboot, behavior is unchanged. * If not invoked as fasthalt or fastboot, we simply signal init(8), just like shutdown(8) does, instead of taking the system down ourselves. * Since only init can handle the RB_REROOT case, the -r flag is not supported in fast mode. * Update the usage string to correctly reflect the program being run (fast or normal; halt, boot, or nextboot) and the options available in each case. * Update the manual page to make the distinction between normal and fast mode clear, better explain what shutdown(8) still does that reboot(8) does not, and add a historical note explaining what the difference between the two used to be. MFC after: 1 month Relnotes: yes Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D54117
* nextboot: Reimplement missing -a optionDag-Erling Smørgrav2025-12-082-12/+36
| | | | | | | | | | | | | | * Reimplement the -a option which was available in the original shell script and is still documented. * Print the correct usage string when invoked as nextboot. * Add the -D option to the manual page synopsis. MFC after: 1 week Fixes: fd6d47375a78 ("rescue,nextboot: Install nextboot as a link to reboot, rm nextboot.sh") Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D54120
* reboot(8): add support for noshutdownKonstantin Belousov2025-07-222-0/+16
| | | | | | | | | | Similar to shutdown(8), refuse to reboot if /var/run/noshutdown is present. The -f option can be used to force operation. Reviewed by: imp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D51241
* reboot.8: Xr reboot(2)Maxim Konovalov2025-04-121-1/+2
| | | | | PR: 259439 MFC after: 1 week
* boot_i386.8: Mention this is legacyEd Maste2025-04-071-3/+3
| | | | | | Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49704
* nextboot: Smarter warning about deleting nextbootWarner Losh2025-01-141-1/+16
| | | | | | | | | | | | | | | | | | | | | | Read only filesystems always error when trying to remove something with EROFS. However, that's true even if the file isn't there. The code assumed it would always get a ENOENT if the file wasn't there, but produced a gross message on read only systems. This message was harmless, but annoying. Instead, stat the file first and return if it's already not there. Some readings of POSIX require that the ENOENT error take precidence over the EROFS error. Linux made this change years ago, and we should too. POSIX.1-2024 isn't explicit, but does say for unlink() does say "[EROFS] The directory entry to be unlinked is part of a read-only file system" and "[ENOENT] A component of path does not name an existing file" implying that EROFS should only be returned for an existing file. FreeBSD doesn't implement this, so this workaround is necessary. Ideally, we'd fix this in the kernel in the future. Sponsored by: Netflix Discussed with: jrtc23 Differential Revision: https://reviews.freebsd.org/D48425
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* nextboot: Permit ZFS boot filesystems mounted at the pool's rootJohn Baldwin2024-05-301-3/+3
| | | | | | | | | | This restores nextboot -k on ZFS setups where /boot is on the root dataset of a pool. Reviewed by: jrtc27, glebius Fixes: 0c3ade2cf13d nextboot: fix nextboot -k on ZFS Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45306
* man filesystems: fix xrefs after move to section 4Alexander Ziaee2024-05-161-1/+1
| | | | | Reviewed by: des, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1077
* nextboot: Write nextboot.conf safelyMark Johnston2024-04-031-9/+29
| | | | | | | | | | As in the old nextboot.sh script: - First write everything to a tempfile instead of /boot/nextboot.conf. - fsync() the tempfile before renaming it to nextboot.conf. Fixes: fd6d47375a78 ("rescue,nextboot: Install nextboot as a link to reboot, rm nextboot.sh") Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44572
* nextboot: check unlink, but only warn on !ENOENTWarner Losh2024-02-221-1/+2
| | | | | | | | | | Emulate rm -f from the nextboot.sh script: Report all errors, except ENOENT. This problems show through, except the expected one when nextboot.conf isn't there. Sponsored by: Netflix Reviewed by: rew Differential Revision: https://reviews.freebsd.org/D44013
* reboot: Emulate nextboot -D betterWarner Losh2024-02-211-2/+1
| | | | | | | | | It used to produce no output when the file couldn't be removed. Emulate that better by unlinking and ignoring errors. It's used at the end of reboot always, even when the file isn't going to be there. Sponsored by: Netflix Fixes: 2c479548119a
* nextboot: fix nextboot -k on ZFSGleb Smirnoff2024-02-201-0/+5
| | | | | | | zfsbootcfg(1) expects pool name to operate on, not currently mounted filesystem name. Fixes: fd6d47375a78fbf0737012b7cc11180291781e8b
* nextboot: fix typo that merged two args into oneGleb Smirnoff2024-02-201-1/+1
| | | | Fixes: fd6d47375a78fbf0737012b7cc11180291781e8b
* reboot: Move extern for environWarner Losh2024-02-181-1/+2
| | | | | | | | envorin isn't defined in any header, and gcc is cranky with this inside a function, so move it to global scope. Both clang and gcc are now happy with this. Sponsored by: Netflix
* reboot: Remove sys/types.h: it's not needed here...Warner Losh2024-02-181-1/+0
|
* reboot: Use posix_spawn instead of systemWarner Losh2024-02-161-15/+37
| | | | | | | | | Use posix_spawn to avoid having to allocate memory needed for the system command line. Sponsored by: Netflix Reviewed by: jrtc27 Differential Revision: https://reviews.freebsd.org/D43860
* reboot: initialize howtoWarner Losh2024-02-151-1/+2
| | | | | | | Make static analyzers happy by initialzing howto to 0. Coverity is cranky that it could be used unused. But it's analysis is incomplete because the args to getopt when it wasn't initialized preclude it from being used.
* rescue,nextboot: Install nextboot as a link to reboot, rm nextboot.shWarner Losh2024-02-122-136/+4
| | | | | | | | | | | | | | | Reboot now emulates the nextboot shell script completely. Retire the nextboot.sh script and install the link. Retain the same manual page, since there's enough differences between nextboot and reboot that talking about nextboot would likely be confusing in nextboot.8 The nextboot.sh script no longer exists, so doesn't need to be fixed up to create rescue. However, now we need a link from nextboot to reboot. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43831 Differential Revision: https://reviews.freebsd.org/D43843
* reboot: Allow this to be installed as nextbootWarner Losh2024-02-121-8/+26
| | | | | | | | | | Allow nextboot to be a symlink link to reboot. It does everything reboot does, except doesn't actually setup the sytem to reboot and reboot. Also, don't accept the reboot args related to rebooting when in nextboot mode. Sponsored by: Netflix Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D43830
* reboot: Implement -o to set kernel options for next bootWarner Losh2024-02-122-1/+11
| | | | | | Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43829
* reboot: Implement -k in terms of envWarner Losh2024-02-121-7/+6
| | | | | | | | | kernel isn't special, beyond the sanity checks we do. Add it to the env rather than pass it into write_nextboot(). Sponsored by: Netflix Reviewed by: kevans, kib Differential Revision: https://reviews.freebsd.org/D43828
* reboot: Implement -e from nextbootWarner Losh2024-02-122-4/+64
| | | | | | | | Implement -e foo=bar to add loader environment variables to nextboot.conf. bar is enclosed in quotes if it isn't already. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43827
* reboot: Implement zfs supportWarner Losh2024-02-121-9/+49
| | | | | | | | | | | | | | | | | | Implement full support for ZFS -k support. For ZFS, we have to set a property that gets cleared by the boot loaeder for whether or not to process nextboot.conf. Do this using system("zfsbootcfg..." rather than coding the small subset of that program inline to avoid CDDL contamination of reboot and the complications of disabling CDDL and/or ZFS. The few bytes needed to implement reboot for systems with zfs is not worth saving for systems w/o ZFS. Only set nextboot_enable=YES for UFS filesystems. They are the only one that need that as the first line. Its presence on ZFS can cause the kernel to not be oneshot. Sponsored by: Netflix Reviewed by: kevans, kib Differential Revision: https://reviews.freebsd.org/D43824
* reboot: Implement -D from nextbootWarner Losh2024-02-122-7/+22
| | | | | | | | Implement -D from nextboot.sh which deletes the nextboot.conf file and exists. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43822
* reboot: Add sanity checking of write to nextboot.confWarner Losh2024-02-121-10/+37
| | | | | | | | | | Add sanity checking to the write to nextboot. Move to separate function and allow force to override all errors. If we can't write nextboot.conf, don't silently fail anymore. Sponsored by: Netflix Reviewed by: kevans, kib, markj, jhb Differential Revision: https://reviews.freebsd.org/D43803
* reboot: Don't reboot if the next kernel isn't thereWarner Losh2024-02-122-16/+38
| | | | | | | | | | reboot -k garbage won't boot garbage unless /boot/garbage/kernel is there. Refuse to reboot if it is missing, though allow -f to force it for special-use cases. This is in keeping with nextboot.sh. Sponsored by: Netflix Reviewed by: kevans, kib, markj, emaste Differential Revision: https://reviews.freebsd.org/D43802
* reboot: convert flags to boolsWarner Losh2024-02-121-11/+13
| | | | | | | | | Convert all the command line flags to bools, since that's how we use them. Sort the includes while adding stdbool.h. Sponsored by: Netflix Reviewed by: kevans, kib, emaste Differential Revision: https://reviews.freebsd.org/D43801
* reboot: Disallow -k and -r, it doesn't make sense.Warner Losh2024-02-121-0/+2
| | | | | | | | | When we're re-rooting to a new /, there is no next kernel. Error out rather than leaving a timebomb in /boot/nextboot.conf. Sponsored by: Netflix Reviewed by: kevans, kib, emaste Differential Revision: https://reviews.freebsd.org/D43800
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-9/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* sbin: Remove ancient SCCS tags.Warner Losh2023-11-274-8/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* reboot(8): print syscall error on sysctl failureKonstantin Belousov2023-11-131-1/+1
| | | | | | | Noted by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42561
* reboot(8): adapt for vmmeter v_swappgsin expansion to 64bitKonstantin Belousov2023-11-131-5/+5
| | | | | | | | | | Otherwise reboot(8) requires COMPAT_FREEBSD11 kernel config option. PR: 275048 Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42561
* Use 115200 bps by default for serial communicationEd Maste2023-08-171-1/+1
| | | | | | | | | | | | | 9600 was a standard baud rate decades ago, but 115200 is now more common so choose defaults that are useful to the largest number of users. Note that boot0sio does not support rates above 9600 so it remains unchanged. Reviewed by: bz, imp, manu Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36295
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-162-4/+0
| | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-163-3/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Mark usage function as __dead2 in programs where it does not returnAlfonso Gregory2023-07-071-1/+1
| | | | | | | | In most cases, usage does not return, so mark them as __dead2. For the cases where they do return, they have not been marked __dead2. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/735
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+0
|
* Cross-reference nextboot(8) and freebsd-update(8)Mateusz Piotrowski2022-03-291-1/+2
| | | | MFC after: 1 week
* boottrace: annotate init and shutdown utilitiesMitchell Horne2022-02-221-2/+8
| | | | | | | | | | Add boottrace annotations to record events in init(8), shutdown(8), and reboot(8). Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #23 Differential Revision: https://reviews.freebsd.org/D31928
* nextboot: Improve the shell code used to figure out the zpool nameAllan Jude2021-06-051-1/+1
| | | | | | | Reported by: imp Reviewed by: imp, tsoome Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D30650
* Address a mandoc warningMateusz Piotrowski2020-11-101-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=367567
* The nextboot(8) manual page currently says that the loader(8) would deleteAlexey Dokuchaev2020-10-111-7/+7
| | | | | | | | | | | | | | | | the /boot/nextboot.conf file or its contents which is 1) not the most user- friendly way of working with custom configurations, and 2) simply not true for both Forth and Lua implementations: they would not delete it, but just change the setting to "NO", that is, disable it. While at it, add one missing serial (Oxford) comma and fix some bogus line wraps along the way. Approved by: bcr (manpages) Differential Revision: https://reviews.freebsd.org/D25971 Notes: svn path=/head/; revision=366626
* nextboot(8): Fix behavior on non-ZFS /boot systemsConrad Meyer2020-09-231-1/+1
| | | | | | | | | | | Fix unquoted test for an empty value, which broke nextboot(8) on non-ZFS /boot systems after r365938. Discussed with: allanjude, tsoome X-MFC-With: r365938 Notes: svn path=/head/; revision=366078