mirror of
https://github.com/systemd/systemd.git
synced 2025-08-06 21:49:53 +03:00
udevadm-control: allow to enable/disable trace logging in systemd-udevd
Should be useful for debugging udev rules.
This commit is contained in:
@ -743,6 +743,14 @@
|
|||||||
<xi:include href="version-info.xml" xpointer="v241"/>
|
<xi:include href="version-info.xml" xpointer="v241"/>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--trace=<replaceable>BOOL</replaceable></option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Enable/disable trace logging in <command>systemd-udevd</command>.</para>
|
||||||
|
|
||||||
|
<xi:include href="version-info.xml" xpointer="v258"/>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-t</option></term>
|
<term><option>-t</option></term>
|
||||||
<term><option>--timeout=<replaceable>seconds</replaceable></option></term>
|
<term><option>--timeout=<replaceable>seconds</replaceable></option></term>
|
||||||
|
@ -66,7 +66,7 @@ _udevadm() {
|
|||||||
[SETTLE]='-t --timeout -E --exit-if-exists'
|
[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
|
||||||
--load-credentials'
|
--load-credentials'
|
||||||
[CONTROL_ARG]='-l --log-priority -p --property -m --children-max -t --timeout'
|
[CONTROL_ARG]='-l --log-priority -p --property -m --children-max -t --timeout --trace'
|
||||||
[MONITOR_STANDALONE]='-k --kernel -u --udev -p --property'
|
[MONITOR_STANDALONE]='-k --kernel -u --udev -p --property'
|
||||||
[MONITOR_ARG]='-s --subsystem-match -t --tag-match'
|
[MONITOR_ARG]='-s --subsystem-match -t --tag-match'
|
||||||
[TEST_STANDALONE]='-v --verbose'
|
[TEST_STANDALONE]='-v --verbose'
|
||||||
@ -191,6 +191,9 @@ _udevadm() {
|
|||||||
-l|--log-priority)
|
-l|--log-priority)
|
||||||
comps='alert crit debug emerg err info notice warning'
|
comps='alert crit debug emerg err info notice warning'
|
||||||
;;
|
;;
|
||||||
|
--trace)
|
||||||
|
comps='yes no'
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
comps=''
|
comps=''
|
||||||
;;
|
;;
|
||||||
|
@ -66,6 +66,7 @@ _udevadm_control(){
|
|||||||
'(-R --reload)'{-R,--reload}'[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
|
'(-R --reload)'{-R,--reload}'[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
|
||||||
'(-p --property)'{-p,--property=}'[Set a global property for all events.]:KEY=VALUE' \
|
'(-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' \
|
'(-m --children-max=)'{-m,--children-max=}'[Set the maximum number of events.]:N' \
|
||||||
|
'--trace=[Enable/disable trace logging.]:BOOL' \
|
||||||
'(-t --timeout=)'{-t,--timeout=}'[The maximum number of seconds to wait for a reply from systemd-udevd.]:SECONDS'
|
'(-t --timeout=)'{-t,--timeout=}'[The maximum number of seconds to wait for a reply from systemd-udevd.]:SECONDS'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "creds-util.h"
|
#include "creds-util.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
|
#include "parse-argument.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "static-destruct.h"
|
#include "static-destruct.h"
|
||||||
@ -30,6 +31,7 @@ static bool arg_exit = false;
|
|||||||
static int arg_max_children = -1;
|
static int arg_max_children = -1;
|
||||||
static int arg_log_level = -1;
|
static int arg_log_level = -1;
|
||||||
static int arg_start_exec_queue = -1;
|
static int arg_start_exec_queue = -1;
|
||||||
|
static int arg_trace = -1;
|
||||||
static bool arg_load_credentials = false;
|
static bool arg_load_credentials = false;
|
||||||
|
|
||||||
STATIC_DESTRUCTOR_REGISTER(arg_env, strv_freep);
|
STATIC_DESTRUCTOR_REGISTER(arg_env, strv_freep);
|
||||||
@ -42,7 +44,8 @@ static bool arg_has_control_commands(void) {
|
|||||||
arg_reload ||
|
arg_reload ||
|
||||||
!strv_isempty(arg_env) ||
|
!strv_isempty(arg_env) ||
|
||||||
arg_max_children >= 0 ||
|
arg_max_children >= 0 ||
|
||||||
arg_ping;
|
arg_ping ||
|
||||||
|
arg_trace >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int help(void) {
|
static int help(void) {
|
||||||
@ -58,6 +61,7 @@ static int help(void) {
|
|||||||
" -p --property=KEY=VALUE Set a global property for all events\n"
|
" -p --property=KEY=VALUE Set a global property for all events\n"
|
||||||
" -m --children-max=N Maximum number of children\n"
|
" -m --children-max=N Maximum number of children\n"
|
||||||
" --ping Wait for udev to respond to a ping message\n"
|
" --ping Wait for udev to respond to a ping message\n"
|
||||||
|
" --trace=BOOL Enable/disable trace logging\n"
|
||||||
" -t --timeout=SECONDS Maximum time to block for a reply\n"
|
" -t --timeout=SECONDS Maximum time to block for a reply\n"
|
||||||
" --load-credentials Load udev rules from credentials\n",
|
" --load-credentials Load udev rules from credentials\n",
|
||||||
program_invocation_short_name);
|
program_invocation_short_name);
|
||||||
@ -68,6 +72,7 @@ static int help(void) {
|
|||||||
static int parse_argv(int argc, char *argv[]) {
|
static int parse_argv(int argc, char *argv[]) {
|
||||||
enum {
|
enum {
|
||||||
ARG_PING = 0x100,
|
ARG_PING = 0x100,
|
||||||
|
ARG_TRACE,
|
||||||
ARG_LOAD_CREDENTIALS,
|
ARG_LOAD_CREDENTIALS,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -83,6 +88,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
{ "env", required_argument, NULL, 'p' }, /* alias for -p */
|
{ "env", required_argument, NULL, 'p' }, /* alias for -p */
|
||||||
{ "children-max", required_argument, NULL, 'm' },
|
{ "children-max", required_argument, NULL, 'm' },
|
||||||
{ "ping", no_argument, NULL, ARG_PING },
|
{ "ping", no_argument, NULL, ARG_PING },
|
||||||
|
{ "trace", required_argument, NULL, ARG_TRACE },
|
||||||
{ "timeout", required_argument, NULL, 't' },
|
{ "timeout", required_argument, NULL, 't' },
|
||||||
{ "load-credentials", no_argument, NULL, ARG_LOAD_CREDENTIALS },
|
{ "load-credentials", no_argument, NULL, ARG_LOAD_CREDENTIALS },
|
||||||
{ "version", no_argument, NULL, 'V' },
|
{ "version", no_argument, NULL, 'V' },
|
||||||
@ -143,6 +149,14 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
arg_ping = true;
|
arg_ping = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ARG_TRACE:
|
||||||
|
r = parse_boolean_argument("--trace=", optarg, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
arg_trace = r;
|
||||||
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
r = parse_sec(optarg, &arg_timeout);
|
r = parse_sec(optarg, &arg_timeout);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -296,6 +310,13 @@ static int send_control_commands(void) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg_trace >= 0) {
|
||||||
|
r = varlink_callbo_and_log(link, "io.systemd.Udev.SetTrace", /* reply = */ NULL,
|
||||||
|
SD_JSON_BUILD_PAIR_BOOLEAN("enable", arg_trace));
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,8 @@ udevadm control -R
|
|||||||
udevadm control -p HELLO=world
|
udevadm control -p HELLO=world
|
||||||
udevadm control -m 42
|
udevadm control -m 42
|
||||||
udevadm control --ping -t 5
|
udevadm control --ping -t 5
|
||||||
|
udevadm control --trace yes
|
||||||
|
udevadm control --trace no
|
||||||
udevadm control --load-credentials
|
udevadm control --load-credentials
|
||||||
udevadm control -h
|
udevadm control -h
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user