diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2010-12-14 14:18:32 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2010-12-14 14:18:32 +0100 |
commit | 48a0170b111b55e961be769d2cc4890511bcd991 (patch) | |
tree | 45cc479d03b844d778217523e30dd962daf04076 /libudev/libudev-device.c | |
parent | ff0e1f4e5d897a0ddbf365e920c0e28a6657abaa (diff) |
libudev: enumerate - allow to filter-out not-already-initialized devices
Diffstat (limited to 'libudev/libudev-device.c')
-rw-r--r-- | libudev/libudev-device.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c index 8b0cccd533..66f806316f 100644 --- a/libudev/libudev-device.c +++ b/libudev/libudev-device.c @@ -81,6 +81,7 @@ struct udev_device { bool info_loaded; bool db_loaded; bool uevent_loaded; + bool is_initialized; }; struct udev_list_entry *udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value) @@ -249,6 +250,7 @@ int udev_device_read_db(struct udev_device *udev_device) info(udev_device->udev, "no db file to read %s: %m\n", filename); return -1; } + udev_device->is_initialized = true; while (fgets(line, sizeof(line), f)) { ssize_t len; @@ -1308,6 +1310,31 @@ const char *udev_device_get_id_filename(struct udev_device *udev_device) return udev_device->id_filename; } +/** + * udev_device_get_is_initialized: + * @udev_device: udev device + * + * Check if udev has already handled the device and has set up + * device node permissions and context, or has renamed a network + * device. + * + * For now, this is only implemented for devices with a device node + * or network interfaces. All other devices return 1 here. + * + * Returns: 1 if the device is set up. 0 otherwise. + **/ +int udev_device_get_is_initialized(struct udev_device *udev_device) +{ + if (!udev_device->info_loaded) + udev_device_read_db(udev_device); + return udev_device->is_initialized; +} + +void udev_device_set_is_initialized(struct udev_device *udev_device) +{ + udev_device->is_initialized = true; +} + int udev_device_add_tag(struct udev_device *udev_device, const char *tag) { if (strchr(tag, ':') != NULL || strchr(tag, ' ') != NULL) |