Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/union In union_access() copy up regular files before ...



details:   https://anonhg.NetBSD.org/src/rev/b1a7ccc3f61f
branches:  trunk
changeset: 1026756:b1a7ccc3f61f
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun Dec 05 16:16:58 2021 +0000

description:
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.

diffstat:

 sys/fs/union/union_vnops.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 9a2d04d9eb9c -r b1a7ccc3f61f sys/fs/union/union_vnops.c
--- a/sys/fs/union/union_vnops.c        Sun Dec 05 15:51:33 2021 +0000
+++ b/sys/fs/union/union_vnops.c        Sun Dec 05 16:16:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: union_vnops.c,v 1.79 2021/10/20 03:08:17 thorpej Exp $ */
+/*     $NetBSD: union_vnops.c,v 1.80 2021/12/05 16:16:58 hannken Exp $ */
 
 /*
  * Copyright (c) 1992, 1993, 1994, 1995
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.79 2021/10/20 03:08:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.80 2021/12/05 16:16:58 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -771,6 +771,13 @@
                }
        }
 
+       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;



Home | Main Index | Thread Index | Old Index