X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev%2Flib%2Flibudev-device.c;h=2b6086d0325116aa67e678bc8cbe7c56810bd5c9;hb=4061ab9f4bb0bdad3858e8ef1738dc892afe9de4;hp=fc881fb3fdacf27c5d194de6da0825254bc96df8;hpb=affed87af1ad1a19a1baab3bfd2d271049f52e6c;p=elogind.git diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c index fc881fb3f..2b6086d03 100644 --- a/udev/lib/libudev-device.c +++ b/udev/lib/libudev-device.c @@ -3,18 +3,10 @@ * * Copyright (C) 2008 Kay Sievers * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. */ #include @@ -58,6 +50,7 @@ struct udev_device { int devlink_priority; int refcount; dev_t devnum; + int watch_handle; unsigned int parent_set:1; unsigned int subsystem_set:1; unsigned int devtype_set:1; @@ -176,6 +169,9 @@ int udev_device_read_db(struct udev_device *udev_device) case 'E': udev_device_add_property_from_string(udev_device, val); break; + case 'W': + udev_device_set_watch_handle(udev_device, atoi(val)); + break; } } fclose(f); @@ -251,6 +247,7 @@ struct udev_device *device_new(struct udev *udev) udev_list_init(&udev_device->properties_list); udev_list_init(&udev_device->sysattr_list); udev_device->event_timeout = -1; + udev_device->watch_handle = -1; /* copy global properties */ udev_list_entry_foreach(list_entry, udev_get_properties_list_entry(udev)) udev_device_add_property(udev_device, @@ -298,7 +295,7 @@ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char * /* path is not a root directory */ subdir = &syspath[len+1]; pos = strrchr(subdir, '/'); - if (pos == NULL || pos < &subdir[2]) { + if (pos == NULL || pos[1] == '\0' || pos < &subdir[2]) { dbg(udev, "not a subdir :%s\n", syspath); return NULL; } @@ -1291,3 +1288,16 @@ int udev_device_set_ignore_remove(struct udev_device *udev_device, int ignore) udev_device->ignore_remove = ignore; return 0; } + +int udev_device_get_watch_handle(struct udev_device *udev_device) +{ + if (!udev_device->info_loaded) + device_load_info(udev_device); + return udev_device->watch_handle; +} + +int udev_device_set_watch_handle(struct udev_device *udev_device, int handle) +{ + udev_device->watch_handle = handle; + return 0; +}