From f30a47c45e6f1415668d2bf3b91a8eaa7eb41029 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 3 Jan 2024 04:34:54 +0900 Subject: [PATCH] udev-util: introduce device_is_processing() helper function --- src/shared/udev-util.c | 12 ++++++++++++ src/shared/udev-util.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index 922364b0012..9acdaeff521 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -239,6 +239,18 @@ int device_is_renaming(sd_device *dev) { return r; } +int device_is_processing(sd_device *dev) { + int r; + + assert(dev); + + r = device_get_property_bool(dev, "ID_PROCESSING"); + if (r == -ENOENT) + return false; /* defaults to false */ + + return r; +} + bool device_for_action(sd_device *dev, sd_device_action_t a) { sd_device_action_t b; diff --git a/src/shared/udev-util.h b/src/shared/udev-util.h index 4d27bed1d94..13710a3ec1f 100644 --- a/src/shared/udev-util.h +++ b/src/shared/udev-util.h @@ -13,6 +13,7 @@ int udev_parse_config(void); int device_wait_for_initialization(sd_device *device, const char *subsystem, usec_t timeout_usec, sd_device **ret); int device_wait_for_devlink(const char *path, const char *subsystem, usec_t timeout_usec, sd_device **ret); int device_is_renaming(sd_device *dev); +int device_is_processing(sd_device *dev); bool device_for_action(sd_device *dev, sd_device_action_t action);