]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm-trigger: introduce --quiet option
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 20 Feb 2021 07:31:40 +0000 (16:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 20 Feb 2021 19:40:23 +0000 (04:40 +0900)
This may be useful to invoke the command by non-privileged users.

man/udevadm.xml
shell-completion/bash/udevadm
shell-completion/zsh/_udevadm
src/udev/udevadm-trigger.c

index ec26cc3c07fed03d442057b9506bc86e2e82081b..b731f808bc990bc0164aada2645108ffe37d4e09 100644 (file)
             <para>Do not actually trigger the event.</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><option>-q</option></term>
+          <term><option>--quiet</option></term>
+          <listitem>
+            <para>Suppress error logging in triggering events.</para>
+          </listitem>
+        </varlistentry>
         <varlistentry>
           <term><option>-t</option></term>
           <term><option>--type=<replaceable>TYPE</replaceable></option></term>
index 8b1b962f2d49d21c01586ff78511cb78f66e9218..33d998395e3a303945b4295de8a072097d554ea6 100644 (file)
@@ -51,7 +51,7 @@ _udevadm() {
         [INFO_STANDALONE]='-r --root -a --attribute-walk -x --export -e --export-db -c --cleanup-db
                            -w --wait-for-initialization'
         [INFO_ARG]='-q --query -p --path -n --name -P --export-prefix -d --device-id-of-file'
-        [TRIGGER_STANDALONE]='-v --verbose -n --dry-run -w --settle --wait-daemon'
+        [TRIGGER_STANDALONE]='-v --verbose -n --dry-run -q --quiet -w --settle --wait-daemon'
         [TRIGGER_ARG]='-t --type -c --action -s --subsystem-match -S --subsystem-nomatch
                        -a --attr-match -A --attr-nomatch -p --property-match
                        -g --tag-match -y --sysname-match --name-match -b --parent-match'
index ae82d8aa70b296b928206825c87261c23a65e1e8..5e989b4a1d63dcfe47bffe8966ac41a7f379b0f5 100644 (file)
@@ -21,6 +21,7 @@ _udevadm_trigger(){
     _arguments \
         '--verbose[Print the list of devices which will be triggered.]' \
         '--dry-run[Do not actually trigger the event.]' \
+        '--quiet[Suppress error logging in triggering events.]' \
         '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \
         '--action=[Type of event to be triggered.]:actions:(add change remove)' \
         '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \
index f866bb7f1621c80858bb2e4e36b0ec7445b41be3..ade92286d48e8af6349b702a01d0df35679e5d3b 100644 (file)
@@ -23,6 +23,7 @@
 
 static bool arg_verbose = false;
 static bool arg_dry_run = false;
+static bool arg_quiet = false;
 
 static int exec_list(sd_device_enumerator *e, sd_device_action_t action, Set **settle_set) {
         const char *action_str;
@@ -70,6 +71,7 @@ static int exec_list(sd_device_enumerator *e, sd_device_action_t action, Set **s
 
                         bool ignore = IN_SET(r, -ENOENT, -ENODEV);
                         int level =
+                                arg_quiet ? LOG_DEBUG :
                                 r == -ENOENT ? LOG_DEBUG :
                                 r == -ENODEV ? LOG_WARNING : LOG_ERR;
 
@@ -144,6 +146,7 @@ static int help(void) {
                "  -V --version                      Show package version\n"
                "  -v --verbose                      Print the list of devices while running\n"
                "  -n --dry-run                      Do not actually trigger the events\n"
+               "  -q --quiet                        Suppress error logging in triggering events\n"
                "  -t --type=                        Type of events to trigger\n"
                "          devices                     sysfs devices (default)\n"
                "          subsystems                  sysfs subsystems and drivers\n"
@@ -174,6 +177,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
         static const struct option options[] = {
                 { "verbose",           no_argument,       NULL, 'v'      },
                 { "dry-run",           no_argument,       NULL, 'n'      },
+                { "quiet",             no_argument,       NULL, 'q'      },
                 { "type",              required_argument, NULL, 't'      },
                 { "action",            required_argument, NULL, 'c'      },
                 { "subsystem-match",   required_argument, NULL, 's'      },
@@ -217,7 +221,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return r;
 
-        while ((c = getopt_long(argc, argv, "vnt:c:s:S:a:A:p:g:y:b:wVh", options, NULL)) >= 0) {
+        while ((c = getopt_long(argc, argv, "vnqt:c:s:S:a:A:p:g:y:b:wVh", options, NULL)) >= 0) {
                 _cleanup_free_ char *buf = NULL;
                 const char *key, *val;
 
@@ -228,6 +232,9 @@ int trigger_main(int argc, char *argv[], void *userdata) {
                 case 'n':
                         arg_dry_run = true;
                         break;
+                case 'q':
+                        arg_quiet = true;
+                        break;
                 case 't':
                         if (streq(optarg, "devices"))
                                 device_type = TYPE_DEVICES;