summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-device
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-13 15:41:09 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-12-16 19:52:58 +0100
commitcd53c8f97d6247a7c73b0bde32789581bf444b3d (patch)
tree6338aab3a0533a4ee52d798a1d8fce8a2c8d0571 /src/libsystemd/sd-device
parent421e3b45f03dd6b7f8dd99258dda44428b384889 (diff)
downloadsystemd-cd53c8f97d6247a7c73b0bde32789581bf444b3d.tar.gz
systemd-cd53c8f97d6247a7c73b0bde32789581bf444b3d.tar.bz2
systemd-cd53c8f97d6247a7c73b0bde32789581bf444b3d.zip
sd-device: attempt to read db again if it wasn't found
This mostly reverts "sd-device: don't retry loading uevent/db files more than once", 7141e4f62c3f220872df3114c42d9e4b9525e43e. We will retry if we couldn't access the file, but not if parsing failed. Not re-reading the database at all just doesn't seem like a good idea. We have two implementations of device_read_db, and one does that, and the other retries to read the db. Re-reading seems more useful, since we can create the object and then access properties as some later time when we know that the device has been initialized and we can get useful results. Otherwise, we force the user to destroy this object and create a new one. This changes device_read_uevent_file() and device_read_db_aux(). See next commit for description of where those functions are used.
Diffstat (limited to 'src/libsystemd/sd-device')
-rw-r--r--src/libsystemd/sd-device/sd-device.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index d5583488f2..95068afd96 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -498,8 +498,6 @@ int device_read_uevent_file(sd_device *device) {
if (device->uevent_loaded || device->sealed)
return 0;
- device->uevent_loaded = true;
-
r = sd_device_get_syspath(device, &syspath);
if (r < 0)
return r;
@@ -507,15 +505,19 @@ int device_read_uevent_file(sd_device *device) {
path = strjoina(syspath, "/uevent");
r = read_full_file(path, &uevent, &uevent_len);
- if (r == -EACCES)
+ if (r == -EACCES) {
/* empty uevent files may be write-only */
+ device->uevent_loaded = true;
return 0;
- else if (r == -ENOENT)
+ }
+ if (r == -ENOENT)
/* some devices may not have uevent files, see set_syspath() */
return 0;
- else if (r < 0)
+ if (r < 0)
return log_device_debug_errno(device, r, "sd-device: Failed to read uevent file '%s': %m", path);
+ device->uevent_loaded = true;
+
for (i = 0; i < uevent_len; i++)
switch (state) {
case PRE_KEY:
@@ -1301,8 +1303,6 @@ int device_read_db_aux(sd_device *device, bool force) {
if (device->db_loaded || (!force && device->sealed))
return 0;
- device->db_loaded = true;
-
r = device_get_id_filename(device, &id);
if (r < 0)
return r;
@@ -1320,6 +1320,8 @@ int device_read_db_aux(sd_device *device, bool force) {
/* devices with a database entry are initialized */
device->is_initialized = true;
+ device->db_loaded = true;
+
for (i = 0; i < db_len; i++) {
switch (state) {
case PRE_KEY: