summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-06-01 23:51:37 +0200
committerTom Gundersen <teg@jklm.no>2015-06-02 18:12:47 +0200
commit4189708ad0cde8e211e38d27de943579772f8869 (patch)
tree1b149a4f2b419c668e59822b304f3c9d06034f35
parentd4cb0234908e08093aab3b90bc36574f53bca424 (diff)
sd-device: get_subsystem - don't complain if a device does not have a subsystem
-rw-r--r--src/libsystemd/sd-device/sd-device.c7
-rw-r--r--src/libudev/libudev-device.c3
2 files changed, 8 insertions, 2 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index 97da4a8eea..af8137b1ae 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -785,7 +785,7 @@ _public_ int sd_device_get_subsystem(sd_device *device, const char **ret) {
path_startswith(device->devpath, "/class/") ||
path_startswith(device->devpath, "/bus/"))
r = device_set_subsystem(device, "subsystem");
- if (r < 0)
+ if (r < 0 && r != -ENOENT)
return log_debug_errno(r, "sd-device: could not set subsystem for %s: %m", device->devpath);
device->subsystem_set = true;
@@ -1188,6 +1188,8 @@ int device_get_id_filename(sd_device *device, const char **ret) {
return r;
if (major(devnum) > 0) {
+ assert(subsystem);
+
/* use dev_t -- b259:131072, c254:0 */
r = asprintf(&id, "%c%u:%u",
streq(subsystem, "block") ? 'b' : 'c',
@@ -1209,6 +1211,9 @@ int device_get_id_filename(sd_device *device, const char **ret) {
if (!sysname)
return -EINVAL;
+ if (!subsystem)
+ return -EINVAL;
+
r = asprintf(&id, "+%s:%s", subsystem, sysname);
if (r < 0)
return -ENOMEM;
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 893d72c19f..c27b01db96 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -178,7 +178,8 @@ _public_ const char *udev_device_get_subsystem(struct udev_device *udev_device)
if (r < 0) {
errno = -r;
return NULL;
- }
+ } else if (!subsystem)
+ errno = ENODATA;
return subsystem;
}