freebsd-dev/lib
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
..
atf Retire WITHOUT_CXX option 2023-01-26 21:13:16 -05:00
clang Ensure .inc files are regenerated when llvm/clang tblgen binaries change 2023-02-26 15:56:07 +01:00
csu csu: move common code to libc 2023-03-12 00:50:03 +02:00
flua flua: Fix a typo in a source code comment 2022-09-15 10:25:54 +02:00
geom geli: split the initalization of HMAC 2023-02-08 10:01:58 -08:00
googletest googletest: remove unused auto_ptr warning suppression 2022-11-30 19:34:52 -05:00
lib9p bhyve: Move libcasper dependecy to lib9p 2023-03-07 11:09:22 -05:00
lib80211
libalias
libarchive libarchive: merge from vendor branch 2022-12-13 20:21:13 +01:00
libauditd
libbe libbe: Avoid double printing cloning errors. 2023-03-14 21:15:17 -06:00
libbearssl bearssl: Suppress warnings from functions that have no args 2023-02-13 08:19:40 -07:00
libbegemot libbegemot: Disable -Wuse-after-free. 2022-10-03 16:10:43 -07:00
libblacklist
libblocksruntime
libbluetooth bluetooth: Remove one more h4 reference. 2021-09-29 22:02:25 -06:00
libbsddialog contrib/bsddialog: Import version 0.4 2022-09-25 15:09:16 +02:00
libbsdstat
libbsm
libbsnmp pkgbase: Put the mibs and defs in the bnsmp package 2021-06-19 17:50:03 +02:00
libbz2
libc fs/msdosfs: add tracking of free root directory entries 2023-03-29 08:46:01 +02:00
libc_nonshared libc_nonshared: Move to clibs package 2022-11-01 10:17:07 +00:00
libc++ Merge llvm-project release/15.x llvmorg-15.0.2-10-gf3c5289e7846 2023-02-08 20:05:09 +01:00
libc++experimental Merge llvm-project main llvmorg-15-init-15358-g53dc0f10787 2023-02-08 20:02:26 +01:00
libcalendar
libcam cam_get_device: resolve path links before parsing device name 2022-01-26 11:25:31 +02:00
libcapsicum
libcasper libcasper.3: document cap_init's single-threaded program requirement 2023-01-10 20:53:30 -07:00
libcbor Add libcbor to the build 2021-10-15 15:10:24 -04:00
libclang_rt Merge llvm-project release/15.x llvmorg-15.0.7-0-g8dfdcc7b7bf6 2023-02-08 20:05:25 +01:00
libcom_err pkgbase: Create a FreeBSD-kerberos package 2021-09-07 10:23:14 +02:00
libcompat
libcompiler_rt compiler-rt: remove eprintf 2023-03-14 13:13:51 -04:00
libcrypt libcrypt: Drop inclusion of libutil.h 2021-12-07 00:24:19 +00:00
libcuse cuse(3): Make some clarifications in the manual page. 2022-07-20 10:41:11 +02:00
libcxxrt Sort SRCS in libcxxrt's Makefile, and use += to list sources 2022-01-22 21:08:55 +01:00
libdevctl libdevctl: Add devctl_getpath 2022-03-01 08:06:41 -07:00
libdevdctl libdevdctl: update deprecated deprecation warning comment 2022-12-04 10:17:37 -05:00
libdevinfo pkgbase: Put devmatch in its own package 2022-10-26 19:46:38 +02:00
libdevstat
libdl
libdpv Indicate the port where the referenced man pages come from. 2022-08-16 20:57:30 +02:00
libdwarf libdwarf: Add some constants from DWARF 5 2023-02-07 15:10:24 -05:00
libedit libedit: Disable -Wuse-after-free for chartype.c. 2022-10-03 16:10:43 -07:00
libefivar efivar: Really look for labels for the provider with right efimedia 2023-02-16 08:54:39 -07:00
libelf libelf: Link gelf_getchdr.3 to the build 2021-11-29 13:57:24 -05:00
libelftc pkgbase: Create a FreeBSD-elftoolchain package 2023-02-08 08:49:12 +01:00
libevent1
libexecinfo
libexpat MFV: expat 2.5.0 2022-11-17 22:15:00 -08:00
libfetch libfetch: Pass a zeroed digest to DigestCalcResponse. 2022-11-15 19:18:58 -08:00
libfido2 Add libfido2 to the build 2021-10-22 19:57:57 -04:00
libfigpar
libgcc_eh Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90 2022-05-14 13:45:25 +02:00
libgcc_s Export _Unwind_Complete and _Unwind_VRS_Pop from arm's libgcc_s 2022-04-27 11:04:10 +02:00
libgeom Reference correct section for free(3). 2022-09-17 13:12:44 +02:00
libgpio
libgssapi pkgbase: split kerberos binaries and libs 2022-08-03 11:02:28 +01:00
libiconv_modules libiconv VIQR: Fix a use after free. 2022-10-03 16:10:43 -07:00
libifconfig carp: support unicast 2023-03-20 14:37:09 +01:00
libipsec libipsec: ansify 2023-03-16 19:19:35 +00:00
libipt
libiscsiutil libiscsiutil: Fix a typo in a source code comment 2023-01-11 11:52:55 +01:00
libjail Refer to a related manpage 2023-02-04 08:22:28 -07:00
libkiconv
libkvm kvm_close(3): Check kd->sparse_map != NULL before munmap 2022-10-16 16:49:16 +00:00
libldns ldns: Disable -Warray-parameter warnings from GCC 12 on sha2.c. 2022-09-28 14:02:30 -07:00
liblua lua: Update to 5.4.4 2023-02-08 10:33:26 -07:00
liblutok Explicitly set CXXSTD to c++11 for old C++ code using std::auto_ptr<>. 2022-12-04 16:25:21 -08:00
liblzma MFV: xz 5.4.2. 2023-03-19 19:30:08 -07:00
libmagic file: upgrade to 5.43. 2022-09-24 19:16:39 -07:00
libmd libmd: ansify 2023-03-16 19:02:56 +00:00
libmemstat sys/bitset.h: reduce visibility of BIT_* macros 2021-12-05 23:00:25 +01:00
libmilter Add -DSTARTTLS CFLAG in order to enable DANE in sendmail builds 2023-01-15 21:24:38 +00:00
libmixer mixer(3): Add HEADNAME to TAILQ_HEAD declarations in man page 2023-01-24 09:10:49 -05:00
libmp
libmt mt(3): Fix a typo in the manual page 2022-04-06 18:41:08 +02:00
libnetbsd libnetbsd: Fix a typo in a source code comment 2022-04-02 14:53:56 +02:00
libnetgraph ng_atmllc: remove 2023-03-09 18:04:21 +00:00
libnetmap pkgbase: Create a FreeBSD-netmap package 2023-02-08 08:49:28 +01:00
libnv libnv: bump library version 2022-07-22 00:23:08 +02:00
libomp Merge llvm-project main llvmorg-15-init-15358-g53dc0f10787 2023-02-08 20:02:26 +01:00
libopenbsd
libopencsd Include Embedded Trace Extensions (ETE) source code to the OpenCSD build. 2023-03-27 17:10:26 +01:00
libpam pam.d: install hard link with same mode as target 2022-11-24 08:14:44 -05:00
libpathconv libpathconv: bump man page dates 2022-08-09 10:05:31 +02:00
libpcap
libpe
libpfctl libpfctl: Don't pass stack garbage to free. 2023-03-22 12:33:59 -07:00
libpjdlog
libpmc libpmc: Use LIB_CXX instead of explicit LDADD to link a C++ library. 2023-03-23 09:31:58 -07:00
libpmcstat libpmcstat: Fix a few ARM-specific issues with function symbols. 2022-03-10 15:39:53 -08:00
libproc Retire WITHOUT_CXX option 2023-01-26 21:13:16 -05:00
libprocstat libprocstat: forward declare struct kinfo_proc 2022-08-26 23:20:32 +01:00
libradius libradius: fix WITHOUT_OPENSSL build 2021-10-28 17:05:53 -04:00
libregex pkgbase: Put more binaries/lib in runtime 2021-12-21 10:17:27 +01:00
librpcsec_gss Correct a typo in man page references: rpcset_gss -> rpcsec_gss. 2022-09-16 22:38:42 +02:00
librpcsvc pkgbase: Put more binaries/lib in runtime 2021-12-21 10:17:27 +01:00
librss librss: Remove rss_socket_set_rss_bucket() 2023-02-28 15:57:11 -05:00
librt Fix aio_readv(2), aio_writev(2) with SIGEV_THREAD. 2021-08-22 23:49:23 +12:00
librtld_db librtld_db: Handle shlibs with discontiguous mappings. 2021-12-03 11:07:30 -08:00
libsbuf
libsdp
libsecureboot lib/libsecureboot: Fix some typos 2022-11-11 10:38:39 -05:00
libsm Update for new library files in sendmail 8.17.1 2023-01-15 21:23:27 +00:00
libsmb pkgbase: Create a FreeBSD-smbutils package 2023-02-08 08:48:28 +01:00
libsmdb
libsmutil Add -DSTARTTLS CFLAG in order to enable DANE in sendmail builds 2023-01-15 21:24:38 +00:00
libsqlite3
libssp
libssp_nonshared
libstats
libstdbuf
libstdthreads
libsysdecode linux(4): Rename linux_timer.h to linux_time.h 2023-02-14 17:46:33 +03:00
libtacplus
libtelnet
libthr libthr pshared: correct a bug in allocation 2023-02-02 00:59:27 +02:00
libthread_db arm: Add support for using VFP in kernel 2023-02-04 20:21:43 +01:00
libucl
libufs Fix for tunefs(8) unable to add a UFS/FFS soft update journal. 2022-11-12 15:37:27 -08:00
libugidfw
libulog
libunbound unbound: Reapply Vendor import 1.17.0 2022-10-16 14:08:33 -07:00
libusb libusb(3): Implement libusb_interrupt_event_handler() by exposing existing function. 2022-10-02 17:32:59 +02:00
libusbhid usbhid(3): Fix a typo in the manual page 2022-06-04 19:54:25 +02:00
libutil Allow a comma-separated list in login class capabilities, 2023-01-14 10:48:29 -08:00
libveriexec
libvgl
libvmmapi bhyve: Remove vmctx member from struct vm_snapshot_meta. 2023-03-24 11:49:06 -07:00
libwrap pkgbase: Put libwrap in FreeBSD-tcpd package 2022-10-26 19:46:32 +02:00
libxo Import Juniper libxo-1.6.0 2023-01-30 13:37:33 -05:00
liby
libypclnt pkgbase: Put more binaries/lib in runtime 2021-12-21 10:17:27 +01:00
libz libz: silence K&R warns 2023-03-16 18:22:24 +00:00
libzstd cppcheck: explicitly exclude kernel code from userspace checks 2022-05-10 10:20:55 -07:00
msun libc: Simplify soft-float on 32-bit arm 2023-02-14 09:53:08 -07:00
ncurses pkgbase: Put libpanelw and libform in FreeBSD-clibs 2023-02-08 08:49:59 +01:00
ofed libirdma: Drop clang-specific -ferror-limit. 2022-10-03 16:10:42 -07:00
tests
Makefile NgATM: Remove netgraph ATM support 2023-03-09 18:04:02 +00:00
Makefile.inc