Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2001 12:16:12 -0800 (PST)
From:      semenu@FreeBSD.org
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/24393: Patch to msdosfs to handle a kind of incorrect filesystems
Message-ID:  <200101162016.f0GKGCU11053@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         24393
>Category:       kern
>Synopsis:       Patch to msdosfs to handle a kind of incorrect filesystems
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 16 12:20:04 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Semen A. Ustimenko
>Release:        4.2-RELEASE
>Organization:
>Environment:
FreeBSD dev.the.net 4.2-RELEASE FreeBSD 4.2-RELEASE #3: Tue Dec 12 15:23:17 GMT+6 2000     root@default.the.net:/usr/src/sys/compile/DEFAULT  i386

>Description:
There are sometimes a FAT filesystems not handled correctly by msdosfs 
driver, but handled by mtools and other OSes. The problem is that 
msdosfs assume . entry in directory have cluster number set to real 
directory cluster number. But sometimes cluster number for . entry is 
set to 0, and msdosfs behaves wrong with such filesystems.

>How-To-Repeat:
Take a FAT12 formatted diskette image from vmware2 distribution 
(vmware-distrib/lib/floppies/windows.flp): 
without patch:

# ls -lR /floppy
ls: win2k: directory causes a cycle
ls: win9x: directory causes a cycle
ls: winnt: directory causes a cycle
total 850
-rwxr-xr-x  1 root  wheel  870002 Nov  1 17:36 VMwareTools.exe
drwxr-xr-x  1 root  wheel       0 Nov  1 17:36 win2k
drwxr-xr-x  1 root  wheel       0 Nov  1 17:36 win9x
drwxr-xr-x  1 root  wheel       0 Nov  1 17:36 winnt

with patch:
# ls -lR /floppy
total 852
-rwxr-xr-x  1 root  wheel  870002 Nov  1 17:36 VMwareTools.exe
drwxr-xr-x  1 root  wheel     512 Nov  1 17:36 win2k
drwxr-xr-x  1 root  wheel     512 Nov  1 17:36 win9x
drwxr-xr-x  1 root  wheel     512 Nov  1 17:36 winnt

/floppy/win2k:
total 28
-rwxr-xr-x  1 root  wheel  18432 Nov  1 17:36 vmx_fb.dll
-rwxr-xr-x  1 root  wheel   2274 Nov  1 17:36 vmx_svga.inf
-rwxr-xr-x  1 root  wheel   7440 Nov  1 17:36 vmx_svga.sys

/floppy/win9x:
total 25
-rwxr-xr-x  1 root  wheel  17136 Nov  1 17:36 VMX_SVGA.DRV
-rwxr-xr-x  1 root  wheel   5991 Nov  1 17:36 VMX_SVGA.vxd
-rwxr-xr-x  1 root  wheel   1669 Nov  1 17:36 vmx_svga.inf

/floppy/winnt:
total 38
-rwxr-xr-x  1 root  wheel  17408 Nov  1 17:36 vmx_fb.dll
-rwxr-xr-x  1 root  wheel  13637 Nov  1 17:36 vmx_svga.inf
-rwxr-xr-x  1 root  wheel   7440 Nov  1 17:36 vmx_svga.sys

>Fix:
Use following patch:

Index: src/sys/msdosfs/msdosfs_denode.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/msdosfs/msdosfs_denode.c,v
retrieving revision 1.47.2.1
diff -c -r1.47.2.1 msdosfs_denode.c
*** src/sys/msdosfs/msdosfs_denode.c	2000/07/08 14:34:27	1.47.2.1
--- src/sys/msdosfs/msdosfs_denode.c	2001/01/16 19:30:13
***************
*** 356,361 ****
--- 356,371 ----
  		 */
  		u_long size;
  
+ 		/*
+ 		 * XXX Sometimes, there arrives that . entry have cluster
+ 		 * number 0, when it shouldn't. Use real cluster number
+ 		 * instead of what is written in directory entry.
+ 		 */
+ 		if ((diroffset == 0) && (ldep->de_StartCluster != dirclust)) {
+ 			printf("deget(): . entry at clust %ld != %ld\n", dirclust, ldep->de_StartCluster);
+ 			ldep->de_StartCluster = dirclust;
+ 		}
+ 
  		nvp->v_type = VDIR;
  		if (ldep->de_StartCluster != MSDOSFSROOT) {
  			error = pcbmap(ldep, 0xffff, 0, &size, 0);


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101162016.f0GKGCU11053>