sd-device: generate e better error code when trying to allocate sd_device for non-dir
Currently, for sysfs paths outside of /sys/devices/ we do better checking if something is a suitable path: we check if it's actually a directory, and if not return ENODEV. Let's make the codepath for nodes *inside* of /sys/device/ similar: let's also return ENODEV if the path supplied is not a directory. Previously, we'd return ENOTDIR in that case, which is quite confusing I think.
This commit is contained in:
@@ -196,6 +196,10 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
|
||||
* Hence, use log_trace_errno() here. */
|
||||
return log_trace_errno(SYNTHETIC_ERRNO(ENODEV),
|
||||
"sd-device: the uevent file \"%s/uevent\" does not exist.", syspath);
|
||||
if (errno == ENOTDIR)
|
||||
/* Not actually a directory. */
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENODEV),
|
||||
"sd-device: the syspath \"%s\" is not a directory.", syspath);
|
||||
|
||||
return log_debug_errno(errno, "sd-device: cannot find uevent file for %s: %m", syspath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user