From: Christian Brauner Date: Sun, 22 Jul 2018 13:44:05 +0000 (+0200) Subject: start: coding style fixes X-Git-Tag: lxc-3.1.0~195^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea0e06dd74b2baf5f3830531887c734dd16756e5;p=thirdparty%2Flxc.git start: coding style fixes Signed-off-by: Christian Brauner --- diff --git a/src/lxc/start.c b/src/lxc/start.c index b528a85c5..62e89f741 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -1529,30 +1529,33 @@ static inline int do_share_ns(void *arg) return 0; } -static int lxc_setup_shmount(struct lxc_conf *conf) { +static int lxc_setup_shmount(struct lxc_conf *conf) +{ size_t len_cont; char *full_cont_path; int ret = -1; - /* Construct the shmount path under the container root */ - /* +1 for slash */ + /* Construct the shmount path under the container root. */ len_cont = strlen(conf->rootfs.mount) + 1 + strlen(conf->shmount.path_cont); /* +1 for the terminating '\0' */ full_cont_path = malloc(len_cont + 1); - if(!full_cont_path) { + if (!full_cont_path) { SYSERROR("Not enough memory"); return -ENOMEM; } - ret = snprintf(full_cont_path, len_cont + 1, "%s/%s", conf->rootfs.mount, conf->shmount.path_cont); + + ret = snprintf(full_cont_path, len_cont + 1, "%s/%s", + conf->rootfs.mount, conf->shmount.path_cont); if (ret < 0 || ret >= len_cont + 1) { SYSERROR("Failed to create filename"); free(full_cont_path); return -1; } - /* Check if shmount point is already set up */ + /* Check if shmount point is already set up. */ if (is_shared_mountpoint(conf->shmount.path_host)) { - INFO("Path \"%s\" is already MS_SHARED. Reusing", conf->shmount.path_host); + INFO("Path \"%s\" is already MS_SHARED. Reusing", + conf->shmount.path_host); free(full_cont_path); return 0; } @@ -1560,7 +1563,8 @@ static int lxc_setup_shmount(struct lxc_conf *conf) { /* Create host and cont mount paths */ ret = mkdir_p(conf->shmount.path_host, 0711); if (ret < 0 && errno != EEXIST) { - SYSERROR("Failed to create directory \"%s\"", conf->shmount.path_host); + SYSERROR("Failed to create directory \"%s\"", + conf->shmount.path_host); free(full_cont_path); return ret; } @@ -1573,22 +1577,23 @@ static int lxc_setup_shmount(struct lxc_conf *conf) { } /* Prepare host mountpoint */ - ret = mount("tmpfs", conf->shmount.path_host, "tmpfs", - 0, "size=100k,mode=0711"); + ret = mount("tmpfs", conf->shmount.path_host, "tmpfs", 0, + "size=100k,mode=0711"); if (ret < 0) { SYSERROR("Failed to mount \"%s\"", conf->shmount.path_host); free(full_cont_path); return ret; } + ret = mount(conf->shmount.path_host, conf->shmount.path_host, "none", - MS_REC | MS_SHARED, ""); + MS_REC | MS_SHARED, ""); if (ret < 0) { SYSERROR("Failed to make shared \"%s\"", conf->shmount.path_host); free(full_cont_path); return ret; } - INFO("Made shared mount point \"%s\"", conf->shmount.path_host); + INFO("Setup shared mount point \"%s\"", conf->shmount.path_host); free(full_cont_path); return 0; } @@ -1670,12 +1675,12 @@ static int lxc_spawn(struct lxc_handler *handler) } } - if (conf->shmount.path_host && !conf->shmount.path_cont) { - ERROR("Missing the container side path to the shared mount point"); + if (conf->shmount.path_host) { + if (!conf->shmount.path_cont) { lxc_sync_fini(handler); return -1; - } - if (conf->shmount.path_host) { + } + ret = lxc_setup_shmount(conf); if (ret < 0) { ERROR("Failed to setup shared mount point");