mirror of
https://github.com/systemd/systemd.git
synced 2025-02-28 05:57:33 +03:00
udevadm verify: load all rules from the system if no rules were given
When udevadm verify is invoked without positional arguments, that is, when no udev rules files are specified, load all rules files from the system like the udev daemon does, and verify them.
This commit is contained in:
parent
197f695a75
commit
e8c53080c4
@ -51,7 +51,7 @@
|
||||
<cmdsynopsis>
|
||||
<command>udevadm verify</command>
|
||||
<arg choice="opt" rep="repeat">options</arg>
|
||||
<arg choice="plain" rep="repeat"><replaceable>file</replaceable></arg>
|
||||
<arg choice="opt" rep="repeat"><replaceable>file</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
<cmdsynopsis>
|
||||
<command>udevadm wait <optional>options</optional> <replaceable>device|syspath</replaceable></command>
|
||||
@ -745,13 +745,15 @@
|
||||
<refsect2>
|
||||
<title>udevadm verify
|
||||
<arg choice="opt"><replaceable>options</replaceable></arg>
|
||||
<arg choice="plain" rep="repeat"><replaceable>file</replaceable></arg>
|
||||
<arg choice="opt" rep="repeat"><replaceable>file</replaceable></arg>
|
||||
…
|
||||
</title>
|
||||
|
||||
<para>Verify syntactic and semantic correctness of udev rules files.</para>
|
||||
|
||||
<para>Positional arguments should be used to specify one or more files to check.</para>
|
||||
<para>Positional arguments could be used to specify one or more files to check.
|
||||
If no files are specified, the udev rules are read from the files located in
|
||||
the same udev/rules.d directories that are processed by the udev daemon.</para>
|
||||
|
||||
<para>The exit status is <constant>0</constant> if all specified udev rules files
|
||||
are syntactically and semantically correct, and a non-zero error code otherwise.</para>
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "conf-files.h"
|
||||
#include "constants.h"
|
||||
#include "log.h"
|
||||
#include "pretty-print.h"
|
||||
#include "strv.h"
|
||||
@ -23,7 +25,7 @@ static int help(void) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
printf("%s verify [OPTIONS] FILE...\n"
|
||||
printf("%s verify [OPTIONS] [FILE...]\n"
|
||||
"\n%sVerify udev rules files.%s\n\n"
|
||||
" -h --help Show this help\n"
|
||||
" -V --version Show package version\n"
|
||||
@ -75,9 +77,6 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No rules file specified.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -121,5 +120,16 @@ int verify_main(int argc, char *argv[], void *userdata) {
|
||||
if (!rules)
|
||||
return -ENOMEM;
|
||||
|
||||
if (optind == argc) {
|
||||
const char* const* rules_dirs = STRV_MAKE_CONST(CONF_PATHS("udev/rules.d"));
|
||||
_cleanup_strv_free_ char **files = NULL;
|
||||
|
||||
r = conf_files_list_strv(&files, ".rules", NULL, 0, rules_dirs);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enumerate rules files: %m");
|
||||
|
||||
return verify_rules(rules, files);
|
||||
}
|
||||
|
||||
return verify_rules(rules, strv_skip(argv, optind));
|
||||
}
|
||||
|
@ -60,8 +60,6 @@ assert_0 -V
|
||||
assert_0 --version
|
||||
assert_0 /dev/null
|
||||
|
||||
# No rules file specified.
|
||||
assert_1
|
||||
# unrecognized option '--unknown'
|
||||
assert_1 --unknown
|
||||
# option requires an argument -- 'N'
|
||||
|
Loading…
x
Reference in New Issue
Block a user