procd: replace exit(-1) with exit(EXIT_FAILURE)
[project/procd.git] / initd / zram.c
index d438372469451fa3a8c7794435e1a6e8beacf19f..380fe0ea75cfd134232c64706449d5448170bcf8 100644 (file)
@@ -12,6 +12,7 @@
 #include <sys/stat.h>
 
 #include "../log.h"
+#include "../container.h"
 
 #include "init.h"
 
@@ -64,12 +65,12 @@ early_insmod(char *module)
                sprintf(path, module, ver.release);
                modprobe[1] = path;
                execvp(modprobe[0], modprobe);
-               ERROR("Can't exec %s\n", modprobe[0]);
-               exit(-1);
+               ERROR("Can't exec %s: %m\n", modprobe[0]);
+               exit(EXIT_FAILURE);
        }
 
        if (pid <= 0) {
-               ERROR("Can't exec %s\n", modprobe[0]);
+               ERROR("Can't exec %s: %m\n", modprobe[0]);
                return -1;
        } else {
                waitpid(pid, NULL, 0);
@@ -107,19 +108,21 @@ mount_zram_on_tmp(void)
        pid = fork();
        if (!pid) {
                execvp(mkfs[0], mkfs);
-               ERROR("Can't exec %s\n", mkfs[0]);
-               exit(-1);
+               ERROR("Can't exec %s: %m\n", mkfs[0]);
+               exit(EXIT_FAILURE);
        } else if (pid <= 0) {
-               ERROR("Can't exec %s\n", mkfs[0]);
+               ERROR("Can't exec %s: %m\n", mkfs[0]);
                return -1;
        } else {
                waitpid(pid, NULL, 0);
        }
 
-       ret = mount("/dev/zram0", "/tmp", "ext4", MS_NOSUID | MS_NODEV | MS_NOATIME, "errors=continue,noquota");
-       if (ret < 0) {
-               ERROR("Can't mount /dev/zram0 on /tmp: %m\n");
-               return errno;
+       if (!is_container()) {
+               ret = mount("/dev/zram0", "/tmp", "ext4", MS_NOSUID | MS_NODEV | MS_NOATIME, "errors=continue,noquota");
+               if (ret < 0) {
+                       ERROR("Can't mount /dev/zram0 on /tmp: %m\n");
+                       return errno;
+               }
        }
 
        LOG("Using up to %ld kB of RAM as ZRAM storage on /mnt\n", zramsize);