aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Normand <normand@fr.ibm.com>2009-11-17 22:57:46 +0100
committerDaniel Lezcano <dlezcano@fr.ibm.com>2009-11-17 22:57:46 +0100
commit6e4bb2e01f407fbecc7fc82496ac96065352a053 (patch)
treef24a87be197f8f8dd64d6417950404ce6398fc35
parentfix container find the previously created configuration (diff)
downloadlxc-6e4bb2e01f407fbecc7fc82496ac96065352a053.tar.gz
lxc-6e4bb2e01f407fbecc7fc82496ac96065352a053.tar.bz2
lxc-6e4bb2e01f407fbecc7fc82496ac96065352a053.zip
lxc: move setup_fs to utils.c
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>
-rw-r--r--src/lxc/lxc_init.c40
-rw-r--r--src/lxc/utils.c37
-rw-r--r--src/lxc/utils.h1
3 files changed, 40 insertions, 38 deletions
diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c
index 191f7c4..0230d75 100644
--- a/src/lxc/lxc_init.c
+++ b/src/lxc/lxc_init.c
@@ -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;
}
+
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index 492c885..f9477a3 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -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;
+}
diff --git a/src/lxc/utils.h b/src/lxc/utils.h
index c0c47d0..cb4e6a0 100644
--- a/src/lxc/utils.h
+++ b/src/lxc/utils.h
@@ -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);