[PATCH 0/2] hfs/hfsplus: set s_maxbytes from the volume capacity
From: Viacheslav Dubeyko
Date: Thu Nov 05 2026 - 19:52:51 EST
HFS and HFS+ do not support sparse files: every byte of a file
up to end-of-file has to be backed by an allocated block. As a
result, a write, truncate or copy_file_range() far beyond the
current end-of-file makes the driver zero-fill the whole gap,
which runs out of free space and fails with -ENOSPC rather than
reporting -EFBIG.
Since a file can never be larger than the volume, this series sets
s_maxbytes to the volume capacity instead (capped by
MAX_LFS_FILESIZE for HFS+ and by MAX_NON_LFS for HFS). The VFS then
returns -EFBIG for write(), copy_file_range(), truncate and
fallocate beyond the limit, and trims writes that straddle it. The
now redundant local checks are removed.
Viacheslav Dubeyko (2):
hfsplus: set s_maxbytes from the volume capacity
hfs: set s_maxbytes from the volume capacity
fs/hfs/inode.c | 7 -------
fs/hfs/super.c | 8 ++++++++
fs/hfsplus/inode.c | 7 -------
fs/hfsplus/super.c | 10 +++++++++-
4 files changed, 17 insertions(+), 15 deletions(-)
--
2.43.0