Skip to content

Commit fa3b367

Browse files
author
perseant
committed
Fixes PR #1206, by setting va_mode and va_flags in the copied-up vnode's
attributes.
1 parent 7145c70 commit fa3b367

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

sys/miscfs/union/union_subr.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: union_subr.c,v 1.31 1999/05/02 00:18:31 thorpej Exp $ */
1+
/* $NetBSD: union_subr.c,v 1.32 1999/06/25 19:05:49 perseant Exp $ */
22

33
/*
44
* Copyright (c) 1994 Jan-Simon Pendry
@@ -652,6 +652,7 @@ union_copyup(un, docopy, cred, p)
652652
{
653653
int error;
654654
struct vnode *lvp, *uvp;
655+
struct vattr lvattr, uvattr;
655656

656657
error = union_vn_create(&uvp, un, p);
657658
if (error)
@@ -669,11 +670,21 @@ union_copyup(un, docopy, cred, p)
669670
* from VOP_CLOSE
670671
*/
671672
vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY);
672-
error = VOP_OPEN(lvp, FREAD, cred, p);
673+
674+
error = VOP_GETATTR(lvp, &lvattr, cred, p);
675+
if (error == 0)
676+
error = VOP_OPEN(lvp, FREAD, cred, p);
673677
if (error == 0) {
674678
error = union_copyfile(lvp, uvp, cred, p);
675679
(void) VOP_CLOSE(lvp, FREAD, cred, p);
676680
}
681+
if (error == 0) {
682+
/* Copy permissions up too */
683+
VATTR_NULL(&uvattr);
684+
uvattr.va_mode = lvattr.va_mode;
685+
uvattr.va_flags = lvattr.va_flags;
686+
error = VOP_SETATTR(uvp, &uvattr, cred, p);
687+
}
677688
VOP_UNLOCK(lvp, 0);
678689
#ifdef UNION_DIAGNOSTIC
679690
if (error == 0)

0 commit comments

Comments
 (0)