]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-unshare: add missing declaration
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 23 Aug 2018 21:11:13 +0000 (23:11 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 23 Aug 2018 21:11:13 +0000 (23:11 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/initutils.h
src/lxc/tools/lxc_unshare.c

index ec44554e3cb6802a7e290b3527a732e2bca1991e..b815cd1943d1a534d5b05e0c35a169848f06be09 100644 (file)
@@ -68,7 +68,6 @@ struct prctl_mm_map {
 };
 #endif
 
-extern void lxc_setup_fs(void);
 extern const char *lxc_global_config_value(const char *option_name);
 
 /* open a file with O_CLOEXEC */
index 59b8461a9a691fd29464c87099f120dc3bccf4fe..9c38f537ffca02148eeaf58b2477c1e463b6b1a0 100644 (file)
@@ -104,6 +104,37 @@ struct start_arg {
        const char *want_hostname;
 };
 
+static int mount_fs(const char *source, const char *target, const char *type)
+{
+       /* the umount may fail */
+       if (umount(target) < 0)
+
+       if (mount(source, target, type, 0, NULL) < 0)
+               return -1;
+
+       return 0;
+}
+
+static void lxc_setup_fs(void)
+{
+       (void)mount_fs("proc", "/proc", "proc");
+
+       /* if /dev has been populated by us, /dev/shm does not exist */
+       if (access("/dev/shm", F_OK))
+               (void)mkdir("/dev/shm", 0777);
+
+       /* if we can't mount /dev/shm, continue anyway */
+       (void)mount_fs("shmfs", "/dev/shm", "tmpfs");
+
+       /* If we were able to mount /dev/shm, then /dev exists */
+       /* Sure, but it's read-only per config :) */
+       if (access("/dev/mqueue", F_OK))
+               (void)mkdir("/dev/mqueue", 0666);
+
+       /* continue even without posix message queue support */
+       (void)mount_fs("mqueue", "/dev/mqueue", "mqueue");
+}
+
 static int do_start(void *arg)
 {
        int ret;