if (verify) {
r = readlink_and_canonicalize(_syspath, &syspath);
- if (r == -EINVAL) {
+ if (r == -ENOENT)
+ /* the device does not exist (any more?) */
+ return -ENODEV;
+ else if (r == -EINVAL) {
/* not a symlink */
syspath = canonicalize_file_name(_syspath);
if (!syspath) {
+ if (errno == ENOENT)
+ /* the device does not exist (any more?) */
+ return -ENODEV;
+
log_debug("sd-device: could not canonicalize '%s': %m", _syspath);
return -errno;
}
- /* ignore errors due to the link not being a symlink */
- } else if (r < 0 && r != -EINVAL) {
+ } else if (r < 0) {
log_debug("sd-device: could not get target of '%s': %s", _syspath, strerror(-r));
return r;
}
return sd_device_new_from_syspath(ret, syspath);
}
- return -ENOENT;
+ return -ENODEV;
}
int device_set_devtype(sd_device *device, const char *_devtype) {
if (r < 0)
return r;
- /* this si racey, so we might end up with the wrong device */
+ /* this is racey, so we might end up with the wrong device */
if (ifr.ifr_ifindex != ifindex)
return -ENODEV;
return 0;
}
- return -ENOENT;
+ return -ENODEV;
}
_public_ int sd_device_get_parent(sd_device *child, sd_device **ret) {
k = sd_device_new_from_syspath(&device, syspath);
if (k < 0) {
- log_debug_errno(k, "device-enumerator: failed to create device from syspath %s: %m", syspath);
- r = k;
+ if (k != -ENODEV)
+ /* this is necessarily racey, so ignore missing devices */
+ r = k;
+
continue;
}
k = sd_device_new_from_device_id(&device, dent->d_name);
if (k < 0) {
- r = k;
+ if (k != -ENODEV)
+ /* this is necessarily racy, so ignore missing devices */
+ r = k;
+
continue;
}
int r;
r = sd_device_new_from_syspath(&device, path);
- if (r == -ENOENT)
+ if (r == -ENODEV)
+ /* this is necessarily racy, so ignore missing devices */
return 0;
else if (r < 0)
return r;