]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: introduce device_get_sysattr_bool()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 15 Jul 2022 00:08:10 +0000 (09:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Jul 2022 23:11:36 +0000 (08:11 +0900)
src/libsystemd/sd-device/device-private.h
src/libsystemd/sd-device/sd-device.c

index 9602f9eda3e5f4e83d556d5ffeddbb8a9834c271..93c1d20a01e60de060bd0e613ce1327e65d2e6fa 100644 (file)
@@ -18,6 +18,7 @@ static inline int device_new_from_watch_handle(sd_device **ret, int wd) {
 }
 
 int device_get_property_bool(sd_device *device, const char *key);
+int device_get_sysattr_bool(sd_device *device, const char *sysattr);
 int device_get_device_id(sd_device *device, const char **ret);
 int device_get_devlink_priority(sd_device *device, int *ret);
 int device_get_watch_handle(sd_device *device);
index a53f31e5ff73d9c15ccb947978e4ca1449e14d5e..6c034626e7f895d523fa69689c555d0c0f4acbcb 100644 (file)
@@ -2166,6 +2166,20 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
         return 0;
 }
 
+int device_get_sysattr_bool(sd_device *device, const char *sysattr) {
+        const char *value;
+        int r;
+
+        assert(device);
+        assert(sysattr);
+
+        r = sd_device_get_sysattr_value(device, sysattr, &value);
+        if (r < 0)
+                return r;
+
+        return parse_boolean(value);
+}
+
 static void device_remove_cached_sysattr_value(sd_device *device, const char *_key) {
         _cleanup_free_ char *key = NULL;