chiark / gitweb /
sd-device: don't complain if the uevent file is missing
[elogind.git] / src / libelogind / sd-device / sd-device.c
index 7a7b323f3ce61ab4d57668cb454f55a724f504a7..9ef851a6bbfcd6ed53839fbc3ecab28b548b3c17 100644 (file)
@@ -510,6 +510,9 @@ int device_read_uevent_file(sd_device *device) {
         if (r == -EACCES)
                 /* empty uevent files may be write-only */
                 return 0;
+        else if (r == -ENOENT)
+                /* some devices may not have uevent files, see set_syspath() */
+                return 0;
         else if (r < 0) {
                 log_debug("sd-device: failed to read uevent file '%s': %s", path, strerror(-r));
                 return r;
@@ -1220,7 +1223,7 @@ int device_get_id_filename(sd_device *device, const char **ret) {
         return 0;
 }
 
-static int device_read_db(sd_device *device) {
+int device_read_db_aux(sd_device *device, bool force) {
         _cleanup_free_ char *db = NULL;
         char *path;
         const char *id, *value;
@@ -1237,7 +1240,7 @@ static int device_read_db(sd_device *device) {
                 INVALID_LINE,
         } state = PRE_KEY;
 
-        if (device->db_loaded || device->sealed)
+        if (device->db_loaded || (!force && device->sealed))
                 return 0;
 
         r = device_get_id_filename(device, &id);
@@ -1313,6 +1316,10 @@ static int device_read_db(sd_device *device) {
         return 0;
 }
 
+static int device_read_db(sd_device *device) {
+        return device_read_db_aux(device, false);
+}
+
 _public_ int sd_device_get_is_initialized(sd_device *device, int *initialized) {
         int r;