summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-device/sd-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-device/sd-device.c')
-rw-r--r--src/libsystemd/sd-device/sd-device.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index 991779aa9c..dad87f39c9 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -1894,12 +1894,16 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
path = prefix_roota(syspath, sysattr);
r = lstat(path, &statbuf);
if (r < 0) {
+ int k;
+
/* remember that we could not access the sysattr */
- r = device_cache_sysattr_value(device, sysattr, NULL);
- if (r < 0)
- return r;
+ k = device_cache_sysattr_value(device, sysattr, NULL);
+ if (k < 0)
+ log_device_debug_errno(device, k,
+ "sd-device: failed to cache attribute '%s' with NULL, ignoring: %m",
+ sysattr);
- return -ENOENT;
+ return r;
} else if (S_ISLNK(statbuf.st_mode)) {
/* Some core links return only the last element of the target path,
* these are just values, the paths should not be exposed. */
@@ -1925,11 +1929,16 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
delete_trailing_chars(value, "\n");
}
+ /* Unfortunately, we need to return 'const char*' instead of 'char*'. Hence, failure in caching
+ * sysattr value is critical unlike the other places. */
r = device_cache_sysattr_value(device, sysattr, value);
- if (r < 0)
- return r;
-
- if (ret_value)
+ if (r < 0) {
+ log_device_debug_errno(device, r,
+ "sd-device: failed to cache attribute '%s' with '%s'%s: %m",
+ sysattr, value, ret_value ? "" : ", ignoring");
+ if (ret_value)
+ return r;
+ } else if (ret_value)
*ret_value = TAKE_PTR(value);
return 0;
@@ -1990,8 +1999,11 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr,
r = device_cache_sysattr_value(device, sysattr, value);
if (r < 0)
- return r;
- TAKE_PTR(value);
+ log_device_debug_errno(device, r,
+ "sd-device: failed to cache attribute '%s' with '%s', ignoring: %m",
+ sysattr, value);
+ else
+ TAKE_PTR(value);
return 0;
}