Skip to content

Commit

Permalink
Merge pull request #2194 from hallyn/2018-02-27/lxcinit-umountdev
Browse files Browse the repository at this point in the history
lxc_init: don't mount filesystems
  • Loading branch information
Christian Brauner committed Feb 27, 2018
2 parents 9e49a49 + 0011e09 commit d931b24
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
2 changes: 0 additions & 2 deletions src/lxc/cmd/lxc_init.c
Expand Up @@ -318,8 +318,6 @@ int main(int argc, char *argv[])
}
}

lxc_setup_fs();

remove_self();

pid = fork();
Expand Down
41 changes: 0 additions & 41 deletions src/lxc/initutils.c
Expand Up @@ -28,47 +28,6 @@

lxc_log_define(lxc_initutils, lxc);

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 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");

/* 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) && mkdir("/dev/mqueue", 0666)) {
DEBUG("Failed to create '/dev/mqueue'");
return;
}

/* continue even without posix message queue support */
if (mount_fs("mqueue", "/dev/mqueue", "mqueue"))
INFO("Failed to mount /dev/mqueue");
}

static char *copy_global_config_value(char *p)
{
int len = strlen(p);
Expand Down

0 comments on commit d931b24

Please sign in to comment.