mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 17:12:14 +00:00
Mount bind the rootfs directory
From: Daniel Lezcano <daniel.lezcano@free.fr> Instead of using a symlink to the rootfs, just mount bind the rootfs directory. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
c952d1b915
commit
9b0f04774f
@ -454,7 +454,10 @@ static int configure_rootfs(const char *name, const char *rootfs)
|
||||
{
|
||||
char path[MAXPATHLEN];
|
||||
char absrootfs[MAXPATHLEN];
|
||||
char fstab[MAXPATHLEN];
|
||||
char *pwd;
|
||||
int ret;
|
||||
FILE *f;
|
||||
|
||||
snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);
|
||||
|
||||
@ -469,6 +472,29 @@ static int configure_rootfs(const char *name, const char *rootfs)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mkdir(path, 0755)) {
|
||||
lxc_log_syserror("failed to create the '%s' directory", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(fstab, MAXPATHLEN, LXCPATH "/%s/fstab", name);
|
||||
|
||||
f = fopen(fstab, "a+");
|
||||
if (!f) {
|
||||
lxc_log_syserror("failed to open fstab file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fprintf(f, "%s %s none bind 0 0\n", absrootfs, path);
|
||||
fclose(f);
|
||||
|
||||
if (ret < 0) {
|
||||
lxc_log_syserror("failed to add rootfs mount in fstab");
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs/rootfs", name);
|
||||
|
||||
return symlink(absrootfs, path);
|
||||
}
|
||||
|
||||
@ -641,8 +667,14 @@ static int unconfigure_rootfs(const char *name)
|
||||
{
|
||||
char path[MAXPATHLEN];
|
||||
|
||||
snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);
|
||||
snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);
|
||||
|
||||
#warning deprecated code to be removed in the next version
|
||||
|
||||
/* ugly but for backward compatibily, */
|
||||
delete_info(path, "rootfs");
|
||||
rmdir(path);
|
||||
unlink(path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1202,16 +1234,16 @@ int lxc_configure(const char *name, struct lxc_conf *conf)
|
||||
return -LXC_ERROR_CONF_TTY;
|
||||
}
|
||||
|
||||
if (conf->rootfs && configure_rootfs(name, conf->rootfs)) {
|
||||
lxc_log_error("failed to configure the rootfs");
|
||||
return -LXC_ERROR_CONF_ROOTFS;
|
||||
}
|
||||
|
||||
if (conf->fstab && configure_mount(name, conf->fstab)) {
|
||||
lxc_log_error("failed to configure the mount points");
|
||||
return -LXC_ERROR_CONF_MOUNT;
|
||||
}
|
||||
|
||||
if (conf->rootfs && configure_rootfs(name, conf->rootfs)) {
|
||||
lxc_log_error("failed to configure the rootfs");
|
||||
return -LXC_ERROR_CONF_ROOTFS;
|
||||
}
|
||||
|
||||
if (conf->pts && configure_pts(name, conf->pts)) {
|
||||
lxc_log_error("failed to configure a new pts instance");
|
||||
return -LXC_ERROR_CONF_PTS;
|
||||
@ -1550,12 +1582,6 @@ int lxc_create_tty(const char *name, struct lxc_tty_info *tty_info)
|
||||
if (!conf_has_tty(name))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
if (!conf_has_rootfs(name)) {
|
||||
lxc_log_warning("no rootfs is configured, ignoring ttys");
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);
|
||||
|
||||
if (read_info(path, "tty", tty, sizeof(tty)) < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user