[CRIU] [PATCH] mount: Create target of bind mount if it doesn't exist
Pavel Emelyanov
xemul at parallels.com
Thu Aug 28 09:07:06 PDT 2014
On 08/28/2014 07:43 PM, Saied Kazemi wrote:
> 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?
+1 I'd also like to know the reasons why the mountpoint target doesn't exist.
AFAIK rmdir/unlink doesn't work on dirs/files that are mountpoints.
> --Saied
>
>
>
> On Thu, Aug 28, 2014 at 8:27 AM, Tycho Andersen <tycho.andersen at canonical.com <mailto: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 <mailto: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 <mailto:CRIU at openvz.org>
> https://lists.openvz.org/mailman/listinfo/criu
>
>
>
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>
More information about the CRIU
mailing list