chiark / gitweb /
uaccess: become a nop when not run on a systemd system
[elogind.git] / src / readahead-common.c
index e991dfd05d69d130e4aee283acfa83a257b95c8b..f0d57b4c6e49c1192dfe50b6fc57014ab893bbd5 100644 (file)
@@ -154,9 +154,8 @@ bool enough_ram(void) {
 
         assert_se(sysinfo(&si) >= 0);
 
-        return si.totalram > 127 * 1024*1024; /* Enable readahead only
-                                               * with at least 128MB
-                                               * memory */
+        /* Enable readahead only with at least 128MB memory */
+        return si.totalram > 127 * 1024*1024 / si.mem_unit;
 }
 
 int open_inotify(void) {
@@ -167,11 +166,11 @@ int open_inotify(void) {
                 return -errno;
         }
 
-        mkdir("/dev/.systemd", 0755);
-        mkdir("/dev/.systemd/readahead", 0755);
+        mkdir("/run/systemd", 0755);
+        mkdir("/run/systemd/readahead", 0755);
 
-        if (inotify_add_watch(fd, "/dev/.systemd/readahead", IN_CREATE) < 0) {
-                log_error("Failed to watch /dev/.systemd/readahead: %m");
+        if (inotify_add_watch(fd, "/run/systemd/readahead", IN_CREATE) < 0) {
+                log_error("Failed to watch /run/systemd/readahead: %m");
                 close_nointr_nofail(fd);
                 return -errno;
         }
@@ -183,10 +182,10 @@ ReadaheadShared *shared_get(void) {
         int fd;
         ReadaheadShared *m = NULL;
 
-        mkdir("/dev/.systemd", 0755);
-        mkdir("/dev/.systemd/readahead", 0755);
+        mkdir("/run/systemd", 0755);
+        mkdir("/run/systemd/readahead", 0755);
 
-        if ((fd = open("/dev/.systemd/readahead/shared", O_CREAT|O_RDWR|O_CLOEXEC, 0644)) < 0) {
+        if ((fd = open("/run/systemd/readahead/shared", O_CREAT|O_RDWR|O_CLOEXEC, 0644)) < 0) {
                 log_error("Failed to create shared memory segment: %m");
                 goto finish;
         }
@@ -209,7 +208,6 @@ finish:
         return m;
 }
 
-
 #define BUMP_REQUEST_NR (16*1024)
 
 int bump_request_nr(const char *p) {