mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
udevadm: add --wait-for-initialization option to "udevadm info"
This commit is contained in:
parent
1b47436e0e
commit
ae760f4b16
@ -175,6 +175,14 @@
|
|||||||
<para>Cleanup the udev database.</para>
|
<para>Cleanup the udev database.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-w<optional>SECONDS</optional></option></term>
|
||||||
|
<term><option>--wait-for-initialization<optional>=SECONDS</optional></option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Wait for device to be initialized. If argument <replaceable>SECONDS</replaceable>
|
||||||
|
is not specified, the default is to wait forever.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<xi:include href="standard-options.xml" xpointer="help" />
|
<xi:include href="standard-options.xml" xpointer="help" />
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
@ -48,7 +48,8 @@ _udevadm() {
|
|||||||
local -A OPTS=(
|
local -A OPTS=(
|
||||||
[COMMON]='-h --help -V --version'
|
[COMMON]='-h --help -V --version'
|
||||||
[DEBUG]='-d --debug'
|
[DEBUG]='-d --debug'
|
||||||
[INFO_STANDALONE]='-r --root -a --attribute-walk -x --export -e --export-db -c --cleanup-db'
|
[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'
|
[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 -w --settle --wait-daemon'
|
||||||
[TRIGGER_ARG]='-t --type -c --action -s --subsystem-match -S --subsystem-nomatch
|
[TRIGGER_ARG]='-t --type -c --action -s --subsystem-match -S --subsystem-nomatch
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "string-table.h"
|
#include "string-table.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
#include "udev-util.h"
|
||||||
#include "udevadm-util.h"
|
#include "udevadm-util.h"
|
||||||
#include "udevadm.h"
|
#include "udevadm.h"
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ typedef enum QueryType {
|
|||||||
static bool arg_root = false;
|
static bool arg_root = false;
|
||||||
static bool arg_export = false;
|
static bool arg_export = false;
|
||||||
static const char *arg_export_prefix = NULL;
|
static const char *arg_export_prefix = NULL;
|
||||||
|
static usec_t arg_wait_for_initialization_timeout = 0;
|
||||||
|
|
||||||
static bool skip_attribute(const char *name) {
|
static bool skip_attribute(const char *name) {
|
||||||
static const char* const skip[] = {
|
static const char* const skip[] = {
|
||||||
@ -329,6 +331,8 @@ static int help(void) {
|
|||||||
" -P --export-prefix Export the key name with a prefix\n"
|
" -P --export-prefix Export the key name with a prefix\n"
|
||||||
" -e --export-db Export the content of the udev database\n"
|
" -e --export-db Export the content of the udev database\n"
|
||||||
" -c --cleanup-db Clean up the udev database\n"
|
" -c --cleanup-db Clean up the udev database\n"
|
||||||
|
" -w --wait-for-initialization[=SECONDS]\n"
|
||||||
|
" Wait for device to be initialized\n"
|
||||||
, program_invocation_short_name);
|
, program_invocation_short_name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -350,6 +354,7 @@ int info_main(int argc, char *argv[], void *userdata) {
|
|||||||
{ "device-id-of-file", required_argument, NULL, 'd' },
|
{ "device-id-of-file", required_argument, NULL, 'd' },
|
||||||
{ "export", no_argument, NULL, 'x' },
|
{ "export", no_argument, NULL, 'x' },
|
||||||
{ "export-prefix", required_argument, NULL, 'P' },
|
{ "export-prefix", required_argument, NULL, 'P' },
|
||||||
|
{ "wait-for-initialization", optional_argument, NULL, 'w' },
|
||||||
{ "version", no_argument, NULL, 'V' },
|
{ "version", no_argument, NULL, 'V' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{}
|
{}
|
||||||
@ -358,7 +363,7 @@ int info_main(int argc, char *argv[], void *userdata) {
|
|||||||
ActionType action = ACTION_QUERY;
|
ActionType action = ACTION_QUERY;
|
||||||
QueryType query = QUERY_ALL;
|
QueryType query = QUERY_ALL;
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "aced:n:p:q:rxP:Vh", options, NULL)) >= 0)
|
while ((c = getopt_long(argc, argv, "aced:n:p:q:rxP:w::Vh", options, NULL)) >= 0)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'n':
|
case 'n':
|
||||||
case 'p': {
|
case 'p': {
|
||||||
@ -414,6 +419,14 @@ int info_main(int argc, char *argv[], void *userdata) {
|
|||||||
arg_export = true;
|
arg_export = true;
|
||||||
arg_export_prefix = optarg;
|
arg_export_prefix = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
if (optarg) {
|
||||||
|
r = parse_sec(optarg, &arg_wait_for_initialization_timeout);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to parse timeout value: %m");
|
||||||
|
} else
|
||||||
|
arg_wait_for_initialization_timeout = USEC_INFINITY;
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
return print_version();
|
return print_version();
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -453,6 +466,12 @@ int info_main(int argc, char *argv[], void *userdata) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Unknown device \"%s\": %m", *p);
|
return log_error_errno(r, "Unknown device \"%s\": %m", *p);
|
||||||
|
|
||||||
|
if (arg_wait_for_initialization_timeout > 0) {
|
||||||
|
r = device_wait_for_initialization(device, NULL, arg_wait_for_initialization_timeout, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
if (action == ACTION_QUERY)
|
if (action == ACTION_QUERY)
|
||||||
r = query_device(query, device);
|
r = query_device(query, device);
|
||||||
else if (action == ACTION_ATTRIBUTE_WALK)
|
else if (action == ACTION_ATTRIBUTE_WALK)
|
||||||
|
Loading…
Reference in New Issue
Block a user