summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-device/device-enumerator.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-04-17 14:11:00 +0200
committerTom Gundersen <teg@jklm.no>2015-04-17 14:16:16 +0200
commitdee5e0b6c29ca22cbf67d28fbee195d70b0dde72 (patch)
tree9b168fad51bc28c0e12efcc4847eb5293eddad2e /src/libsystemd/sd-device/device-enumerator.c
parent19c9df44921bd4788bba608e9d0756f4fb1d5f89 (diff)
sd-device: enumerator - match only on initialized devices by default
It is still possible to include uninitialized ones, but now that is opt-in. In most cases people only want initialized devices. Exception is if you want to work without udev running. Suggested by David Herrmann.
Diffstat (limited to 'src/libsystemd/sd-device/device-enumerator.c')
-rw-r--r--src/libsystemd/sd-device/device-enumerator.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c
index eb637f5a57..49c44bc47b 100644
--- a/src/libsystemd/sd-device/device-enumerator.c
+++ b/src/libsystemd/sd-device/device-enumerator.c
@@ -52,7 +52,7 @@ struct sd_device_enumerator {
Set *match_sysname;
Set *match_tag;
sd_device *match_parent;
- bool match_is_initialized;
+ bool match_allow_uninitialized;
};
_public_ int sd_device_enumerator_new(sd_device_enumerator **ret) {
@@ -250,10 +250,20 @@ _public_ int sd_device_enumerator_add_match_parent(sd_device_enumerator *enumera
return 0;
}
-_public_ int sd_device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator) {
+_public_ int sd_device_enumerator_allow_uninitialized(sd_device_enumerator *enumerator) {
assert_return(enumerator, -EINVAL);
- enumerator->match_is_initialized = true;
+ enumerator->match_allow_uninitialized = true;
+
+ enumerator->scan_uptodate = false;
+
+ return 0;
+}
+
+int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator) {
+ assert_return(enumerator, -EINVAL);
+
+ enumerator->match_allow_uninitialized = false;
enumerator->scan_uptodate = false;
@@ -527,7 +537,7 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator,
* might not store a database, and have no way to find out
* for all other types of devices.
*/
- if (enumerator->match_is_initialized &&
+ if (!enumerator->match_allow_uninitialized &&
!initialized &&
(major(devnum) > 0 || ifindex > 0))
continue;