freebsd-nq/bin
Stefan Eßer c33db74b53 fs/msdosfs: add tracking of free root directory entries
This update implements tallying of free directory entries during
create, delete,	or rename operations on FAT12 and FAT16 file systems.

Prior to this change, the total number of root directory entries
was reported as number of inodes, but 0 as the number of free
inodes, causing system health monitoring software to warn about
a suspected disk full issue.

The FAT12 and FAT16 file systems provide a limited number of
root directory entries, e.g. 512 on typical hard disk formats.
The valid range of values is 1 to 65535, but the msdosfs code
will effectively round up "odd" values to the next multiple of 16
(e.g. 513 would allow for 528 root directory entries).

This update implements tracking of directory entries during create,
delete, or rename operations, with initial values determined by
scanning the directory when the file system is mounted.

Total and free directory entries are reported in the f_files and
f_ffree elements of struct statfs, despite differences in semantics
of these values:

- There is no limit on the number of files and directories that can
  be created on a FAT file system. Only the root directory of FAT12
  and FAT16 file systems is limited, any number of files can still be
  created in sub-directories, even when 0 free "inodes" are reported.

- A single file can require 1 to 21 directory entries, depending on
  the character set, structure, and length of the name. The DOS 8.3
  style file name takes up 1 entry, and if the name does not comply
  with the syntax of a DOS 8.3 file name, 1 additional entry is used
  for each 13 characters of the file name. Since all these entries
  have to be contiguous, it is possible that a file or directory with
  a long name can not be created, despite a sufficient total number of
  free directory entries.

- Renaming a file can require more directory entries than currently
  allocated to store its long name, which may prevent an in-place
  update of the name if more entries are needed. This may cause a
  rename operation to fail if no contiguous range of free entries for
  the new name can be found.

- The volume label is stored in a directory entry. An empty FAT file
  system with a volume label will therefore show 1 used "inode" in
  df.

- The perceentage of free inodes shown in df or monitoring tools does
  only represent the state of the root directory of a FAT12 or FAT16
  file system. Neither does a reported value of 0% free inodes does
  prevent files from being created in sub-directories, nor does a
  value of 50% free inodes guarantee that even a single file with
  a "long" name can be created in the root directory (if every other
  directory entry is occupied and there are no 2 contiguous entries).

The statfs(2) and df(1) man pages have been updated with a notice
regarding the possibly different semantics of values reported as
total and free inodes for non-Unix file systems.

PR:		270053
Reported by:	Ben Woods <woodsb02@freebsd.org>
Approved by:	mckusick
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D38987
2023-03-29 08:46:01 +02:00
..
cat cat: style nits 2021-01-20 18:46:26 +01:00
chflags fts_read: Handle error from a NULL return better. 2020-12-08 23:38:26 +00:00
chio chio: Mark some arguments as unused. 2022-10-25 10:57:29 -06:00
chmod fts_read: Handle error from a NULL return better. 2020-12-08 23:38:26 +00:00
cp cp: Adjust the sparse file tests. 2023-02-08 16:49:50 +00:00
csh csh: install hard link with same mode as target 2022-11-29 16:04:05 -05:00
date date.1: Examples: Use syntax that is also compatible with csh 2023-02-27 17:37:28 +01:00
dd Add O_DIRECT flag to DD for cache bypass 2020-06-04 20:47:11 +00:00
df fs/msdosfs: add tracking of free root directory entries 2023-03-29 08:46:01 +02:00
domainname pkgbase: Put yellow pages programs to its own package 2021-12-21 10:17:22 +01:00
echo echo(1): Replace errexit() with err(3) 2021-11-09 22:12:19 +01:00
ed ed(1): Add two references in the SEE ALSO section 2021-04-09 09:43:49 +02:00
expr expr(1): Fix overflow detection when operand is INTMAX_MIN 2018-04-14 04:35:10 +00:00
freebsd-version freebsd-version(1): Add -j flag to support jails 2021-10-01 13:50:56 -05:00
getfacl Fix build of bin/getfacl after libc changes. 2021-08-27 11:52:18 +03:00
hostname hostname: avoid strcpy() overlap in -d flag handling 2021-09-25 00:03:50 -05:00
kenv kenv: allow listing of static kernel environments 2021-07-18 23:06:19 -05:00
kill General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
ln General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
ls ls(1): add a -v flag to sort naturally 2022-10-31 00:00:42 +01:00
mkdir src/bin/mkdir: Spell occur correctly. 2021-10-02 10:39:31 -06:00
mv General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
nproc nproc: denote an incompatiblity with Linux 2023-02-15 20:43:46 +00:00
pax pax: update date parsing code (from OpenBSD) 2022-10-19 17:02:45 +00:00
pkill pkill: tests: do a pass for case-sensitive conflicts 2023-03-20 14:54:54 -05:00
ps ps(1): Use calloc instead of malloc and memset. 2022-03-11 10:36:00 +01:00
pwait Fix typo in pwait.c introduced in 5bdce6ff54 2021-01-21 21:43:27 +00:00
pwd pwd(1): Add EXAMPLES section 2020-10-24 16:42:35 +00:00
realpath realpath(1): Add EXAMPLES section. 2020-10-20 13:15:26 +00:00
rm fts_read: Handle error from a NULL return better. 2020-12-08 23:38:26 +00:00
rmail DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
rmdir General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
setfacl Remove unused headers. 2020-12-12 02:26:43 +00:00
sh sh(1): fix history file write checking 2023-03-20 17:56:56 +01:00
sleep sleep.1: Fix mdoc style 2022-05-25 10:11:33 +02:00
stty stty(1): provide details about interaction with job control 2022-10-02 20:29:53 +03:00
sync DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
test Remove unused includes. 2020-12-22 21:04:36 -08:00
tests
timeout timeout: Move from /usr/bin to /bin 2023-02-02 18:34:35 +01:00
uuidgen uuidgen(1): fix another typo 2023-03-06 09:03:52 +01:00
Makefile Add nproc(1) 2023-02-08 19:47:33 +00:00
Makefile.inc build: provide a default WARNS for all in-tree builds 2020-09-18 17:17:46 +00:00