From c93d29a8f5f38b8c0c60239a2e70bc231ae69e20 Mon Sep 17 00:00:00 2001 From: Jan-Simon Pendry Date: Sun, 24 Apr 1994 15:46:47 -0800 Subject: [PATCH] detect root node and set VROOT flag SCCS-vsn: sys/miscfs/union/union_subr.c 8.5 --- usr/src/sys/miscfs/union/union_subr.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/usr/src/sys/miscfs/union/union_subr.c b/usr/src/sys/miscfs/union/union_subr.c index 9e444c77ef..f0cd58e1d5 100644 --- a/usr/src/sys/miscfs/union/union_subr.c +++ b/usr/src/sys/miscfs/union/union_subr.c @@ -8,7 +8,7 @@ * * %sccs.include.redist.c% * - * @(#)union_subr.c 8.4 (Berkeley) %G% + * @(#)union_subr.c 8.5 (Berkeley) %G% */ #include @@ -21,6 +21,7 @@ #include #include #include +#include #include #ifdef DIAGNOSTIC @@ -200,7 +201,9 @@ union_allocvp(vpp, mp, undvp, dvp, cnp, uppervp, lowervp) struct union_node *un; struct union_node **pp; struct vnode *xlowervp = NULLVP; + struct union_mount *um = MOUNTTOUNIONMOUNT(mp); int hash; + int vflag; int try; if (uppervp == NULLVP && lowervp == NULLVP) @@ -211,6 +214,17 @@ union_allocvp(vpp, mp, undvp, dvp, cnp, uppervp, lowervp) lowervp = NULLVP; } + /* detect the root vnode (and aliases) */ + vflag = 0; + if ((uppervp == um->um_uppervp) && + ((lowervp == NULLVP) || lowervp == um->um_lowervp)) { + if (lowervp == NULLVP) { + lowervp = um->um_lowervp; + VREF(lowervp); + } + vflag = VROOT; + } + loop: for (try = 0; try < 3; try++) { switch (try) { @@ -370,6 +384,7 @@ loop: MALLOC((*vpp)->v_data, void *, sizeof(struct union_node), M_TEMP, M_WAITOK); + (*vpp)->v_flag |= vflag; if (uppervp) (*vpp)->v_type = uppervp->v_type; else -- 2.20.1