Re: FAT32 statfs(2) inode usage

From: Stefan Esser <se_at_FreeBSD.org>
Date: Tue, 07 Mar 2023 10:11:22 UTC
Am 06.03.23 um 13:43 schrieb Ben Woods:
> I think my issue stems from the fact that the msdosfs_vfsops.c code is using the f_files limit variable to represent the FAT root directory entities limit, but is not using the corresponding f_ffree available variable to represent the current number of root directory entities. This leads to the df(1) output incorrectly implying that the number of root directory entities is at capacity.

Yes, true ...

This is the current code in msdosfs_statfs():

	sbp->f_files = pmp->pm_RootDirEnts;     /* XXX */
	sbp->f_ffree = 0;       /* what to put in here? */

The comment says it all ...

> To avoid this confusion, I think the msdosfs_vfsops.c should either set both the f_files and f_ffree statfs variables so that df(1) correctly reports %iused, or should set them both to zero so that df(1) shows %iused as "-".
> 
> Thoughts?

I could implement a counter that provides a useful value for f_ffree by
counting all file and directory creations and removals from the root
directory of a FAT12/FAT16 file system.

That would probably only take 1 hour of work for development and testing,
but I'd want/need a review before committing to msdosfs.

(I had stopped working on FreeBSD some 5 months ago because of frustration
about the lack of response to many changes put up for review over the
last few years, and have just got back to looking into the mail lists
a few days ago. I used to spend >100 hours a month working on FreeBSD
issues since joining the project in the 90s.)

If you are interested in testing / review of the proposed change, I'll
try to provide it ...

Regards, STefan