struct lxc_mount_options *mnt_opts = &rootfs->mnt_opts;
unsigned long mflags = 0;
int ret;
- const char *src;
+ const char *source, *target;
if (!strequal(bdev->type, "dir"))
return syserror_set(-EINVAL, "Invalid storage driver");
if (rootfs->dfd_idmapped >= 0 && !can_use_bind_mounts())
return syserror_set(-EOPNOTSUPP, "Idmapped mount requested but kernel doesn't support new mount API");
- src = lxc_storage_get_path(bdev->src, bdev->type);
+ source = lxc_storage_get_path(bdev->src, bdev->type);
+ target = bdev->dest;
if (can_use_bind_mounts()) {
__do_close int fd_source = -EBADF, fd_target = -EBADF;
- fd_target = open_at(-EBADF, bdev->dest, PROTECT_OPATH_DIRECTORY, 0, 0);
+ fd_target = open_at(-EBADF, target, PROTECT_OPATH_DIRECTORY, 0, 0);
if (fd_target < 0)
- return syserror("Failed to open \"%s\"", bdev->dest);
+ return syserror("Failed to open \"%s\"", target);
if (rootfs->dfd_idmapped >= 0) {
ret = move_detached_mount(rootfs->dfd_idmapped, fd_target, "",
PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_BENEATH);
} else {
- fd_source = open_at(-EBADF, src, PROTECT_OPATH_DIRECTORY, 0, 0);
+ fd_source = open_at(-EBADF, source, PROTECT_OPATH_DIRECTORY, 0, 0);
if (fd_source < 0)
- return syserror("Failed to open \"%s\"", src);
+ return syserror("Failed to open \"%s\"", source);
ret = fd_bind_mount(fd_source, "",
PROTECT_OPATH_DIRECTORY,
PROTECT_LOOKUP_BENEATH, 0, true);
}
if (ret < 0)
- return syserror("Failed to mount \"%s\" onto \"%s\"", src, bdev->dest);
+ return syserror("Failed to mount \"%s\" onto \"%s\"", source, target);
} else {
- ret = mount(src, bdev->dest, "bind", MS_BIND | MS_REC | mnt_opts->mnt_flags | mnt_opts->prop_flags, mnt_opts->data);
+ ret = mount(source, target, "bind", MS_BIND | MS_REC | mnt_opts->mnt_flags | mnt_opts->prop_flags, mnt_opts->data);
if (ret < 0)
- return log_error_errno(-errno, errno, "Failed to mount \"%s\" on \"%s\"", src, bdev->dest);
+ return log_error_errno(-errno, errno, "Failed to mount \"%s\" on \"%s\"", source, target);
if (ret == 0 && (mnt_opts->mnt_flags & MS_RDONLY)) {
- mflags = add_required_remount_flags(src, bdev->dest, MS_BIND | MS_REC | mnt_opts->mnt_flags | mnt_opts->mnt_flags | MS_REMOUNT);
+ mflags = add_required_remount_flags(source, target, MS_BIND | MS_REC | mnt_opts->mnt_flags | mnt_opts->mnt_flags | MS_REMOUNT);
- ret = mount(src, bdev->dest, "bind", mflags, mnt_opts->data);
+ ret = mount(source, target, "bind", mflags, mnt_opts->data);
if (ret < 0)
return log_error_errno(-errno, errno, "Failed to remount \"%s\" on \"%s\" read-only with options \"%s\", mount flags \"%lu\", and propagation flags \"%lu\"",
- src ? src : "(none)", bdev->dest, mnt_opts->data, mflags, mnt_opts->mnt_flags);
+ source ? source : "(none)", target, mnt_opts->data, mflags, mnt_opts->mnt_flags);
else
DEBUG("Remounted \"%s\" on \"%s\" read-only with options \"%s\", mount flags \"%lu\", and propagation flags \"%lu\"",
- src ? src : "(none)", bdev->dest, mnt_opts->data, mflags, mnt_opts->mnt_flags);
+ source ? source : "(none)", target, mnt_opts->data, mflags, mnt_opts->mnt_flags);
}
TRACE("Mounted \"%s\" on \"%s\" with options \"%s\", mount flags \"%lu\", and propagation flags \"%lu\"",
- src ? src : "(none)", bdev->dest, mnt_opts->data, mflags, mnt_opts->mnt_flags);
+ source ? source : "(none)", target, mnt_opts->data, mflags, mnt_opts->mnt_flags);
}
- TRACE("Mounted \"%s\" onto \"%s\"", src, bdev->dest);
+ TRACE("Mounted \"%s\" onto \"%s\"", source, target);
return 0;
}