Subject: kern/2185: msdosfs does not remove directory entry when deleting file
To: None <gnats-bugs@NetBSD.ORG>
From: Dave Huang <khym@spiff.bga.com>
List: netbsd-bugs
Date: 03/07/1996 05:42:04
>Number:         2185
>Category:       kern
>Synopsis:       msdosfs does not remove directory entry when deleting file
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar  7 07:05:01 1996
>Last-Modified:
>Originator:     Dave Huang
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 20 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Release:        NetBSD-current as of March 4, 1996
>Environment:
	
System: NetBSD spiff.bga.com 1.1A NetBSD 1.1A (SPIFF) #26: Mon Mar 4 16:02:48 CST 1996 khym@spiff.bga.com:/usr/src/sys/arch/i386/compile/SPIFF i386


>Description:
When deleting a file from an MSDOS partition, the clusters occupied by
the file are freed, but the directory entry itself is not marked as
deleted.

Looks like a stray semicolon slipped into the function removede() in
msdosfs_lookup.c, causing it to return before deleting the directory
entry.

>How-To-Repeat:
spiff /dos/c> touch junkfile
spiff /dos/c> ls -l junkfile
-rwxrwxr-x  1 root  wheel  0 Mar  7 05:34 junkfile*
spiff /dos/c> rm junkfile
spiff /dos/c> ls -l junkfile
-rwxrwxr-x  1 root  wheel  0 Mar  7 05:34 junkfile*

Now go run scandisk/chkdsk under MSDOS/Win95/WinNT and watch it
complain.

>Fix:
--- msdosfs_lookup.c.orig	Sat Feb 10 06:33:33 1996
+++ msdosfs_lookup.c	Thu Mar  7 05:23:40 1996
@@ -916,7 +916,7 @@
 	dep->de_refcnt--;
 	do {
 		error = pcbmap(pdep, de_cluster(pmp, offset), &bn, 0, &blsize);
-		if (error);
+		if (error)
 			return error;
 		error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
 		if (error) {

>Audit-Trail:
>Unformatted: