"clussec" can be of CLUSTER size if we divide by an adjusted "words per

sector"(FAT16), or "dwords per sector"(FAT32) value instead of multiplying
it first. For FAT12 the *3/2 works out a little differently: here we
first multiply by 3 and then divide by the number of "nibbles per sector".


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@904 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-04-29 12:28:14 +00:00
parent 0afa773303
commit f6716cd74b
1 changed files with 12 additions and 10 deletions

View File

@ -47,8 +47,9 @@ int ISFAT32(struct dpb FAR * dpbp)
}
#endif
struct buffer FAR *getFATblock(ULONG clussec, struct dpb FAR * dpbp)
struct buffer FAR *getFATblock(CLUSTER clussec, struct dpb FAR * dpbp)
{
unsigned secdiv;
struct buffer FAR *bp;
CLUSTER max_cluster = dpbp->dpb_size;
@ -68,21 +69,22 @@ struct buffer FAR *getFATblock(ULONG clussec, struct dpb FAR * dpbp)
return NULL;
}
secdiv = dpbp->dpb_secsize;
if (ISFAT12(dpbp))
{
clussec = (((unsigned)clussec << 1) + (unsigned)clussec) >> 1;
clussec = (unsigned)clussec * 3;
secdiv *= 2;
}
else /* FAT16 or FAT32 */
{
secdiv /= 2;
#ifdef WITHFAT32
else if (ISFAT32(dpbp))
{
clussec = clussec * SIZEOF_CLST32;
}
if (ISFAT32(dpbp))
secdiv /= 2;
#endif
else
{
clussec = clussec * SIZEOF_CLST16;
}
clussec = clussec / dpbp->dpb_secsize + dpbp->dpb_fatstrt;
clussec /= secdiv;
clussec += dpbp->dpb_fatstrt;
#ifdef WITHFAT32
if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING))
{