util: introduce device_for_action()

It will be used in later commits.
This commit is contained in:
Yu Watanabe
2019-03-12 03:49:53 +09:00
parent 5ebd3fc3c1
commit a707c65b70
2 changed files with 13 additions and 0 deletions
+11
View File
@@ -181,3 +181,14 @@ int device_is_renaming(sd_device *dev) {
return r >= 0;
}
bool device_for_action(sd_device *dev, DeviceAction action) {
DeviceAction a;
assert(dev);
if (device_get_action(dev, &a) < 0)
return false;
return a == action;
}
+2
View File
@@ -3,6 +3,7 @@
#include "sd-device.h"
#include "device-private.h"
#include "time-util.h"
typedef enum ResolveNameTiming {
@@ -28,3 +29,4 @@ static inline int udev_parse_config(void) {
int device_wait_for_initialization(sd_device *device, const char *subsystem, sd_device **ret);
int device_is_renaming(sd_device *dev);
bool device_for_action(sd_device *dev, DeviceAction action);