[CRIU] [PATCH] mount: Create target of bind mount if it doesn't exist
Saied Kazemi
saied at google.com
Thu Aug 28 08:43:06 PDT 2014
I have seen a similar case where /dev/null is missing (Docker using
UnionFS). While this patch fixes the issue, I am wondering why the target
file should be missing to start with and whether *always* recreating
missing target files could be masking more serious issues. Any thoughts?
--Saied
On Thu, Aug 28, 2014 at 8:27 AM, Tycho Andersen <
tycho.andersen at canonical.com> wrote:
> If the target of a bind mount doesn't exist, create it. In particular, this
> happens with /dev/ptmx across hosts under LXC. We could also mkdir -p any
> path
> to the target, although I'm not sure if that is a case that occurrs in the
> wild.
>
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
> mount.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/mount.c b/mount.c
> index 9bb8a17..2108907 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -1346,6 +1346,24 @@ static int do_bind_mount(struct mount_info *mi)
> root = rpath;
> do_bind:
> pr_info("\tBind %s to %s\n", root, mi->mountpoint);
> +
> + if (access(mi->mountpoint, F_OK)) {
> + if (errno == ENOENT) {
> + FILE *f;
> +
> + f = fopen(mi->mountpoint, "w");
> + if (!f) {
> + pr_perror("couldn't write 0 length
> %s", mi->mountpoint);
> + return -1;
> + }
> +
> + fclose(f);
> + } else {
> + pr_perror("Couldn't access %s",
> mi->mountpoint);
> + return -1;
> + }
> + }
> +
> if (mount(root, mi->mountpoint, NULL,
> MS_BIND, NULL) < 0) {
> pr_perror("Can't mount at %s", mi->mountpoint);
> --
> 1.9.1
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20140828/19b20e5f/attachment.html>
More information about the CRIU
mailing list