]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc_setup_fs: Create /dev/shm folder if it doesn't exist
authorBogdan Purcareata <bogdan.purcareata@nxp.com>
Fri, 8 Jan 2016 15:38:44 +0000 (15:38 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 28 Jan 2016 10:58:57 +0000 (11:58 +0100)
When running application containers with lxc-execute, /dev is
populated only with device entries. Since /dev is a tmpfs mount in
the container environment, the /dev/shm folder not being present is not
a sufficient reason for the /dev/shm mount to fail.

Create the /dev/shm directory if not present.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/initutils.c

index 45df60f6c4cc5ef5a46c837976c4dbc63e84f2f5..8d9016cd01c7b442b061dbcacbc99d61bf304e2b 100644 (file)
@@ -47,6 +47,10 @@ extern void lxc_setup_fs(void)
        if (mount_fs("proc", "/proc", "proc"))
                INFO("failed to remount proc");
 
+       /* if /dev has been populated by us, /dev/shm does not exist */
+       if (access("/dev/shm", F_OK) && mkdir("/dev/shm", 0777))
+               INFO("failed to create /dev/shm");
+
        /* if we can't mount /dev/shm, continue anyway */
        if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
                INFO("failed to mount /dev/shm");