Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150387203
D38987.1792282403.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D38987.1792282403.diff
View Options
diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c
--- a/sys/fs/msdosfs/msdosfs_lookup.c
+++ b/sys/fs/msdosfs/msdosfs_lookup.c
@@ -684,6 +684,7 @@
return error;
}
ndep = bptoep(pmp, bp, ddep->de_fndoffset);
+ rootde_alloced(ddep);
DE_EXTERNALIZE(ndep, dep);
@@ -721,6 +722,7 @@
ndep--;
ddep->de_fndoffset -= sizeof(struct direntry);
}
+ rootde_alloced(ddep);
if (!unix2winfn(un, unlen, (struct winentry *)ndep,
cnt++, chksum, pmp))
break;
@@ -1015,6 +1017,7 @@
*/
offset -= sizeof(struct direntry);
ep--->deName[0] = SLOT_DELETED;
+ rootde_freed(pdep);
if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95)
|| !(offset & pmp->pm_crbomask)
|| ep->deAttributes != ATTR_WIN95)
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
@@ -425,6 +425,10 @@
int ronly, error;
struct g_consumer *cp;
struct bufobj *bo;
+ struct direntry *dep;
+ u_long dirsize;
+ u_long dirclu;
+ int diridx;
bp = NULL; /* This and pmp both used in error_exit. */
pmp = NULL;
@@ -747,6 +751,27 @@
goto error_exit;
pmp->pm_fmod = 1;
}
+
+ if (FAT32(pmp)) {
+ pmp->pm_rootdirfree = 0;
+ } else {
+ pmp->pm_rootdirfree = pmp->pm_RootDirEnts;
+ diridx = 0;
+ dirsize = pmp->pm_RootDirEnts * sizeof(struct direntry);
+ dirclu = pmp->pm_firstcluster - pmp->pm_rootdirsize;
+ if (bread(pmp->pm_devvp, dirclu, dirsize, NOCRED, &bp) != 0)
+ goto error_exit;
+ for (diridx = 0; diridx < pmp->pm_RootDirEnts; diridx++) {
+ dep = (struct direntry*)bp->b_data + diridx;
+ if (dep->deName[0] == SLOT_EMPTY)
+ break;
+ if (dep->deName[0] != SLOT_DELETED)
+ pmp->pm_rootdirfree--;
+ }
+ brelse(bp);
+ bp = NULL;
+ }
+
mp->mnt_data = pmp;
mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
@@ -948,8 +973,8 @@
sbp->f_blocks = pmp->pm_maxcluster + 1;
sbp->f_bfree = pmp->pm_freeclustercount;
sbp->f_bavail = pmp->pm_freeclustercount;
- sbp->f_files = pmp->pm_RootDirEnts; /* XXX */
- sbp->f_ffree = 0; /* what to put in here? */
+ sbp->f_files = pmp->pm_RootDirEnts;
+ sbp->f_ffree = pmp->pm_rootdirfree;
return (0);
}
diff --git a/sys/fs/msdosfs/msdosfsmount.h b/sys/fs/msdosfs/msdosfsmount.h
--- a/sys/fs/msdosfs/msdosfsmount.h
+++ b/sys/fs/msdosfs/msdosfsmount.h
@@ -114,6 +114,7 @@
void *pm_w2u; /* Unicode->Local iconv handle */
void *pm_u2d; /* Unicode->DOS iconv handle */
void *pm_d2u; /* DOS->Local iconv handle */
+ u_short pm_rootdirfree; /* number of free slots in FAT12/16 root directory */
#ifndef MAKEFS
struct lock pm_fatlock; /* lockmgr protecting allocations */
struct lock pm_checkpath_lock; /* protects doscheckpath result */
@@ -222,6 +223,22 @@
? roottobn((pmp), (dirofs)) \
: cntobn((pmp), (dirclu)))
+/*
+ * Decrement the number of used entries in a fixed size FAT12/16 root
+ * directory
+ */
+#define rootde_alloced(dep) \
+ if ((dep)->de_StartCluster == MSDOSFSROOT) \
+ (dep)->de_pmp->pm_rootdirfree--;
+
+/*
+ * Increment the number of used entries in a fixed size FAT12/16 root
+ * directory
+ */
+#define rootde_freed(dep) \
+ if ((dep)->de_StartCluster == MSDOSFSROOT) \
+ (dep)->de_pmp->pm_rootdirfree++;
+
#define MSDOSFS_LOCK_MP(pmp) \
lockmgr(&(pmp)->pm_fatlock, LK_EXCLUSIVE, NULL)
#define MSDOSFS_UNLOCK_MP(pmp) \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 18, 12:13 AM (11 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30476428
Default Alt Text
D38987.1792282403.diff (3 KB)
Attached To
Mode
D38987: Count used root directory entries in FAT12/16 file systems
Attached
Detach File
Event Timeline
Log In to Comment