diff options
author | Tom Gundersen <teg@jklm.no> | 2015-06-01 23:51:37 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-03-14 10:01:41 +0100 |
commit | b32ab4f27b4a4235ce433eff7f6433c020caad51 (patch) | |
tree | 5fc04eb8e9888dd14837702ce492f79014ef8f03 /src | |
parent | 9b3a72550211800eaf34348a76898ed37f931d27 (diff) |
sd-device: get_subsystem - don't complain if a device does not have a subsystem
Diffstat (limited to 'src')
-rw-r--r-- | src/libelogind/sd-device/sd-device.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libelogind/sd-device/sd-device.c b/src/libelogind/sd-device/sd-device.c index 97da4a8ee..af8137b1a 100644 --- a/src/libelogind/sd-device/sd-device.c +++ b/src/libelogind/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; |