Subject: Unnecessary size limitation in MS-DOS filesystem?
To: None <tech-kern@netbsd.org>
From: Matthias Scheler <tron@lyssa.owl.de>
List: tech-kern
Date: 03/05/1999 20:01:02
Hello,
while finding out why I can't access my 6GB MS-DOS Fat32 partition
I found this piece of code in "src/sys/msdosfs/msdosfs_vfsops.c":
if (pmp->pm_HugeSectors > 0xffffffff / pmp->pm_BytesPerSec + 1) {
/*
* We cannot deal currently with this size of disk
* due to fileid limitations (see msdosfs_getattr and
* msdosfs_readdir)
*/
error = EINVAL;
goto error_exit;
}
This is the code segment from "src/sys/msdosfs/msdosfs_vnops.c":
int
msdosfs_getattr(v)
void *v;
{
[...]
u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
[...]
if (dep->de_Attributes & ATTR_DIRECTORY) {
fileid = cntobn(pmp, dep->de_StartCluster) * dirsperblk;
if (dep->de_StartCluster == MSDOSFSROOT)
fileid = 1;
} else {
fileid = cntobn(pmp, dep->de_dirclust) * dirsperblk;
if (dep->de_dirclust == MSDOSFSROOT)
fileid = roottobn(pmp, 0) * dirsperblk;
fileid += dep->de_diroffset / sizeof(struct direntry);
}
It looks like the block number is multiplied by "dirsperblk" so the size
check in "msdosfs_vfsops.c" uses to small bounds. IMHO it should look
like this:
if (pmp->pm_HugeSectors >
0xffffffff / (pmp->pm_BytesPerSec / sizeof(struct direntry)) + 1) {
[...]
}
This would raise the maximum size of a MS-DOS partition from 4GB to 128GB.
--
Matthias Scheler http://home.owl.de/~tron/