summaryrefslogtreecommitdiff
path: root/src/readahead-common.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-09-26 15:50:14 +0200
committerLennart Poettering <lennart@poettering.net>2010-09-26 15:50:14 +0200
commit6624768c9c39ab409edebe07cb06ecd93cc6f3ed (patch)
tree977498358b71fcf0bd9c3f8623e9c42d58d72d72 /src/readahead-common.c
parentf0cf061eda90f60730dbb222675e48d11e8cf757 (diff)
readahead: add interface to sd-daemon.[ch] to control readahead
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;
+}