<div dir="ltr">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?<div>
<br></div><div>--Saied</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 28, 2014 at 8:27 AM, Tycho Andersen <span dir="ltr"><<a href="mailto:tycho.andersen@canonical.com" target="_blank">tycho.andersen@canonical.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If the target of a bind mount doesn't exist, create it. In particular, this<br>
happens with /dev/ptmx across hosts under LXC. We could also mkdir -p any path<br>
to the target, although I'm not sure if that is a case that occurrs in the<br>
wild.<br>
<br>
Signed-off-by: Tycho Andersen <<a href="mailto:tycho.andersen@canonical.com">tycho.andersen@canonical.com</a>><br>
---<br>
mount.c | 18 ++++++++++++++++++<br>
1 file changed, 18 insertions(+)<br>
<br>
diff --git a/mount.c b/mount.c<br>
index 9bb8a17..2108907 100644<br>
--- a/mount.c<br>
+++ b/mount.c<br>
@@ -1346,6 +1346,24 @@ static int do_bind_mount(struct mount_info *mi)<br>
root = rpath;<br>
do_bind:<br>
pr_info("\tBind %s to %s\n", root, mi->mountpoint);<br>
+<br>
+ if (access(mi->mountpoint, F_OK)) {<br>
+ if (errno == ENOENT) {<br>
+ FILE *f;<br>
+<br>
+ f = fopen(mi->mountpoint, "w");<br>
+ if (!f) {<br>
+ pr_perror("couldn't write 0 length %s", mi->mountpoint);<br>
+ return -1;<br>
+ }<br>
+<br>
+ fclose(f);<br>
+ } else {<br>
+ pr_perror("Couldn't access %s", mi->mountpoint);<br>
+ return -1;<br>
+ }<br>
+ }<br>
+<br>
if (mount(root, mi->mountpoint, NULL,<br>
MS_BIND, NULL) < 0) {<br>
pr_perror("Can't mount at %s", mi->mountpoint);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
_______________________________________________<br>
CRIU mailing list<br>
<a href="mailto:CRIU@openvz.org">CRIU@openvz.org</a><br>
<a href="https://lists.openvz.org/mailman/listinfo/criu" target="_blank">https://lists.openvz.org/mailman/listinfo/criu</a><br>
</font></span></blockquote></div><br></div>