teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0020-sd-device-introduce-device_has_devlink.patch

4295f9
From 76aebe6fec5894b05114fdf1e8aee54139bef69e Mon Sep 17 00:00:00 2001
4295f9
From: Yu Watanabe <watanabe.yu+github@gmail.com>
4295f9
Date: Wed, 1 Sep 2021 09:22:15 +0900
4295f9
Subject: [PATCH] sd-device: introduce device_has_devlink()
4295f9
4295f9
(cherry picked from commit b881ce16b9ccae4c3089c82e2ea1781cd9773a4f)
4295f9
4295f9
Related: #1977994
4295f9
---
4295f9
 src/libsystemd/sd-device/device-private.h | 1 +
4295f9
 src/libsystemd/sd-device/sd-device.c      | 7 +++++++
4295f9
 2 files changed, 8 insertions(+)
4295f9
4295f9
diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h
4295f9
index fe268d7f2f..9bb5eff208 100644
4295f9
--- a/src/libsystemd/sd-device/device-private.h
4295f9
+++ b/src/libsystemd/sd-device/device-private.h
4295f9
@@ -32,6 +32,7 @@ void device_set_db_persist(sd_device *device);
4295f9
 void device_set_devlink_priority(sd_device *device, int priority);
4295f9
 int device_ensure_usec_initialized(sd_device *device, sd_device *device_old);
4295f9
 int device_add_devlink(sd_device *device, const char *devlink);
4295f9
+bool device_has_devlink(sd_device *device, const char *devlink);
4295f9
 int device_add_property(sd_device *device, const char *property, const char *value);
4295f9
 int device_add_tag(sd_device *device, const char *tag, bool both);
4295f9
 void device_remove_tag(sd_device *device, const char *tag);
4295f9
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
4295f9
index 388128bf33..8a9e4a33a1 100644
4295f9
--- a/src/libsystemd/sd-device/sd-device.c
4295f9
+++ b/src/libsystemd/sd-device/sd-device.c
4295f9
@@ -1193,6 +1193,13 @@ int device_add_devlink(sd_device *device, const char *devlink) {
4295f9
         return 0;
4295f9
 }
4295f9
 
4295f9
+bool device_has_devlink(sd_device *device, const char *devlink) {
4295f9
+        assert(device);
4295f9
+        assert(devlink);
4295f9
+
4295f9
+        return set_contains(device->devlinks, devlink);
4295f9
+}
4295f9
+
4295f9
 static int device_add_property_internal_from_string(sd_device *device, const char *str) {
4295f9
         _cleanup_free_ char *key = NULL;
4295f9
         char *value;