Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/msdosfs/msdosfs_vfsops.c
Show First 20 Lines • Show All 694 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
if (pmp->pm_HugeSectors <= pmp->pm_firstcluster) { | if (pmp->pm_HugeSectors <= pmp->pm_firstcluster) { | ||||
error = EINVAL; | error = EINVAL; | ||||
goto error_exit; | goto error_exit; | ||||
} | } | ||||
pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / | pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) / | ||||
SecPerClust + 1; | SecPerClust + 1; | ||||
pmp->pm_fatsize = pmp->pm_FATsecs * DEV_BSIZE; /* XXX not used? */ | pmp->pm_fatsize = pmp->pm_FATsecs * DEV_BSIZE; | ||||
if (pmp->pm_fatmask == 0) { | if (pmp->pm_fatmask == 0) { | ||||
if (pmp->pm_maxcluster <= ((CLUST_RSRVD - CLUST_FIRST) & | |||||
FAT12_MASK)) { | |||||
/* | /* | ||||
* The last 10 (or 16?) clusters are reserved and must not | |||||
* be allocated for data. | |||||
*/ | |||||
if (pmp->pm_maxcluster < (CLUST_RSRVD & FAT12_MASK)) { | |||||
se: The condition was wrong and caused valid FAT12 file systems to be trated as FAT16 in the… | |||||
/* | |||||
* This will usually be a floppy disk. This size makes | * This will usually be a floppy disk. This size makes | ||||
* sure that one FAT entry will not be split across | * sure that one FAT entry will not be split across | ||||
* multiple blocks. | * multiple blocks. | ||||
*/ | */ | ||||
pmp->pm_fatmask = FAT12_MASK; | pmp->pm_fatmask = FAT12_MASK; | ||||
pmp->pm_fatmult = 3; | pmp->pm_fatmult = 3; | ||||
pmp->pm_fatdiv = 2; | pmp->pm_fatdiv = 2; | ||||
} else { | } else { | ||||
pmp->pm_fatmask = FAT16_MASK; | pmp->pm_fatmask = FAT16_MASK; | ||||
pmp->pm_fatmult = 2; | pmp->pm_fatmult = 2; | ||||
pmp->pm_fatdiv = 1; | pmp->pm_fatdiv = 1; | ||||
} | } | ||||
} | } | ||||
clusters = (pmp->pm_fatsize / pmp->pm_fatmult) * pmp->pm_fatdiv; | clusters = (pmp->pm_fatsize / pmp->pm_fatmult) * pmp->pm_fatdiv ; | ||||
if (pmp->pm_maxcluster >= clusters) { | if (pmp->pm_maxcluster >= clusters) { | ||||
#ifdef MSDOSFS_DEBUG | #ifdef MSDOSFS_DEBUG | ||||
printf("Warning: number of clusters (%ld) exceeds FAT " | printf("Warning: number of clusters (%ld) exceeds FAT " | ||||
"capacity (%ld)\n", pmp->pm_maxcluster + 1, clusters); | "capacity (%ld)\n", pmp->pm_maxcluster - 1, clusters); | ||||
#endif | #endif | ||||
pmp->pm_maxcluster = clusters - 1; | pmp->pm_maxcluster = clusters - 1; | ||||
} | } | ||||
if (FAT12(pmp)) | if (FAT12(pmp)) | ||||
pmp->pm_fatblocksize = 3 * 512; | pmp->pm_fatblocksize = 3 * 512; | ||||
else | else | ||||
pmp->pm_fatblocksize = PAGE_SIZE; | pmp->pm_fatblocksize = PAGE_SIZE; | ||||
▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
msdosfs_statfs(struct mount *mp, struct statfs *sbp) | msdosfs_statfs(struct mount *mp, struct statfs *sbp) | ||||
{ | { | ||||
struct msdosfsmount *pmp; | struct msdosfsmount *pmp; | ||||
pmp = VFSTOMSDOSFS(mp); | pmp = VFSTOMSDOSFS(mp); | ||||
sbp->f_bsize = pmp->pm_bpcluster; | sbp->f_bsize = pmp->pm_bpcluster; | ||||
sbp->f_iosize = pmp->pm_bpcluster; | sbp->f_iosize = pmp->pm_bpcluster; | ||||
sbp->f_blocks = pmp->pm_maxcluster + 1; | sbp->f_blocks = pmp->pm_maxcluster - CLUST_FIRST + 1; | ||||
Done Inline ActionsThe first data cluster is cluster #2, thus for example maxcluster=1023 would represent a data area indexed by [2 .. 1023] and with a size of 1022 clusters. se: The first data cluster is cluster #2, thus for example maxcluster=1023 would represent a data… | |||||
sbp->f_bfree = pmp->pm_freeclustercount; | sbp->f_bfree = pmp->pm_freeclustercount; | ||||
sbp->f_bavail = pmp->pm_freeclustercount; | sbp->f_bavail = pmp->pm_freeclustercount; | ||||
sbp->f_files = howmany(pmp->pm_rootdirsize * DEV_BSIZE, | sbp->f_files = howmany(pmp->pm_rootdirsize * DEV_BSIZE, | ||||
sizeof(struct direntry)); | sizeof(struct direntry)); | ||||
sbp->f_ffree = pmp->pm_rootdirfree; | sbp->f_ffree = pmp->pm_rootdirfree; | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 140 Lines • Show Last 20 Lines |
The condition was wrong and caused valid FAT12 file systems to be trated as FAT16 in the following lines, leading to only 3/4 of the size being made available (e.g. 12 MB for a file system consisting of 4084 clusters of 4 KB).