sd-device: use ERRNO_IS_NEG_DEVICE_ABSENT() for device-id load failures (#41764)
Device enumeration may encounter transient errors such as ENXIO when devices appear or disappear concurrently. These conditions represent expected "device absent" races and should be treated uniformly across the enumeration logic. This change replaces the ENODEV-specific check with ERRNO_IS_NEG_DEVICE_ABSENT(), ensuring that all expected disappearance conditions are handled consistently. Unexpected errors are still propagated, while expected races are ignored without aborting the enumeration.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "device-filter.h"
|
||||
#include "device-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "log.h"
|
||||
#include "path-util.h"
|
||||
@@ -741,7 +742,7 @@ static int enumerator_scan_dir_and_add_devices(
|
||||
|
||||
k = sd_device_new_from_syspath(&device, syspath);
|
||||
if (k < 0) {
|
||||
if (k != -ENODEV)
|
||||
if (!ERRNO_IS_NEG_DEVICE_ABSENT(k))
|
||||
/* this is necessarily racey, so ignore missing devices */
|
||||
r = k;
|
||||
|
||||
@@ -836,7 +837,7 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c
|
||||
|
||||
k = sd_device_new_from_device_id(&device, de->d_name);
|
||||
if (k < 0) {
|
||||
if (k != -ENODEV)
|
||||
if (!ERRNO_IS_NEG_DEVICE_ABSENT(k))
|
||||
/* this is necessarily racy, so ignore missing devices */
|
||||
r = k;
|
||||
|
||||
@@ -882,7 +883,7 @@ static int parent_add_child(sd_device_enumerator *enumerator, const char *path,
|
||||
int r;
|
||||
|
||||
r = sd_device_new_from_syspath(&device, path);
|
||||
if (r == -ENODEV)
|
||||
if (ERRNO_IS_NEG_DEVICE_ABSENT(r))
|
||||
/* this is necessarily racy, so ignore missing devices */
|
||||
return 0;
|
||||
else if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user