{
int ret;
struct lxc_storage *bdev;
- const struct lxc_rootfs *rootfs = &conf->rootfs;
+ struct lxc_rootfs *rootfs = &conf->rootfs;
if (!rootfs->path) {
ret = mount("", "/", NULL, MS_SLAVE | MS_REC, 0);
if (ret < 0)
return log_error_errno(-1, errno, "Failed to recursively turn root mount tree into dependent mount");
+ rootfs->mntpt_fd = openat(-1, "/", O_RDONLY | O_CLOEXEC | O_DIRECTORY | O_PATH);
+ if (rootfs->mntpt_fd < 0)
+ return -errno;
+
return 0;
}
rootfs->path, rootfs->mount,
rootfs->options ? rootfs->options : "(null)");
+ rootfs->mntpt_fd = openat(-1, rootfs->mount, O_RDONLY | O_CLOEXEC | O_DIRECTORY | O_PATH);
+ if (rootfs->mntpt_fd < 0)
+ return -errno;
+
return 0;
}
return NULL;
}
new->rootfs.managed = true;
+ new->rootfs.mntpt_fd = -EBADF;
new->logfd = -1;
lxc_list_init(&new->cgroup);
lxc_list_init(&new->cgroup2);
return log_error(-1, "Failed to drop capabilities");
}
+ close_prot_errno_disarm(lxc_conf->rootfs.mntpt_fd);
NOTICE("The container \"%s\" is set up", name);
return 0;
free(conf->rootfs.options);
free(conf->rootfs.path);
free(conf->rootfs.data);
+ close_prot_errno_disarm(conf->rootfs.mntpt_fd);
free(conf->logfile);
if (conf->logfd != -1)
close(conf->logfd);
* @mountflags : the portion of @options that are flags
* @data : the portion of @options that are not flags
* @managed : whether it is managed by LXC
+ * @mntpt_fd : fd for @mount
*/
struct lxc_rootfs {
+ int mntpt_fd;
char *path;
char *mount;
char *bdev_type;