struct udev_rules {
struct udev *udev;
char **dirs;
- usec_t *dirs_ts_usec;
+ usec_t dirs_ts_usec;
int resolve_names;
/* every key in the rules file becomes a token */
char *key;
char *val;
size_t len;
+ struct udev_list_entry *entry;
/* find key */
key = line;
val++;
}
- /* handle device, renamed by external tool, returning new path */
- if (streq(key, "DEVPATH")) {
- char syspath[UTIL_PATH_SIZE];
-
- log_debug("updating devpath from '%s' to '%s'\n",
- udev_device_get_devpath(dev), val);
- strscpyl(syspath, sizeof(syspath), "/sys", val, NULL);
- udev_device_set_syspath(dev, syspath);
- } else {
- struct udev_list_entry *entry;
-
- entry = udev_device_add_property(dev, key, val);
- /* store in db, skip private keys */
- if (key[0] != '.')
- udev_list_entry_set_num(entry, true);
- }
+ entry = udev_device_add_property(dev, key, val);
+ /* store in db, skip private keys */
+ if (key[0] != '.')
+ udev_list_entry_set_num(entry, true);
+
return 0;
}
"starting at character %tu ('%s')\n",
filename, lineno, linepos - line + 1, tmp);
if (linepos[1] == '#')
- log_info("hint: comments can only start at beginning of line");
+ log_error("hint: comments can only start at beginning of line");
}
break;
}
}
strv_uniq(rules->dirs);
- rules->dirs_ts_usec = calloc(strv_length(rules->dirs), sizeof(usec_t));
- if(!rules->dirs_ts_usec)
- return udev_rules_unref(rules);
udev_rules_check_timestamp(rules);
r = conf_files_list_strv(&files, ".rules", NULL, (const char **)rules->dirs);
free(rules->uids);
free(rules->gids);
strv_free(rules->dirs);
- free(rules->dirs_ts_usec);
free(rules);
return NULL;
}
bool udev_rules_check_timestamp(struct udev_rules *rules)
{
- unsigned int i;
- bool changed = false;
-
- if (rules == NULL)
- goto out;
-
- for (i = 0; rules->dirs[i]; i++) {
- struct stat stats;
+ if (!rules)
+ return false;
- if (stat(rules->dirs[i], &stats) < 0)
- continue;
-
- if (rules->dirs_ts_usec[i] == timespec_load(&stats.st_mtim))
- continue;
-
- /* first check */
- if (rules->dirs_ts_usec[i] != 0) {
- log_debug("reload - timestamp of '%s' changed\n", rules->dirs[i]);
- changed = true;
- }
-
- /* update timestamp */
- rules->dirs_ts_usec[i] = timespec_load(&stats.st_mtim);
- }
-out:
- return changed;
+ return paths_check_timestamp(rules->dirs, &rules->dirs_ts_usec, true);
}
static int match_key(struct udev_rules *rules, struct token *token, const char *val)
strscpyl(tag_symlink, sizeof(tag_symlink), tags_dir, unescaped_filename, NULL);
r = symlink(device_node, tag_symlink);
if (r < 0 && errno != EEXIST) {
- log_error("failed to create symlink %s -> %s: %s\n", tag_symlink, device_node, strerror(errno));
+ log_error("failed to create symlink %s -> %s: %m\n", tag_symlink, device_node);
return -errno;
} else
r = 0;