1137
1137
static int mount_entry_on_absolute_rootfs(struct mntent *mntent,
1138
const struct lxc_rootfs *rootfs)
1138
const struct lxc_rootfs *rootfs,
1139
const char *lxc_name)
1141
1142
char path[MAXPATHLEN];
1142
1143
unsigned long mntflags;
1145
int r, ret = 0, offset;
1146
1147
if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) {
1147
1148
ERROR("failed to parse mount option '%s'", mntent->mnt_opts);
1152
/* if rootfs->path is a blockdev path, allow container fstab to
1153
* use /var/lib/lxc/CN/rootfs as the target prefix */
1154
r = snprintf(path, MAXPATHLEN, "/var/lib/lxc/%s/rootfs", lxc_name);
1155
if (r < 0 || r >= MAXPATHLEN)
1158
aux = strstr(mntent->mnt_dir, path);
1160
offset = strlen(path);
1151
1165
aux = strstr(mntent->mnt_dir, rootfs->path);
1153
1167
WARN("ignoring mount point '%s'", mntent->mnt_dir);
1170
offset = strlen(rootfs->path);
1157
1174
snprintf(path, MAXPATHLEN, "%s/%s", rootfs->mount,
1158
aux + strlen(rootfs->path));
1176
if (r < 0 || r >= MAXPATHLEN) {
1177
WARN("pathnme too long for '%s'", mntent->mnt_dir);
1160
1183
ret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type,
1161
1184
mntflags, mntdata);
1238
ret = mount_file_entries(rootfs, file);
1263
ret = mount_file_entries(rootfs, file, lxc_name);
1240
1265
endmntent(file);
1244
static int setup_mount_entries(const struct lxc_rootfs *rootfs, struct lxc_list *mount)
1269
static int setup_mount_entries(const struct lxc_rootfs *rootfs, struct lxc_list *mount,
1270
const char *lxc_name)
1247
1273
struct lxc_list *iterator;
1873
if (setup_mount(&lxc_conf->rootfs, lxc_conf->fstab)) {
1900
if (setup_mount(&lxc_conf->rootfs, lxc_conf->fstab, name)) {
1874
1901
ERROR("failed to setup the mounts for '%s'", name);
1878
if (setup_mount_entries(&lxc_conf->rootfs, &lxc_conf->mount_list)) {
1905
if (setup_mount_entries(&lxc_conf->rootfs, &lxc_conf->mount_list, name)) {
1879
1906
ERROR("failed to setup the mount entries for '%s'", name);