Skip to content

Commit

Permalink
loader: set boot_safe when safe mode is selected
Browse files Browse the repository at this point in the history
This may be used to disable or limit functionality of some services
when safe mode is selected. The particular value of boot_safe should not
be considered significant, only its presence in the environment.

Reviewed by:	imp, tsoome
Differential Revision:	https://reviews.freebsd.org/D32172
  • Loading branch information
kevans91 committed Dec 14, 2024
1 parent 212d7f4 commit 48b05b8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions stand/forth/menu-commands.4th
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ also menu-namespace also menu-command-helpers
s" set hw.ata.atapi_dma=0" evaluate
s" set kern.eventtimer.periodic=1" evaluate
s" set kern.geom.part.check_integrity=0" evaluate
s" set boot_safe=YES" evaluate
;

: safemode_disable ( -- )
Expand All @@ -136,6 +137,7 @@ also menu-namespace also menu-command-helpers
s" hw.ata.atapi_dma" unsetenv
s" kern.eventtimer.periodic" unsetenv
s" kern.geom.part.check_integrity" unsetenv
s" boot_safe" unsetenv
;

: init_safemode ( N -- N )
Expand Down
2 changes: 2 additions & 0 deletions stand/lua/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ function core.setSafeMode(safe_mode)
loader.setenv("hw.ata.atapi_dma", "0")
loader.setenv("kern.eventtimer.periodic", "1")
loader.setenv("kern.geom.part.check_integrity", "0")
loader.setenv("boot_safe", "YES")
else
loader.unsetenv("kern.smp.disabled")
loader.unsetenv("hw.ata.ata_dma")
loader.unsetenv("hw.ata.atapi_dma")
loader.unsetenv("kern.eventtimer.periodic")
loader.unsetenv("kern.geom.part.check_integrity")
loader.unsetenv("boot_safe")
end
core.sm = safe_mode
end
Expand Down
17 changes: 16 additions & 1 deletion stand/man/loader_simp.8
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd September 29, 2021
.Dd September 30, 2021
.Dt LOADER_SIMP 8
.Os
.Sh NAME
Expand Down Expand Up @@ -339,6 +339,21 @@ In a running system, the state of console muting can be manipulated by the
utility.
.It Va boot_pause
During the device probe, pause after each line is printed.
.It Va boot_safe
Force userland to boot in
.Dq safe mode ,
which may disable or limit the functionality of some services that may not be
desired in safe mode.
This is typically set by selecting
.Dq safe mode
in the loader menu, which also sets some other hints for the kernel.
Applications wishing to respect safe mode should
.Sy only
test for the presence of
.Va boot_safe
in
.Xr kenv 1 ,
not for any particular value.
.It Va boot_serial
Force the use of a serial console even when an internal console
is present.
Expand Down

0 comments on commit 48b05b8

Please sign in to comment.