lua loader: Add disable-device to disable a device.

disable-device fooX will set hint.foo.X.disabled=1 as a way to easily
disable a device attaching during boot.

Reviewed by:		tsoome
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D31297
This commit is contained in:
Warner Losh 2021-07-28 16:52:38 -06:00
parent efea1bc1fd
commit 07c4b78d0a
2 changed files with 23 additions and 2 deletions

View File

@ -240,6 +240,21 @@ cli["show-module-options"] = function()
pager.close() pager.close()
end end
cli["disable-device"] = function(...)
local _, argv = cli.arguments(...)
local d, u
if #argv == 0 then
print("usage error: disable-device device")
return
end
d, u = string.match(argv[1], "(%w*%a)(%d+)")
if d ~= nil then
loader.setenv("hint." .. d .. "." .. u .. ".disabled", "1")
end
end
-- Used for splitting cli varargs into cmd_name and the rest of argv -- Used for splitting cli varargs into cmd_name and the rest of argv
function cli.arguments(...) function cli.arguments(...)
local argv = {...} local argv = {...}

View File

@ -26,7 +26,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd December 17, 2020 .Dd July 24, 2021
.Dt CLI.LUA 8 .Dt CLI.LUA 8
.Os .Os
.Sh NAME .Sh NAME
@ -91,10 +91,12 @@ module provides the following default commands:
.It .It
.Ic reload-conf .Ic reload-conf
.It .It
.Ic enable-module .Ic device-disable
.It .It
.Ic disable-module .Ic disable-module
.It .It
.Ic enable-module
.It
.Ic toggle-module .Ic toggle-module
.It .It
.Ic show-module-options .Ic show-module-options
@ -131,6 +133,10 @@ The
.Ic show-module-options .Ic show-module-options
command will dump the list of modules that loader has been made aware of and command will dump the list of modules that loader has been made aware of and
any applicable options using paged output. any applicable options using paged output.
.Pp
The
.Ic device-disable
command sets the environment variable that disables the device argument.
.Ss Exported Functions .Ss Exported Functions
The following functions are exported from The following functions are exported from
.Nm : .Nm :