Loading a FAT-32 filesystem throws ArrayIndexOutOfBoundsException

Project:JNode Core
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

The attached file is a gzipped FAT-32 filesystem created under Windows XP.

Running the following test:

public void testTrivial() throws Exception
{
File file = new File("test.fat32");
Device device = new FileDevice(file, "r");
FileSystem fs = new FatFileSystem(device, true);
fs.close();
}

Gives the following exception:

org.jnode.fs.FileSystemException: java.lang.ArrayIndexOutOfBoundsException: 0
at org.jnode.fs.fat.FatFileSystem.(FatFileSystem.java:89)

More than likely this is because the code is using sectorSize to initialise the number of entries, but the sector size field is always 0 on FAT-32.

Reference: http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html

AttachmentSize
issues_2100.45 KB

See here...

#1

Status:active» closed

What you state is essentially correct.

The current Jnode fat code read the bootsector with the assumptions that the offsets

17-18 NrRootDirEntries
19-20 NrLogicalSectors

have a meaning for a FAT32.

As you pointed out these fields that M$ name:

17-18 BPB_RootEntCnt
19-20 BPB_TotSec16

in the Bios Parameter Block data structure are "zero" for a Fat32 filesystem.

The current code can only go in exception making these assumptions.

A more complete (the law for what I know) Fat specification can be found in the M$ Hardware White Paper titled "Microsoft Extensible Firmare Initiative, Fat32 File System Specification" available at the URL http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx.

These are the guidelines I'm following in my new jfat jnode package code, still in developing and still far from a complete implementation.

My code can read, without exceptions at least, the gizipped issue_2 image you posted.

To give just an idea of my jfat code, I'll append a dump of mine FSEntry implementation for the file "text.txt" in the root directory of your issue_2 FAT32 100Mb gzipped image file.

Regards, G. Vitillaro (aka alea).

*******************************************
Short Entry isDirty[false]
*******************************************
Index 5
Entry
00000000 54 45 53 54 20 20 20 20 54 58 54 20 18 11 57 7B |TEST TXT ..W{|
00000010 74 34 74 34 00 00 20 71 6E 34 07 00 12 00 00 00 |t4t4.. qn4......|
Name
Attr 20
NTRes 18
CrtTimeTenth 17
CrtTime 31575
CrtDate 13428
LstAccDate 13428
FstClusHi 0
WrtTime 28960
WrtDate 13422
FstClushLo 7
FileSize 18
*******************************************
ShortName TEST.TXT
Attr A
Case LLLLLLLL.LLL
ChkSum 8F
Created 2006-03-20 15:26:46.170
Accessed 2006-03-20
Modified 2006-03-14 14:09:00.0
StartCluster 7
Length 18
*******************************************

#2

I'll close this.