int ret = -1, offset = 1;
/* +1 for the separating whitespace */
- len_mount = strlen(conf->lxc_shmount.path_host) + 1
- + strlen(conf->lxc_shmount.path_cont) - offset
+ len_mount = strlen(conf->shmount.path_host) + 1
+ + strlen(conf->shmount.path_cont) - offset
+ sizeof(" none bind,create=dir 0 0") - 1;
ret = snprintf(new_mount, len_mount + 1, "%s %s none bind,create=dir 0 0",
- conf->lxc_shmount.path_host, conf->lxc_shmount.path_cont + offset);
+ conf->shmount.path_host, conf->shmount.path_cont + offset);
if (ret < 0 || (size_t)ret >= len_mount + 1)
return -1;
new->lsm_aa_profile = NULL;
new->lsm_se_context = NULL;
new->tmp_umount_proc = false;
- new->lxc_shmount.path_host = NULL;
- new->lxc_shmount.path_cont = NULL;
+ new->tmp_umount_proc = 0;
+ new->shmount.path_host = NULL;
+ new->shmount.path_cont = NULL;
/* if running in a new user namespace, init and COMMAND
* default to running as UID/GID 0 when using lxc-execute */
lxc_clear_procs(conf, "lxc.proc");
free(conf->cgroup_meta.dir);
free(conf->cgroup_meta.controllers);
- free(conf->lxc_shmount.path_host);
- free(conf->lxc_shmount.path_cont);
+ free(conf->shmount.path_host);
+ free(conf->shmount.path_cont);
free(conf);
}
/* procs */
struct lxc_list procs;
- struct lxc_shmount {
+ struct shmount {
/* Absolute path to the shared mount point on the host */
char *path_host;
/* Absolute path (in the container) to the shared mount point */
char *path_cont;
- } lxc_shmount;
+ } shmount;
};
extern int write_id_mapping(enum idtype idtype, pid_t pid, const char *buf,
lxc_conf->auto_mounts &= ~allowed_auto_mounts[i].mask;
lxc_conf->auto_mounts |= allowed_auto_mounts[i].flag;
if (is_shmounts) {
- lxc_conf->lxc_shmount.path_host = strdup(token + (sizeof("shmounts:") - 1));
- if (strcmp(lxc_conf->lxc_shmount.path_host, "") == 0) {
+ lxc_conf->shmount.path_host = strdup(token + (sizeof("shmounts:") - 1));
+ if (strcmp(lxc_conf->shmount.path_host, "") == 0) {
ERROR("Invalid shmounts path: empty");
break;
}
- lxc_conf->lxc_shmount.path_cont = strdup("/dev/.lxc-mounts");
+ lxc_conf->shmount.path_cont = strdup("/dev/.lxc-mounts");
}
}
return -EINVAL;
}
- if (!c->lxc_conf->lxc_shmount.path_host) {
+ if (!c->lxc_conf->shmount.path_host) {
ERROR("Host path to shared mountpoint must be specified in the config\n");
return -EINVAL;
}
- len = strlen(c->lxc_conf->lxc_shmount.path_host) + sizeof("/.lxcmount_XXXXXX") - 1;
+ len = strlen(c->lxc_conf->shmount.path_host) + sizeof("/.lxcmount_XXXXXX") - 1;
- ret = snprintf(template, len + 1, "%s/.lxcmount_XXXXXX", c->lxc_conf->lxc_shmount.path_host);
+ ret = snprintf(template, len + 1, "%s/.lxcmount_XXXXXX", c->lxc_conf->shmount.path_host);
if (ret < 0 || (size_t)ret >= len + 1) {
SYSERROR("Error writing shmounts tempdir name");
goto out;
if (!suff)
_exit(EXIT_FAILURE);
- len = strlen(c->lxc_conf->lxc_shmount.path_cont) + sizeof("/.lxcmount_XXXXXX") - 1;
- ret = snprintf(path, len + 1, "%s%s", c->lxc_conf->lxc_shmount.path_cont, suff);
+ len = strlen(c->lxc_conf->shmount.path_cont) + sizeof("/.lxcmount_XXXXXX") - 1;
+ ret = snprintf(path, len + 1, "%s%s", c->lxc_conf->shmount.path_cont, suff);
if (ret < 0 || (size_t)ret >= len + 1) {
SYSERROR("Error writing container mountpoint name");
_exit(EXIT_FAILURE);
unsigned long, const void *, struct lxc_mount *)
static int do_lxcapi_umount(struct lxc_container *c, const char *target,
- unsigned long mountflags, struct lxc_mount *mnt)
+ unsigned long flags, struct lxc_mount *mnt)
{
pid_t pid, init_pid;
int ret = -1;
}
/* Do the unmount */
- ret = umount2(target, mountflags);
+ ret = umount2(target, flags);
if (ret < 0) {
SYSERROR("Failed to umount \"%s\"", target);
_exit(EXIT_FAILURE);
/* Construct the shmount path under the container root */
/* +1 for slash */
- len_cont = strlen(conf->rootfs.mount) + 1 + strlen(conf->lxc_shmount.path_cont);
+ 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) {
SYSERROR("Not enough memory");
return -ENOMEM;
}
- ret = snprintf(full_cont_path, len_cont + 1, "%s/%s", conf->rootfs.mount, conf->lxc_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);
}
/* Check if shmount point is already set up */
- if (is_shared_mountpoint(conf->lxc_shmount.path_host)) {
- INFO("Path \"%s\" is already MS_SHARED. Reusing", conf->lxc_shmount.path_host);
+ if (is_shared_mountpoint(conf->shmount.path_host)) {
+ INFO("Path \"%s\" is already MS_SHARED. Reusing", conf->shmount.path_host);
free(full_cont_path);
return 0;
}
/* Create host and cont mount paths */
- ret = mkdir_p(conf->lxc_shmount.path_host, 0711);
+ ret = mkdir_p(conf->shmount.path_host, 0711);
if (ret < 0 && errno != EEXIST) {
- SYSERROR("Failed to create directory \"%s\"", conf->lxc_shmount.path_host);
+ SYSERROR("Failed to create directory \"%s\"", conf->shmount.path_host);
free(full_cont_path);
return ret;
}
}
/* Prepare host mountpoint */
- ret = mount("tmpfs", conf->lxc_shmount.path_host, "tmpfs",
+ ret = mount("tmpfs", conf->shmount.path_host, "tmpfs",
0, "size=100k,mode=0711");
if (ret < 0) {
- SYSERROR("Failed to mount \"%s\"", conf->lxc_shmount.path_host);
+ SYSERROR("Failed to mount \"%s\"", conf->shmount.path_host);
free(full_cont_path);
return ret;
}
- ret = mount(conf->lxc_shmount.path_host, conf->lxc_shmount.path_host, "none",
+ ret = mount(conf->shmount.path_host, conf->shmount.path_host, "none",
MS_REC | MS_SHARED, "");
if (ret < 0) {
- SYSERROR("Failed to make shared \"%s\"", conf->lxc_shmount.path_host);
+ SYSERROR("Failed to make shared \"%s\"", conf->shmount.path_host);
free(full_cont_path);
return ret;
}
- INFO("Made shared mount point \"%s\"", conf->lxc_shmount.path_host);
+ INFO("Made shared mount point \"%s\"", conf->shmount.path_host);
free(full_cont_path);
return 0;
}
}
}
- if (conf->lxc_shmount.path_host && !conf->lxc_shmount.path_cont) {
+ if (conf->shmount.path_host && !conf->shmount.path_cont) {
ERROR("Missing the container side path to the shared mount point");
lxc_sync_fini(handler);
return -1;
}
- if (conf->lxc_shmount.path_host) {
+ if (conf->shmount.path_host) {
ret = lxc_setup_shmount(conf);
if (ret < 0) {
ERROR("Failed to setup shared mount point");