From 5eb83e9000413a0d1344476d44596397f57963b0 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 21 Jul 2022 14:15:20 +0900 Subject: [PATCH] sd-device: introduce device_clear_sysattr_cache() --- src/libsystemd/sd-device/device-private.h | 1 + src/libsystemd/sd-device/sd-device.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h index 93c1d20a01e..3d670a3afcc 100644 --- a/src/libsystemd/sd-device/device-private.h +++ b/src/libsystemd/sd-device/device-private.h @@ -26,6 +26,7 @@ int device_get_devnode_mode(sd_device *device, mode_t *ret); int device_get_devnode_uid(sd_device *device, uid_t *ret); int device_get_devnode_gid(sd_device *device, gid_t *ret); +void device_clear_sysattr_cache(sd_device *device); int device_cache_sysattr_value(sd_device *device, const char *key, char *value); int device_get_cached_sysattr_value(sd_device *device, const char *key, const char **ret_value); diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 6c034626e7f..3e31beb1f2b 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -2044,6 +2044,10 @@ _public_ int sd_device_get_trigger_uuid(sd_device *device, sd_id128_t *ret) { return 0; } +void device_clear_sysattr_cache(sd_device *device) { + device->sysattr_values = hashmap_free(device->sysattr_values); +} + int device_cache_sysattr_value(sd_device *device, const char *key, char *value) { _unused_ _cleanup_free_ char *old_value = NULL; _cleanup_free_ char *new_key = NULL; -- 2.47.3