X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibudev%2Flibudev-device.c;h=26993740728268fbf3e02d09685f87315d563f50;hb=7491ccf2cb237a2a88b831b2c7374ba2bb255cba;hp=f26a4c44b559c55cffff79330dc4e5ce5af085cf;hpb=aa0e72ea54aaa9a0e7badfb3593cbf7e6e303345;p=elogind.git diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index f26a4c44b..269937407 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -161,7 +161,7 @@ _public_ dev_t udev_device_get_devnum(struct udev_device *udev_device) return udev_device->devnum; } -static int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum) +int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum) { char num[32]; @@ -1732,9 +1732,14 @@ void udev_device_set_is_initialized(struct udev_device *udev_device) udev_device->is_initialized = true; } +static bool is_valid_tag(const char *tag) +{ + return !strchr(tag, ':') && !strchr(tag, ' '); +} + int udev_device_add_tag(struct udev_device *udev_device, const char *tag) { - if (strchr(tag, ':') != NULL || strchr(tag, ' ') != NULL) + if (!is_valid_tag(tag)) return -EINVAL; udev_device->tags_uptodate = false; if (udev_list_entry_add(&udev_device->tags_list, tag, NULL) != NULL) @@ -1742,6 +1747,20 @@ int udev_device_add_tag(struct udev_device *udev_device, const char *tag) return -ENOMEM; } +void udev_device_remove_tag(struct udev_device *udev_device, const char *tag) +{ + struct udev_list_entry *e; + + if (!is_valid_tag(tag)) + return; + e = udev_list_get_entry(&udev_device->tags_list); + e = udev_list_entry_get_by_name(e, tag); + if (e) { + udev_device->tags_uptodate = false; + udev_list_entry_delete(e); + } +} + void udev_device_cleanup_tags_list(struct udev_device *udev_device) { udev_device->tags_uptodate = false;