X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev%2Fudev-watch.c;h=dff3de1cb43e043939a40fc8d3809cc81de3fd62;hb=03733b04c3919920520c8b2ab1e18a44b2691cb5;hp=8d6cef6ac8103cdb9df7f53f1e3825117d5191db;hpb=9ce462721a02e38c15e4cdeff7dfc98eeb56224a;p=elogind.git diff --git a/udev/udev-watch.c b/udev/udev-watch.c index 8d6cef6ac..dff3de1cb 100644 --- a/udev/udev-watch.c +++ b/udev/udev-watch.c @@ -124,25 +124,12 @@ void udev_watch_restore(struct udev *udev) } } -static const char *udev_watch_filename(struct udev *udev, int wd) -{ - static char filename[UTIL_PATH_SIZE]; - char str[32]; - - sprintf(str, "%d", wd); - util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); - util_strlcat(filename, "/.udev/watch/", sizeof(filename)); - util_strlcat(filename, str, sizeof(filename)); - - return filename; -} - void udev_watch_begin(struct udev *udev, struct udev_device *dev) { - const char *filename; + char filename[UTIL_PATH_SIZE]; int wd; - if (inotify_fd < 0 || major(udev_device_get_devnum(dev)) == 0) + if (inotify_fd < 0) return; info(udev, "adding watch on '%s'\n", udev_device_get_devnode(dev)); @@ -152,21 +139,20 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); } - filename = udev_watch_filename(udev, wd); + snprintf(filename, sizeof(filename), "%s/.udev/watch/%d", udev_get_dev_path(udev), wd); util_create_path(udev, filename); unlink(filename); symlink(udev_device_get_syspath(dev), filename); udev_device_set_watch_handle(dev, wd); - udev_device_update_db(dev); } void udev_watch_end(struct udev *udev, struct udev_device *dev) { int wd; - const char *filename; + char filename[UTIL_PATH_SIZE]; - if (inotify_fd < 0 || major(udev_device_get_devnum(dev)) == 0) + if (inotify_fd < 0) return; wd = udev_device_get_watch_handle(dev); @@ -176,23 +162,22 @@ void udev_watch_end(struct udev *udev, struct udev_device *dev) info(udev, "removing watch on '%s'\n", udev_device_get_devnode(dev)); inotify_rm_watch(inotify_fd, wd); - filename = udev_watch_filename(udev, wd); + snprintf(filename, sizeof(filename), "%s/.udev/watch/%d", udev_get_dev_path(udev), wd); unlink(filename); udev_device_set_watch_handle(dev, -1); - udev_device_update_db(dev); } struct udev_device *udev_watch_lookup(struct udev *udev, int wd) { - const char *filename; + char filename[UTIL_PATH_SIZE]; char buf[UTIL_PATH_SIZE]; ssize_t len; if (inotify_fd < 0 || wd < 0) return NULL; - filename = udev_watch_filename(udev, wd); + snprintf(filename, sizeof(filename), "%s/.udev/watch/%d", udev_get_dev_path(udev), wd); len = readlink(filename, buf, sizeof(buf)); if (len > 0) { buf[len] = '\0';