From: Kay Sievers Date: Sun, 30 Aug 2009 18:42:06 +0000 (+0200) Subject: inotify_add_watch(): do not store watch, if it failed X-Git-Tag: 174~805 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=ebc1ba78edd35a5973f2671a80a71639f5949212 inotify_add_watch(): do not store watch, if it failed On Sun, Aug 30, 2009 at 04:36, Marco d'Itri wrote: > inotify_add_watch may fail in udev_watch_begin, and then a link with > name -1 is created. > I do not know why, but it happened once on my system: > > lrwxrwxrwx 1 root root 27 Aug 4 11:27 -1 -> /devices/virtual/block/ram8 --- diff --git a/udev/udev-watch.c b/udev/udev-watch.c index 5a49c963d..102e16f81 100644 --- a/udev/udev-watch.c +++ b/udev/udev-watch.c @@ -121,6 +121,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) if (wd < 0) { err(udev, "inotify_add_watch(%d, %s, %o) failed: %m\n", inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE); + return; } snprintf(filename, sizeof(filename), "%s/.udev/watch/%d", udev_get_dev_path(udev), wd);