1
0
mirror of https://github.com/systemd/systemd.git synced 2025-11-01 00:24:12 +03:00

udevadm: introduce --revert option to call io.systemd.service.Revert

This commit is contained in:
Yu Watanabe
2025-04-08 05:06:22 +09:00
parent 1043ae3bc2
commit c53d155d8d
4 changed files with 28 additions and 2 deletions

View File

@@ -769,6 +769,16 @@
<xi:include href="version-info.xml" xpointer="v258"/>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--revert</option></term>
<listitem>
<para>Revert settings previously set with <command>udevadm control</command> command. When
specified, settings set with <option>-l/--log-level=</option>, <option>--trace</option>,
<option>-m/--children-max=</option>, and <option>-p/--property=</option> will be cleared.</para>
<xi:include href="version-info.xml" xpointer="v258"/>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-t</option></term>
<term><option>--timeout=<replaceable>seconds</replaceable></option></term>

View File

@@ -93,7 +93,7 @@ _udevadm() {
-g --tag-match -y --sysname-match --name-match -b --parent-match
--prioritized-subsystem'
[SETTLE]='-t --timeout -E --exit-if-exists'
[CONTROL_STANDALONE]='-e --exit -s --stop-exec-queue -S --start-exec-queue -R --reload --ping
[CONTROL_STANDALONE]='-e --exit -s --stop-exec-queue -S --start-exec-queue -R --reload --ping --revert
--load-credentials'
[CONTROL_ARG]='-l --log-priority -p --property -m --children-max -t --timeout --trace'
[MONITOR_STANDALONE]='-k --kernel -u --udev -p --property'

View File

@@ -67,6 +67,7 @@ _udevadm_control(){
'(-p --property)'{-p,--property=}'[Set a global property for all events.]:KEY=VALUE' \
'(-m --children-max=)'{-m,--children-max=}'[Set the maximum number of events.]:N' \
'--trace=[Enable/disable trace logging.]:BOOL' \
'--revert[Revert previously set configurations.]' \
'(-t --timeout=)'{-t,--timeout=}'[The maximum number of seconds to wait for a reply from systemd-udevd.]:SECONDS'
}

View File

@@ -32,6 +32,7 @@ static int arg_max_children = -1;
static int arg_log_level = -1;
static int arg_start_exec_queue = -1;
static int arg_trace = -1;
static bool arg_revert = false;
static bool arg_load_credentials = false;
STATIC_DESTRUCTOR_REGISTER(arg_env, strv_freep);
@@ -45,7 +46,8 @@ static bool arg_has_control_commands(void) {
!strv_isempty(arg_env) ||
arg_max_children >= 0 ||
arg_ping ||
arg_trace >= 0;
arg_trace >= 0 ||
arg_revert;
}
static int help(void) {
@@ -62,6 +64,7 @@ static int help(void) {
" -m --children-max=N Maximum number of children\n"
" --ping Wait for udev to respond to a ping message\n"
" --trace=BOOL Enable/disable trace logging\n"
" --revert Revert previously set configurations\n"
" -t --timeout=SECONDS Maximum time to block for a reply\n"
" --load-credentials Load udev rules from credentials\n",
program_invocation_short_name);
@@ -73,6 +76,7 @@ static int parse_argv(int argc, char *argv[]) {
enum {
ARG_PING = 0x100,
ARG_TRACE,
ARG_REVERT,
ARG_LOAD_CREDENTIALS,
};
@@ -89,6 +93,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "children-max", required_argument, NULL, 'm' },
{ "ping", no_argument, NULL, ARG_PING },
{ "trace", required_argument, NULL, ARG_TRACE },
{ "revert", no_argument, NULL, ARG_REVERT },
{ "timeout", required_argument, NULL, 't' },
{ "load-credentials", no_argument, NULL, ARG_LOAD_CREDENTIALS },
{ "version", no_argument, NULL, 'V' },
@@ -157,6 +162,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_trace = r;
break;
case ARG_REVERT:
arg_revert = true;
break;
case 't':
r = parse_sec(optarg, &arg_timeout);
if (r < 0)
@@ -270,6 +279,12 @@ static int send_control_commands(void) {
if (arg_exit)
return varlink_call_and_log(link, "io.systemd.Udev.Exit", /* parameters = */ NULL, /* reply = */ NULL);
if (arg_revert) {
r = varlink_call_and_log(link, "io.systemd.Udev.Revert", /* parameters = */ NULL, /* reply = */ NULL);
if (r < 0)
return r;
}
if (arg_log_level >= 0) {
r = varlink_callbo_and_log(link, "io.systemd.service.SetLogLevel", /* reply = */ NULL,
SD_JSON_BUILD_PAIR_INTEGER("level", arg_log_level));