chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Speed up udev_enumerate_scan_*
[elogind.git]
/
udev
/
udev-watch.c
diff --git
a/udev/udev-watch.c
b/udev/udev-watch.c
index 53492e5f357fd2fcb73128af2a95721fd55bd99b..d67083b51b3a67e3d14f9d2a7b6b4ef5113646a2 100644
(file)
--- a/
udev/udev-watch.c
+++ b/
udev/udev-watch.c
@@
-26,27
+26,22
@@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifdef HAVE_INOTIFY
#include <sys/inotify.h>
#include <sys/inotify.h>
-#endif
#include "udev.h"
#include "udev.h"
-int inotify_fd = -1;
+
static
int inotify_fd = -1;
/* inotify descriptor, will be shared with rules directory;
* set to cloexec since we need our children to be able to add
* watches for us
*/
/* inotify descriptor, will be shared with rules directory;
* set to cloexec since we need our children to be able to add
* watches for us
*/
-
void
udev_watch_init(struct udev *udev)
+
int
udev_watch_init(struct udev *udev)
{
{
- inotify_fd = inotify_init();
- if (inotify_fd >= 0)
- util_set_fd_cloexec(inotify_fd);
- else if (errno == ENOSYS)
- info(udev, "unable to use inotify, udevd will not monitor rule files changes\n");
- else
+ inotify_fd = inotify_init1(IN_CLOEXEC);
+ if (inotify_fd < 0)
err(udev, "inotify_init failed: %m\n");
err(udev, "inotify_init failed: %m\n");
+ return inotify_fd;
}
/* move any old watches directory out of the way, and then restore
}
/* move any old watches directory out of the way, and then restore
@@
-124,6
+119,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);
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);
}
snprintf(filename, sizeof(filename), "%s/.udev/watch/%d", udev_get_dev_path(udev), wd);