]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm: introduce --revert option to call io.systemd.service.Revert
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Apr 2025 20:06:22 +0000 (05:06 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 11 Apr 2025 20:08:16 +0000 (05:08 +0900)
man/udevadm.xml
shell-completion/bash/udevadm
shell-completion/zsh/_udevadm
src/udev/udevadm-control.c

index 4e1255bf4d67db4fbcb76521984c7d60e1d656c4..5636d102b77ead8de2a4bce3990853335f5f830a 100644 (file)
             <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>
index d3c07e81ddc86853c53ded20b5d2031e88025848..ee463902b500f13fa68734686917e43ffd583853 100644 (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'
index d5cda3977e8a5f96cd6683c41671ecfd5addc30c..0f4b8aff2cda750faa34929f290490c7f129a8a7 100644 (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'
 }
 
index 1fa5a42018295889a63babefa8a7603534e35b64..f9cc4c34cfdc1c5b7e146854709575660ad7fe64 100644 (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));