mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-11-23 15:00:56 +07:00
Merge branch 'master' into udevadm-hwdb-update-output
This commit is contained in:
commit
701d83f686
12
man/udev.7
12
man/udev.7
@ -34,7 +34,10 @@ All device information udev processes is stored in the udev database and sent ou
|
||||
.SH "RULES FILES"
|
||||
.PP
|
||||
The udev rules are read from the files located in the system rules directory
|
||||
/lib/udev/rules\&.d, the volatile runtime directory
|
||||
/lib/udev/rules\&.d
|
||||
(additionally
|
||||
/usr/lib/udev/rules\&.d
|
||||
when built with \-\-enable\-split\-usr), the volatile runtime directory
|
||||
/run/udev/rules\&.d
|
||||
and the local administration directory
|
||||
/etc/udev/rules\&.d\&. All rules files are collectively sorted and processed in lexical order, regardless of the directories in which they live\&. However, files with identical filenames replace each other\&. Files in
|
||||
@ -42,7 +45,9 @@ and the local administration directory
|
||||
have the highest priority, files in
|
||||
/run
|
||||
take precedence over files with the same name in
|
||||
/lib\&. This can be used to override a system\-supplied rules file with a local file if needed; a symlink in
|
||||
/lib
|
||||
(or
|
||||
/usr/lib)\&. This can be used to override a system\-supplied rules file with a local file if needed; a symlink in
|
||||
/etc
|
||||
with the same name as a rules file in
|
||||
/lib, pointing to
|
||||
@ -563,6 +568,9 @@ and compiled to a binary database located at
|
||||
if you want ship the compiled database in an immutable image by using
|
||||
\fB\-\-usr\fR, or anywhere on the system by using
|
||||
\fB\-\-output\fR\&. During runtime only the binary database is used\&.
|
||||
If
|
||||
\fBUDEV_HWDB_BIN\fR
|
||||
is set at run\-time, and its value identifies a file in the file system, then the binary database located under this name will be used\&. During runtime only the binary database is used\&.
|
||||
.SH "SEE ALSO"
|
||||
.PP
|
||||
\fBudevd\fR(8),
|
||||
|
12
man/udev.xml
12
man/udev.xml
@ -55,15 +55,17 @@
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Rules Files</title>
|
||||
<para>The udev rules are read from the files located in the
|
||||
system rules directory <filename>/lib/udev/rules.d</filename>,
|
||||
<para>The udev rules are read from the files located in the system rules
|
||||
directory <filename>/lib/udev/rules.d</filename> (additionally
|
||||
<filename>/usr/lib/udev/rules.d</filename> when built with --enable-split-usr),
|
||||
the volatile runtime directory <filename>/run/udev/rules.d</filename>
|
||||
and the local administration directory <filename>/etc/udev/rules.d</filename>.
|
||||
All rules files are collectively sorted and processed in lexical order,
|
||||
regardless of the directories in which they live. However, files with
|
||||
identical filenames replace each other. Files in <filename>/etc</filename>
|
||||
have the highest priority, files in <filename>/run</filename> take precedence
|
||||
over files with the same name in <filename>/lib</filename>. This can be
|
||||
over files with the same name in <filename>/lib</filename> (or
|
||||
<filename>/usr/lib</filename>). This can be
|
||||
used to override a system-supplied rules file with a local file if needed;
|
||||
a symlink in <filename>/etc</filename> with the same name as a rules file in
|
||||
<filename>/lib</filename>, pointing to <filename>/dev/null</filename>,
|
||||
@ -765,7 +767,9 @@
|
||||
<citerefentry><refentrytitle>udevadm</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||
and compiled to a binary database located at <filename>/etc/udev/hwdb.bin</filename>,
|
||||
or alternatively <filename>/usr/lib/udev/hwdb.bin</filename> if you want ship the compiled
|
||||
database in an immutable image by using <option>--usr</option>, or anywhere on the system by using <option>--output</option>.
|
||||
If <envar>UDEV_HWDB_BIN</envar>
|
||||
is set at run-time, and its value identifies a file in the file system, then the binary
|
||||
database located under this name will be used.
|
||||
During runtime only the binary database is used.</para>
|
||||
</refsect1>
|
||||
|
||||
|
@ -47,6 +47,7 @@ struct udev_hwdb {
|
||||
struct udev *udev;
|
||||
int refcount;
|
||||
|
||||
char *bin_paths;
|
||||
FILE *f;
|
||||
struct stat st;
|
||||
union {
|
||||
@ -256,10 +257,28 @@ static int trie_search_f(struct udev_hwdb *hwdb, const char *search) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char hwdb_bin_paths[] =
|
||||
"/etc/udev/hwdb.bin\0"
|
||||
UDEV_LIBEXEC_DIR "/hwdb.bin\0";
|
||||
|
||||
static char *get_hwdb_bin_paths (void) {
|
||||
static const char default_locations[] =
|
||||
"/etc/udev/hwdb.bin\0"
|
||||
UDEV_LIBEXEC_DIR "/hwdb.bin\0";
|
||||
const char *by_env = getenv("UDEV_HWDB_BIN");
|
||||
if (by_env != NULL) {
|
||||
char *path = malloc(strlen(by_env) + 1
|
||||
+ sizeof (default_locations));
|
||||
if (path != NULL) {
|
||||
memcpy(path, by_env, strlen(by_env) + 1);
|
||||
memcpy(path + strlen(by_env) + 1,
|
||||
default_locations,
|
||||
sizeof (default_locations));
|
||||
}
|
||||
return path;
|
||||
}
|
||||
char *path = malloc(sizeof (default_locations));
|
||||
if (path != NULL) {
|
||||
memcpy(path, default_locations, sizeof (default_locations));
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* udev_hwdb_new:
|
||||
@ -282,7 +301,12 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
|
||||
udev_list_init(udev, &hwdb->properties_list, true);
|
||||
|
||||
/* find hwdb.bin in hwdb_bin_paths */
|
||||
NULSTR_FOREACH(hwdb_bin_path, hwdb_bin_paths) {
|
||||
hwdb->bin_paths = get_hwdb_bin_paths();
|
||||
if (hwdb->bin_paths == NULL) {
|
||||
udev_hwdb_unref(hwdb);
|
||||
return NULL;
|
||||
}
|
||||
NULSTR_FOREACH(hwdb_bin_path, hwdb->bin_paths) {
|
||||
hwdb->f = fopen(hwdb_bin_path, "re");
|
||||
if (hwdb->f)
|
||||
break;
|
||||
@ -363,6 +387,7 @@ _public_ struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb) {
|
||||
return NULL;
|
||||
if (hwdb->map)
|
||||
munmap((void *)hwdb->map, hwdb->st.st_size);
|
||||
free(hwdb->bin_paths);
|
||||
if (hwdb->f)
|
||||
fclose(hwdb->f);
|
||||
udev_list_cleanup(&hwdb->properties_list);
|
||||
@ -381,7 +406,7 @@ bool udev_hwdb_validate(struct udev_hwdb *hwdb) {
|
||||
return false;
|
||||
|
||||
/* if hwdb.bin doesn't exist anywhere, we need to update */
|
||||
NULSTR_FOREACH(p, hwdb_bin_paths) {
|
||||
NULSTR_FOREACH(p, hwdb->bin_paths) {
|
||||
if (stat(p, &st) >= 0) {
|
||||
found = true;
|
||||
break;
|
||||
|
@ -185,7 +185,9 @@ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev
|
||||
/*
|
||||
* udev_hwdb
|
||||
*
|
||||
* access to the static hardware properties database
|
||||
* access to the static hardware properties database; the database to
|
||||
* use can be overriden by setting the UDEV_HWDB_BIN environment
|
||||
* variable to its file name
|
||||
*/
|
||||
struct udev_hwdb;
|
||||
struct udev_hwdb *udev_hwdb_new(struct udev *udev);
|
||||
|
@ -2602,6 +2602,10 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
|
||||
case TK_A_RUN_PROGRAM: {
|
||||
struct udev_list_entry *entry;
|
||||
|
||||
if (event->run_final)
|
||||
break;
|
||||
if (cur->key.op == OP_ASSIGN_FINAL)
|
||||
event->run_final = true;
|
||||
if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
|
||||
udev_list_cleanup(&event->run_list);
|
||||
log_debug("RUN '%s' %s:%u",
|
||||
|
Loading…
Reference in New Issue
Block a user