Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106936610
D39386.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D39386.diff
View Options
diff --git a/sys/fs/msdosfs/msdosfs_fat.c b/sys/fs/msdosfs/msdosfs_fat.c
--- a/sys/fs/msdosfs/msdosfs_fat.c
+++ b/sys/fs/msdosfs/msdosfs_fat.c
@@ -89,11 +89,17 @@
fatblock(struct msdosfsmount *pmp, u_long ofs, u_long *bnp, u_long *sizep,
u_long *bop)
{
- u_long bn, size;
+ u_long bn, size, fatblocksec;
+ fatblocksec = pmp->pm_fatblocksec;
+ if (FAT12(pmp) && fatblocksec % 3 != 0) {
+ fatblocksec *= 3;
+ if (fatblocksec % 6 == 0)
+ fatblocksec /= 2;
+ }
bn = ofs / pmp->pm_fatblocksize * pmp->pm_fatblocksec;
- size = min(pmp->pm_fatblocksec, pmp->pm_FATsecs - bn)
- * DEV_BSIZE;
+ size = roundup(min(fatblocksec, pmp->pm_FATsecs - bn) * DEV_BSIZE,
+ pmp->pm_BlkPerSec * DEV_BSIZE);
bn += pmp->pm_fatblk + pmp->pm_curfat * pmp->pm_FATsecs;
if (bnp)
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -700,11 +700,14 @@
}
pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) /
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_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)) {
/*
* This will usually be a floppy disk. This size makes
* sure that one FAT entry will not be split across
@@ -720,11 +723,11 @@
}
}
- 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) {
#ifdef MSDOSFS_DEBUG
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
pmp->pm_maxcluster = clusters - 1;
}
@@ -1045,7 +1048,7 @@
pmp = VFSTOMSDOSFS(mp);
sbp->f_bsize = 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;
sbp->f_bfree = pmp->pm_freeclustercount;
sbp->f_bavail = pmp->pm_freeclustercount;
sbp->f_files = howmany(pmp->pm_rootdirsize * DEV_BSIZE,
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -313,8 +313,11 @@
vap->va_flags |= UF_SYSTEM;
vap->va_gen = 0;
vap->va_blocksize = pmp->pm_bpcluster;
- vap->va_bytes =
- (dep->de_FileSize + pmp->pm_crbomask) & ~pmp->pm_crbomask;
+ if (dep->de_StartCluster != MSDOSFSROOT)
+ vap->va_bytes =
+ (dep->de_FileSize + pmp->pm_crbomask) & ~pmp->pm_crbomask;
+ else
+ vap->va_bytes = 0; /* FAT12/FAT16 root dir in reserved area */
vap->va_type = ap->a_vp->v_type;
vap->va_filerev = dep->de_modrev;
return (0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 6:06 PM (2 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15724646
Default Alt Text
D39386.diff (2 KB)
Attached To
Mode
D39386: Fix panic and other issues in msdosfs
Attached
Detach File
Event Timeline
Log In to Comment