From <@gimli.Informatik.Uni-Oldenburg.DE:oytix!jelal.hb.north.de!nox@olis.north.de>  Sat Apr 29 22:20:25 1995
Received: from gimli.Informatik.Uni-Oldenburg.DE (gimli.Informatik.Uni-Oldenburg.DE [134.106.1.10])
          by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id WAA09267
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 29 Apr 1995 22:20:19 -0700
Received: by gimli.Informatik.Uni-Oldenburg.DE (Smail3.1.22.1)
	id <m0s5R55-00009kC>; Sun, 30 Apr 95 06:58 CES
Received: by olis.north.de (/\==/\ Smail3.1.28.1 #28.13)
	id <m0s5QtF-0000TOC@olis.north.de>; Sun, 30 Apr 95 06:45 MES
Received: from jelal.hb.north.de by oytix.hb.north.de with bsmtp
	(Smail3.1.29.0 #1) id m0s5NLW-0004hxM; Sun, 30 Apr 95 02:58 MET DST
Received: by jelal.hb.north.de (SMail-ST 0.95gcc/2.5+)
	id AA00055; Sun, 30 Apr 1995 02:16:36 +0200 (CEDT)
Message-Id: <9504300016.AA00055@jelal.hb.north.de>
Date: Sun, 30 Apr 1995 02:16:36 +0200 (CEDT)
From: nox@jelal.hb.north.de
Reply-To: nox@jelal.hb.north.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: panic: msdosfs_unlock: denode not locked
X-Send-Pr-Version: 3.2

>Number:         371
>Category:       kern
>Synopsis:       panic: msdosfs_unlock: denode not locked
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 29 22:30:01 1995
>Closed-Date:    Tue Jun 27 15:29:33 PDT 1995
>Last-Modified:
>Originator:     Juergen Lock
>Release:        FreeBSD 2.0-RELEASE i386
>Organization:
me? organized?
>Environment:

	2.0R msdosfs with some fixes from the 'net,
	a messdos filesystem /dev/sd0h mounted on /dos...

>Description:

	When called from chflags looks like msdosfs_setattr clears
	its DE_LOCKED bit when it shouldn't.

>How-To-Repeat:

	(dunno if this works always...)
	load bindist in /usr/tmp/2.0-RELEASE, then:

	mkdir /dos/20r
	mv /usr/tmp/2.0-RELEASE/bindist /dos/20r

>Fix:
	
	Here is what i'm running now, relative to 2.0R.  the first one
is probably useless (left it there just in case), the second and third
ones are the fix, and the rest is from the net.  Of course i don't
know if this is TRT but it works for me...

--- msdosfs_vnops.c.orig	Tue Nov  1 22:14:45 1994
+++ msdosfs_vnops.c	Sun Apr 23 22:40:35 1995
@@ -382,7 +382,8 @@
 	}
 
 	if (vap->va_size != VNOVAL) {
-		if (ap->a_vp->v_type == VDIR)
+		if (ap->a_vp->v_type == VDIR ||
+		    (dep->de_Attributes & ATTR_DIRECTORY))
 			return EISDIR;
 		error = detrunc(dep, vap->va_size, 0, cred, ap->a_p);
 		if (error)
@@ -410,6 +411,9 @@
 	}
 
 	if (vap->va_flags != VNOVAL) {
+		/* always true? */
+		u_long locked = dep->de_flag & DE_LOCKED;
+
 		error = suser(cred, &ap->a_p->p_acflag);
 		if (error)
 			return error;
@@ -420,6 +424,9 @@
 			dep->de_flag |= (vap->va_flags & 0xffff);
 		}
 		dep->de_flag |= DE_UPDATE;
+		if (locked)
+			/* !!! */
+			dep->de_flag |= DE_LOCKED;
 	}
 	return error;
 }
@@ -881,7 +888,9 @@
 		struct componentname *a_cnp;
 	} */ *ap;
 {
-	return VOP_ABORTOP(ap->a_vp, ap->a_cnp);
+	VOP_ABORTOP(ap->a_vp, ap->a_cnp);
+	vput(ap->a_vp);
+	return EMLINK;
 }
 
 /*
@@ -972,7 +981,7 @@
 	tdep = tvp ? VTODE(tvp) : NULL;
 	pmp = fddep->de_pmp;
 
-#ifdef __NetBSD__
+#if 1 /*def __NetBSD__*/
 	/* Check for cross-device rename */
 	if ((ap->a_fvp->v_mount != ap->a_tdvp->v_mount) ||
 	    (tvp && (ap->a_fvp->v_mount != tvp->v_mount))) {
--- msdosfs_denode.c.orig	Mon Oct 10 08:57:32 1994
+++ msdosfs_denode.c	Tue Apr 11 12:40:40 1995
@@ -119,13 +119,6 @@
 	dep->de_next = deq;
 	dep->de_prev = depp;
 	*depp = dep;
-	if (dep->de_flag & DE_LOCKED)
-		panic("msdosfs_hashins: already locked");
-	if (curproc)
-		dep->de_lockholder = curproc->p_pid;
-	else
-		dep->de_lockholder = -1;
-	dep->de_flag |= DE_LOCKED;
 }
 
 static void
@@ -236,6 +229,7 @@
 	 * can't be accessed until we've read it in and have done what we
 	 * need to it.
 	 */
+	VOP_LOCK(nvp);
 	msdosfs_hashins(ldep);
 
 	/*
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: bde 
State-Changed-When: Tue Jun 27 15:29:33 PDT 1995 
State-Changed-Why:  
The bug in msdosfs_setattr() was already fixed in revision 
1.11 1994/12/27 of msdosfs_vnops.c.  The "fixes off the net" 
were already in FreeBSD of course.  Please try to report 
only one bug and fix per PR. 
>Unformatted:



