mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 06:31:02 +00:00
69f13c4922
svn path=/nixpkgs/branches/udev-173/; revision=28660
92 lines
3.4 KiB
Diff
92 lines
3.4 KiB
Diff
commit c49ec33ba0f1a7f11b188913bb4895360ced67f8
|
|
Author: Yury G. Kudryashov <urkud.urkud@gmail.com>
|
|
Date: Tue Aug 16 16:28:56 2011 +0400
|
|
|
|
Upstream considers presence of rules_dir=... in udev.conf as a very special case.
|
|
In particular, they disable /dev/.udev/*. Re-enable it.
|
|
|
|
diff --git a/udev/udev-rules.c b/udev/udev-rules.c
|
|
index 6bf2726..c1ae1f3 100644
|
|
--- a/udev/udev-rules.c
|
|
+++ b/udev/udev-rules.c
|
|
@@ -1812,6 +1812,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
|
|
struct udev_list file_list;
|
|
struct udev_list_entry *file_loop;
|
|
struct token end_token;
|
|
+ char runpathrules[UTIL_PATH_SIZE];
|
|
|
|
rules = calloc(1, sizeof(struct udev_rules));
|
|
if (rules == NULL)
|
|
@@ -1854,22 +1855,21 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
|
|
rules->trie_nodes_cur = 1;
|
|
|
|
if (udev_get_rules_path(udev) == NULL) {
|
|
- char filename[UTIL_PATH_SIZE];
|
|
|
|
/* /lib/udev -- default/package rules */
|
|
add_matching_files(udev, &file_list, LIBEXECDIR "/rules.d", ".rules");
|
|
|
|
/* /etc/udev -- system-specific/user/admin rules */
|
|
add_matching_files(udev, &file_list, SYSCONFDIR "/udev/rules.d", ".rules");
|
|
-
|
|
- /* /run/udev -- throw-away/temporary rules */
|
|
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/rules.d", NULL);
|
|
- add_matching_files(udev, &file_list, filename, ".rules");
|
|
} else {
|
|
/* custom rules files location for testing */
|
|
add_matching_files(udev, &file_list, udev_get_rules_path(udev), ".rules");
|
|
}
|
|
|
|
+ /* /run/udev -- throw-away/temporary rules */
|
|
+ util_strscpyl(runpathrules, sizeof(runpathrules), udev_get_run_path(udev), "/rules.d", NULL);
|
|
+ add_matching_files(udev, &file_list, runpathrules, ".rules");
|
|
+
|
|
/* add all filenames to the string buffer */
|
|
udev_list_entry_foreach(file_loop, udev_list_get_entry(&file_list)) {
|
|
const char *filename = udev_list_entry_get_value(file_loop);
|
|
diff --git a/udev/udevd.c b/udev/udevd.c
|
|
index f1a31e7..45d10b6 100644
|
|
--- a/udev/udevd.c
|
|
+++ b/udev/udevd.c
|
|
@@ -1198,6 +1198,8 @@ int main(int argc, char *argv[])
|
|
struct epoll_event ep_ctrl, ep_inotify, ep_signal, ep_netlink, ep_worker;
|
|
struct udev_ctrl_connection *ctrl_conn = NULL;
|
|
int rc = 1;
|
|
+ char filename[UTIL_PATH_SIZE];
|
|
+ struct stat statbuf;
|
|
|
|
udev = udev_new();
|
|
if (udev == NULL)
|
|
@@ -1480,23 +1482,21 @@ int main(int argc, char *argv[])
|
|
inotify_add_watch(fd_inotify, udev_get_rules_path(udev),
|
|
IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
|
|
} else {
|
|
- char filename[UTIL_PATH_SIZE];
|
|
- struct stat statbuf;
|
|
|
|
inotify_add_watch(fd_inotify, LIBEXECDIR "/rules.d",
|
|
IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
|
|
inotify_add_watch(fd_inotify, SYSCONFDIR "/udev/rules.d",
|
|
IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
|
|
+ }
|
|
|
|
- /* watch dynamic rules directory */
|
|
- util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/rules.d", NULL);
|
|
- if (stat(filename, &statbuf) != 0) {
|
|
- util_create_path(udev, filename);
|
|
- mkdir(filename, 0755);
|
|
- }
|
|
- inotify_add_watch(fd_inotify, filename,
|
|
- IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
|
|
+ /* watch dynamic rules directory */
|
|
+ util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/rules.d", NULL);
|
|
+ if (stat(filename, &statbuf) != 0) {
|
|
+ util_create_path(udev, filename);
|
|
+ mkdir(filename, 0755);
|
|
}
|
|
+ inotify_add_watch(fd_inotify, filename,
|
|
+ IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
|
|
udev_watch_restore(udev);
|
|
|
|
/* block and listen to all signals on signalfd */
|