summaryrefslogtreecommitdiff
path: root/udev_rules.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-03-13 16:00:25 +0100
committerKay Sievers <kay.sievers@vrfy.org>2008-03-13 16:00:25 +0100
commit5ee7ecfb0f07e8c98c1c2b3d988191ad458cf097 (patch)
tree77411cd846420f345ec4fe19c8ef935a30a07510 /udev_rules.c
parent025d3cc960f4b8648e597f5f2cee6f89daf8ee5b (diff)
hack to allow ATTR{block/*/uevent}="change"
Diffstat (limited to 'udev_rules.c')
-rw-r--r--udev_rules.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/udev_rules.c b/udev_rules.c
index 5ae4aa2b78..e464404b59 100644
--- a/udev_rules.c
+++ b/udev_rules.c
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <errno.h>
#include <syslog.h>
+#include <dirent.h>
#include <fnmatch.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -1243,6 +1244,7 @@ try_parent:
if (pair->key.operation == KEY_OP_ASSIGN) {
const char *key_name = key_pair_name(rule, pair);
char devpath[PATH_SIZE];
+ char *pos;
char *attrib;
char attr[PATH_SIZE] = "";
char value[NAME_SIZE];
@@ -1264,6 +1266,28 @@ try_parent:
strlcat(attr, key_name, sizeof(attr));
}
+ pos = strstr(attr, "/*/");
+ if (pos != NULL) {
+ char str[PATH_SIZE];
+ DIR *dir;
+
+ pos[1] = '\0';
+ strlcpy(str, &pos[2], sizeof(str));
+ dir = opendir(attr);
+ if (dir != NULL) {
+ struct dirent *dent;
+
+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
+ if (dent->d_name[0] == '.')
+ continue;
+ strlcat(attr, dent->d_name, sizeof(attr));
+ break;
+ }
+ closedir(dir);
+ }
+ strlcat(attr, str, sizeof(attr));
+ }
+
strlcpy(value, key_val(rule, &pair->key), sizeof(value));
udev_rules_apply_format(udev, value, sizeof(value));
info("writing '%s' to sysfs file '%s'", value, attr);