union_access

In union_access() copy up regular files before checking permissions.

Unionfs is meant to provide a writable layer above a read-only layer
and should not fail here just because the lower layer is mounted
read-only.

diff -r 7905a7f71de2 -r 043f9d56db68 sys/fs/union/union_vnops.c
--- sys/fs/union/union_vnops.c
+++ sys/fs/union/union_vnops.c
@@ -771,6 +771,13 @@ union_access(void *v)
 		}
 	}
 
+	if (un->un_uppervp == NULLVP &&
+	    (un->un_lowervp->v_type == VREG) &&
+	    (ap->a_accmode & VWRITE)) {
+		error = union_copyup(un, 1, ap->a_cred, curlwp);
+		if (error)
+			return error;
+	}
 
 	if ((vp = un->un_uppervp) != NULLVP) {
 		ap->a_vp = vp;
