57 lines
2.1 KiB
Diff
57 lines
2.1 KiB
Diff
From 284d6f9171ba819bcccb6a2df7c3012ba8483a0c Mon Sep 17 00:00:00 2001
|
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
Date: Mon, 9 Jan 2023 16:44:11 +0900
|
|
Subject: [PATCH] sd-device: introduce device_get_property_int()
|
|
|
|
(cherry picked from commit eedfef0f0d2654fcde2a3b694e62518d688af827)
|
|
|
|
Related: RHEL-5988
|
|
---
|
|
src/libsystemd/sd-device/device-private.h | 1 +
|
|
src/libsystemd/sd-device/sd-device.c | 20 ++++++++++++++++++++
|
|
2 files changed, 21 insertions(+)
|
|
|
|
diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h
|
|
index e57b74ba24..d9a519a4d9 100644
|
|
--- a/src/libsystemd/sd-device/device-private.h
|
|
+++ b/src/libsystemd/sd-device/device-private.h
|
|
@@ -18,6 +18,7 @@ int device_new_from_strv(sd_device **ret, char **strv);
|
|
int device_opendir(sd_device *device, const char *subdir, DIR **ret);
|
|
|
|
int device_get_property_bool(sd_device *device, const char *key);
|
|
+int device_get_property_int(sd_device *device, const char *key, int *ret);
|
|
int device_get_sysattr_int(sd_device *device, const char *sysattr, int *ret_value);
|
|
int device_get_sysattr_unsigned(sd_device *device, const char *sysattr, unsigned *ret_value);
|
|
int device_get_sysattr_bool(sd_device *device, const char *sysattr);
|
|
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
|
|
index c822a0b2f0..7ee67b4641 100644
|
|
--- a/src/libsystemd/sd-device/sd-device.c
|
|
+++ b/src/libsystemd/sd-device/sd-device.c
|
|
@@ -2186,6 +2186,26 @@ int device_get_property_bool(sd_device *device, const char *key) {
|
|
return parse_boolean(value);
|
|
}
|
|
|
|
+int device_get_property_int(sd_device *device, const char *key, int *ret) {
|
|
+ const char *value;
|
|
+ int r, v;
|
|
+
|
|
+ assert(device);
|
|
+ assert(key);
|
|
+
|
|
+ r = sd_device_get_property_value(device, key, &value);
|
|
+ if (r < 0)
|
|
+ return r;
|
|
+
|
|
+ r = safe_atoi(value, &v);
|
|
+ if (r < 0)
|
|
+ return r;
|
|
+
|
|
+ if (ret)
|
|
+ *ret = v;
|
|
+ return 0;
|
|
+}
|
|
+
|
|
_public_ int sd_device_get_trigger_uuid(sd_device *device, sd_id128_t *ret) {
|
|
const char *s;
|
|
sd_id128_t id;
|