diff options
Diffstat (limited to 'libudev')
-rw-r--r-- | libudev/libudev-device-private.c | 6 | ||||
-rw-r--r-- | libudev/libudev-device.c | 46 | ||||
-rw-r--r-- | libudev/libudev-enumerate.c | 2 | ||||
-rw-r--r-- | libudev/libudev-private.h | 2 | ||||
-rw-r--r-- | libudev/libudev-queue-private.c | 10 | ||||
-rw-r--r-- | libudev/libudev-queue.c | 4 |
6 files changed, 38 insertions, 32 deletions
diff --git a/libudev/libudev-device-private.c b/libudev/libudev-device-private.c index 3afa82e04f..7683f09857 100644 --- a/libudev/libudev-device-private.c +++ b/libudev/libudev-device-private.c @@ -31,7 +31,7 @@ static void udev_device_tag(struct udev_device *dev, const char *tag, bool add) id = udev_device_get_id_filename(dev); if (id == NULL) return; - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/tags/", tag, "/", id, NULL); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.run/udev/tags/", tag, "/", id, NULL); if (add) { int fd; @@ -115,7 +115,7 @@ int udev_device_update_db(struct udev_device *udev_device) return -1; has_info = device_has_info(udev_device); - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/db/", id, NULL); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.run/udev/db3/", id, NULL); /* do not store anything for otherwise empty devices */ if (!has_info && @@ -176,7 +176,7 @@ int udev_device_delete_db(struct udev_device *udev_device) id = udev_device_get_id_filename(udev_device); if (id == NULL) return -1; - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/db/", id, NULL); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.run/udev/db3/", id, NULL); unlink(filename); return 0; } diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c index c78cf9b7a0..dd0224ae4b 100644 --- a/libudev/libudev-device.c +++ b/libudev/libudev-device.c @@ -237,24 +237,30 @@ const char *udev_device_get_property_value(struct udev_device *udev_device, cons return udev_list_entry_get_value(list_entry); } -int udev_device_read_db(struct udev_device *udev_device) +int udev_device_read_db(struct udev_device *udev_device, const char *dbfile) { - const char *id; char filename[UTIL_PATH_SIZE]; char line[UTIL_LINE_SIZE]; FILE *f; - if (udev_device->db_loaded) - return 0; - udev_device->db_loaded = true; + /* providing a database file will always force-load it */ + if (dbfile == NULL) { + const char *id; - id = udev_device_get_id_filename(udev_device); - if (id == NULL) - return -1; - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_device->udev), "/.udev/db/", id, NULL); - f = fopen(filename, "re"); + if (udev_device->db_loaded) + return 0; + udev_device->db_loaded = true; + + id = udev_device_get_id_filename(udev_device); + if (id == NULL) + return -1; + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_device->udev), "/.run/udev/db3/", id, NULL); + dbfile = filename; + } + + f = fopen(dbfile, "re"); if (f == NULL) { - info(udev_device->udev, "no db file to read %s: %m\n", filename); + info(udev_device->udev, "no db file to read %s: %m\n", dbfile); return -1; } udev_device->is_initialized = true; @@ -908,7 +914,7 @@ const char *udev_device_get_devnode(struct udev_device *udev_device) return NULL; if (!udev_device->info_loaded) { udev_device_read_uevent_file(udev_device); - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); } /* we might get called before we handled an event and have a db, use the kernel-provided name */ @@ -1002,7 +1008,7 @@ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device * if (udev_device == NULL) return NULL; if (!udev_device->info_loaded) - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); return udev_list_get_entry(&udev_device->devlinks_list); } @@ -1030,7 +1036,7 @@ struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device return NULL; if (!udev_device->info_loaded) { udev_device_read_uevent_file(udev_device); - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); } if (!udev_device->devlinks_uptodate) { char symlinks[UTIL_PATH_SIZE]; @@ -1154,7 +1160,7 @@ unsigned long long int udev_device_get_usec_since_initialized(struct udev_device if (udev_device == NULL) return 0; if (!udev_device->info_loaded) - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); if (udev_device->usec_initialized == 0) return 0; now = usec_monotonic(); @@ -1471,7 +1477,7 @@ const char *udev_device_get_id_filename(struct udev_device *udev_device) int udev_device_get_is_initialized(struct udev_device *udev_device) { if (!udev_device->info_loaded) - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); return udev_device->is_initialized; } @@ -1519,7 +1525,7 @@ int udev_device_has_tag(struct udev_device *udev_device, const char *tag) struct udev_list_entry *list_entry; if (!udev_device->info_loaded) - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); list_entry = udev_device_get_tags_list_entry(udev_device); list_entry = udev_list_entry_get_by_name(list_entry, tag); if (list_entry != NULL) @@ -1689,7 +1695,7 @@ int udev_device_set_timeout(struct udev_device *udev_device, int timeout) int udev_device_get_event_timeout(struct udev_device *udev_device) { if (!udev_device->info_loaded) - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); return udev_device->event_timeout; } @@ -1729,7 +1735,7 @@ int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum) int udev_device_get_devlink_priority(struct udev_device *udev_device) { if (!udev_device->info_loaded) - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); return udev_device->devlink_priority; } @@ -1742,7 +1748,7 @@ int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio) int udev_device_get_watch_handle(struct udev_device *udev_device) { if (!udev_device->info_loaded) - udev_device_read_db(udev_device); + udev_device_read_db(udev_device, NULL); return udev_device->watch_handle; } diff --git a/libudev/libudev-enumerate.c b/libudev/libudev-enumerate.c index 128813c7d6..d3dd5c963f 100644 --- a/libudev/libudev-enumerate.c +++ b/libudev/libudev-enumerate.c @@ -751,7 +751,7 @@ int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate) struct dirent *dent; char path[UTIL_PATH_SIZE]; - util_strscpyl(path, sizeof(path), udev_get_dev_path(udev), "/.udev/tags/", + util_strscpyl(path, sizeof(path), udev_get_dev_path(udev), "/.run/udev/tags/", udev_list_entry_get_name(list_entry), NULL); dir = opendir(path); if (dir == NULL) diff --git a/libudev/libudev-private.h b/libudev/libudev-private.h index f95be53df7..0fe6f4a6bf 100644 --- a/libudev/libudev-private.h +++ b/libudev/libudev-private.h @@ -78,7 +78,7 @@ void udev_device_add_property_from_string_parse(struct udev_device *udev_device, int udev_device_add_property_from_string_parse_finish(struct udev_device *udev_device); char **udev_device_get_properties_envp(struct udev_device *udev_device); ssize_t udev_device_get_properties_monitor_buf(struct udev_device *udev_device, const char **buf); -int udev_device_read_db(struct udev_device *udev_device); +int udev_device_read_db(struct udev_device *udev_device, const char *dbfile); int udev_device_read_uevent_file(struct udev_device *udev_device); int udev_device_set_action(struct udev_device *udev_device, const char *action); int udev_device_set_driver(struct udev_device *udev_device, const char *driver); diff --git a/libudev/libudev-queue-private.c b/libudev/libudev-queue-private.c index 06dc2f5e0e..9b02daf0a4 100644 --- a/libudev/libudev-queue-private.c +++ b/libudev/libudev-queue-private.c @@ -103,10 +103,10 @@ void udev_queue_export_cleanup(struct udev_queue_export *udev_queue_export) { char filename[UTIL_PATH_SIZE]; - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue_export->udev), "/.udev/queue.tmp", NULL); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue_export->udev), "/.run/udev/queue.tmp", NULL); unlink(filename); - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue_export->udev), "/.udev/queue.bin", NULL); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue_export->udev), "/.run/udev/queue.bin", NULL); unlink(filename); } @@ -221,7 +221,7 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export) } /* create new queue file */ - util_strscpyl(filename_tmp, sizeof(filename_tmp), udev_get_dev_path(udev_queue_export->udev), "/.udev/queue.tmp", NULL); + util_strscpyl(filename_tmp, sizeof(filename_tmp), udev_get_dev_path(udev_queue_export->udev), "/.run/udev/queue.tmp", NULL); new_queue_file = fopen(filename_tmp, "w+"); if (new_queue_file == NULL) goto error; @@ -255,7 +255,7 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export) goto error; /* rename the new file on top of the old one */ - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue_export->udev), "/.udev/queue.bin", NULL); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue_export->udev), "/.run/udev/queue.bin", NULL); if (rename(filename_tmp, filename) != 0) goto error; @@ -401,7 +401,7 @@ static void update_failed(struct udev_queue_export *udev_queue_export, return; /* location of failed file */ - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/failed/", + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.run/udev/failed/", udev_device_get_subsystem(udev_device), ":", udev_device_get_sysname(udev_device), NULL); switch (state) { diff --git a/libudev/libudev-queue.c b/libudev/libudev-queue.c index 163e6229fe..6f743d2061 100644 --- a/libudev/libudev-queue.c +++ b/libudev/libudev-queue.c @@ -214,7 +214,7 @@ static FILE *open_queue_file(struct udev_queue *udev_queue, unsigned long long i char filename[UTIL_PATH_SIZE]; FILE *queue_file; - util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue->udev), "/.udev/queue.bin", NULL); + util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_queue->udev), "/.run/udev/queue.bin", NULL); queue_file = fopen(filename, "re"); if (queue_file == NULL) return NULL; @@ -484,7 +484,7 @@ struct udev_list_entry *udev_queue_get_failed_list_entry(struct udev_queue *udev if (udev_queue == NULL) return NULL; udev_list_cleanup_entries(udev_queue->udev, &udev_queue->failed_list); - util_strscpyl(path, sizeof(path), udev_get_dev_path(udev_queue->udev), "/.udev/failed", NULL); + util_strscpyl(path, sizeof(path), udev_get_dev_path(udev_queue->udev), "/.run/udev/failed", NULL); dir = opendir(path); if (dir == NULL) return NULL; |