summaryrefslogtreecommitdiff
path: root/src/readahead-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/readahead-common.c')
-rw-r--r--src/readahead-common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/readahead-common.c b/src/readahead-common.c
index a1016a3ede..a2f6f173e9 100644
--- a/src/readahead-common.c
+++ b/src/readahead-common.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/sysinfo.h>
+#include <sys/inotify.h>
#include "log.h"
#include "readahead-common.h"
@@ -116,3 +117,23 @@ bool enough_ram(void) {
* with at least 128MB
* memory */
}
+
+int open_inotify(void) {
+ int fd;
+
+ if ((fd = inotify_init1(IN_CLOEXEC|IN_NONBLOCK)) < 0) {
+ log_error("Failed to create inotify handle: %m");
+ return -errno;
+ }
+
+ mkdir("/dev/.systemd", 0755);
+ mkdir("/dev/.systemd/readahead", 0755);
+
+ if (inotify_add_watch(fd, "/dev/.systemd/readahead", IN_CREATE) < 0) {
+ log_error("Failed to watch /dev/.systemd/readahead: %m");
+ close_nointr_nofail(fd);
+ return -errno;
+ }
+
+ return fd;
+}