]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
rfkill: treat ENXIO/ENODEV the same way as ENOENT 8662/head
authorLennart Poettering <lennart@poettering.net>
Thu, 5 Apr 2018 10:43:08 +0000 (12:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 5 Apr 2018 11:00:43 +0000 (13:00 +0200)
If an rfkill device disappears between the time we get notified about
the existance and we fully opened it we might get ENXIO or ENODEV (i.e.
the two kinds of "device not found" errors, which are typically
generated when for example a device node has no actual backing device
behind it). let's handle that the same way as ENOENT, and downgrade the
log message to LOG_DEBUG.

Fixes: #8586
src/rfkill/rfkill.c

index 139b4343b002789f73f11aaee36ef5adecd791f2..4c2ae2b50fd3b2b56ab81af48323b59f119963bf 100644 (file)
@@ -89,8 +89,8 @@ static int find_device(
 
         device = udev_device_new_from_subsystem_sysname(udev, "rfkill", sysname);
         if (!device)
-                return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno,
-                                      "Failed to open device %s: %m", sysname);
+                return log_full_errno(IN_SET(errno, ENOENT, ENXIO, ENODEV) ? LOG_DEBUG : LOG_ERR, errno,
+                                      "Failed to open device '%s': %m", sysname);
 
         name = udev_device_get_sysattr_value(device, "name");
         if (!name) {
@@ -148,8 +148,8 @@ static int wait_for_initialized(
         /* Check again, maybe things changed */
         d = udev_device_new_from_subsystem_sysname(udev, "rfkill", sysname);
         if (!d)
-                return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR, errno,
-                                      "Failed to open device %s: %m", sysname);
+                return log_full_errno(IN_SET(errno, ENOENT, ENXIO, ENODEV) ? LOG_DEBUG : LOG_ERR, errno,
+                                      "Failed to open device '%s': %m", sysname);
 
         if (udev_device_get_is_initialized(d) != 0) {
                 *ret = d;
@@ -313,6 +313,7 @@ static int save_state_queue(
         r = determine_state_file(udev, event, &state_file);
         if (r < 0)
                 return r;
+
         save_state_queue_remove(write_queue, event->idx, state_file);
 
         item = new0(struct write_queue_item, 1);