]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc: move setup_fs to utils.c
authorMichel Normand <normand@fr.ibm.com>
Tue, 17 Nov 2009 21:57:46 +0000 (22:57 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 17 Nov 2009 21:57:46 +0000 (22:57 +0100)
This is not required immidiately but may be used by other init.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc_init.c
src/lxc/utils.c
src/lxc/utils.h

index 191f7c4da4ad97794f6e24d34f3b70a51f727136..0230d75fb4aae862866156b4f0b3835ec211e88f 100644 (file)
@@ -30,7 +30,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <sys/mount.h>
 #define _GNU_SOURCE
 #include <getopt.h>
 
@@ -52,42 +51,6 @@ static struct option options[] = {
        { 0, 0, 0, 0 },
 };
 
-static int mount_fs(const char *source, const char *target, const char *type)
-{
-       /* the umount may fail */
-       if (umount(target))
-               WARN("failed to unmount %s : %s", target, strerror(errno));
-
-       if (mount(source, target, type, 0, NULL)) {
-               ERROR("failed to mount %s : %s", target, strerror(errno));
-               return -1;
-       }
-
-       DEBUG("'%s' mounted on '%s'", source, target);
-
-       return 0;
-}
-
-static inline int setup_fs(void)
-{
-       if (mount_fs("proc", "/proc", "proc"))
-               return -1;
-
-       if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
-               return -1;
-
-       /* If we were able to mount /dev/shm, then /dev exists */
-       if (access("/dev/mqueue", F_OK) && mkdir("/dev/mqueue", 0666)) {
-               SYSERROR("failed to create '/dev/mqueue'");
-               return -1;
-       }
-
-       if (mount_fs("mqueue", "/dev/mqueue", "mqueue"))
-               return -1;
-
-       return 0;
-}
-
 int main(int argc, char *argv[])
 {
        pid_t pid;
@@ -127,7 +90,7 @@ int main(int argc, char *argv[])
 
        if (!pid) {
                
-               if (setup_fs())
+               if (lxc_setup_fs())
                        exit(err);
 
                NOTICE("about to exec '%s'", aargv[0]);
@@ -171,3 +134,4 @@ int main(int argc, char *argv[])
 out:
        return err;
 }
+
index 492c885f25a99928b4a18a5b68b06d885485aa15..f9477a34780687311d3c39cce1d5b860de72b49d 100644 (file)
@@ -30,6 +30,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/param.h>
+#include <sys/mount.h>
 #include <dirent.h>
 #include <fcntl.h>
 
@@ -233,3 +234,39 @@ again:
 
        return 0;
 }
+
+static int mount_fs(const char *source, const char *target, const char *type)
+{
+       /* the umount may fail */
+       if (umount(target))
+               WARN("failed to unmount %s : %s", target, strerror(errno));
+
+       if (mount(source, target, type, 0, NULL)) {
+               ERROR("failed to mount %s : %s", target, strerror(errno));
+               return -1;
+       }
+
+       DEBUG("'%s' mounted on '%s'", source, target);
+
+       return 0;
+}
+
+extern int lxc_setup_fs(void)
+{
+       if (mount_fs("proc", "/proc", "proc"))
+               return -1;
+
+       if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
+               return -1;
+
+       /* If we were able to mount /dev/shm, then /dev exists */
+       if (access("/dev/mqueue", F_OK) && mkdir("/dev/mqueue", 0666)) {
+               SYSERROR("failed to create '/dev/mqueue'");
+               return -1;
+       }
+
+       if (mount_fs("mqueue", "/dev/mqueue", "mqueue"))
+               return -1;
+
+       return 0;
+}
index c0c47d0058a87315b7376b1a9d55434e03ce96ac..cb4e6a0bbcbc775825a2c4244056b5680861d7af 100644 (file)
@@ -53,3 +53,4 @@
 extern int lxc_copy_file(const char *src, const char *dst);
 extern int lxc_close_inherited_fd(int fd);
 extern int lxc_close_all_inherited_fd(void);
+extern int lxc_setup_fs(void);