Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Dec 2001 23:52:03 +0700
From:      Eugene Grosbein <eugen@grosbein.pp.ru>
To:        freebsd-fs@freebsd.org
Cc:        jkh@freebsd.org
Subject:   [PATCH] msdosfs_vfsops.c: some kind of FAT32 incompatibility?
Message-ID:  <20011203235203.A435@grosbein.pp.ru>

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

Hi!

FreeBSD has obtained FAT32 support with jkh's commit 3 years, 9 months ago
(see revision 1.24). FAT32 checks has not changed since then basically. 
Here are problem description and patch suggested for discussion.

First I have to explain partitioning of my 6.4G hard drive.

Slice 1: Primary DOS partition, FAT16 500Mb (C: for DOS)
Slice 2: Extended DOS partition, 1500Mb single "disk D:", FAT32.
         No free space in the slice for new DOS disks.
Slice 3: 3G for FreeBSD.

The rest is free and the last record in the MBR is not occupied.
This was intentionally left blank as space for testing of 
unstable OS versions and used for it for some time.
Once I decided to use some of this space for Windows95 residing 
at the beginning of drive but there was no standard tools to make it 
visible for Win95. So I used Norton Utilities 3.01 for Win95 and 
its Disk Editor to create new "Extended Partition" residing 
at the end of drive and to link it to existing Extended Partition. 
Disk Editor has feature named 'Recalculate partition' that should 
guarantee correctness of new partition record.

I'm not sure if similar chain of "partitions" is completely correct,
at least this worked for me over a year with one remark: Norton Disk Doctor
did not like the last partition but agreed it to exist and
proposed "to mark" it so that it will not complain every time it is run.
Then all worked very well and this new "disk E:" was formatted as FAT32 and
used as usual.

Now we are back to FreeBSD. "Disk D:" can be mounted as /dev/ad0s5.
If I do not allow NDD to touch "Disk E:" it can be mounted as /dev/ad0s6
and used by  FreeBSD. However, when NDD "marks" it, FreeBSD cannot mount this
"disk" anymore. Diagnostic is "mountmsdosfs(): bad FAT32 filesystem".

The reason is that NDD changes the only byte in FAT32 signature:
it changes BOOTSIG2 from 0 to 0x52. The filesystem is still usable
by Windows but cannot be mounted by FreeBSD.

Well, I can live with this, applying the following patch before each
"buildworld". I just think that somebody else can hit this hole too.
So I propose the patch that handles this situation.
The patch is for RELENG_4 but that piece of code has not changed for
long time so it should apply to CURRENT cleanly in spite of different
file locations.

diff -ur ./bootsect.h /usr/src/sys/msdosfs/bootsect.h
--- ./bootsect.h	Sat Aug 28 08:48:06 1999
+++ /usr/src/sys/msdosfs/bootsect.h	Mon Dec  3 22:27:13 2001
@@ -69,6 +69,7 @@
 #define	BOOTSIG0	0x55
 #define	BOOTSIG1	0xaa
 #define	BOOTSIG2	0
+#define	BOOTSIG2_COMPAT	0x52
 #define	BOOTSIG3	0
 };
 #ifdef	atari
diff -ur ./msdosfs_vfsops.c /usr/src/sys/msdosfs/msdosfs_vfsops.c
--- ./msdosfs_vfsops.c	Mon Nov  5 01:57:51 2001
+++ /usr/src/sys/msdosfs/msdosfs_vfsops.c	Mon Dec  3 22:28:30 2001
@@ -524,7 +524,8 @@
 	}
 
 	if (pmp->pm_RootDirEnts == 0) {
-		if (bsp->bs710.bsBootSectSig2 != BOOTSIG2
+		if ((bsp->bs710.bsBootSectSig2 != BOOTSIG2
+		    && bsp->bs710.bsBootSectSig2 != BOOTSIG2_COMPAT)
 		    || bsp->bs710.bsBootSectSig3 != BOOTSIG3
 		    || pmp->pm_Sectors
 		    || pmp->pm_FATsecs


Please CC me when replying. Thank you.
Eugene Grosbein

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




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