[PATCH 0/2] hfsplus: make hidden directory name independent from nls

From: Viacheslav Dubeyko

Date: Tue Nov 03 2026 - 22:46:29 EST


HFS+ keeps the indirect node files of hard links in the hidden
directory of the root folder. On disk, its name is four U+0000 (NUL)
characters followed by "HFS+ Private Data". Currently, the catalog key
of this directory is built from the UTF-8 string HFSP_HIDDENDIR_NAME
by means of the nls table of the mount. hfsplus_fill_super() works
around it by temporarily replacing sbi->nls with utf8 table, but
hfsplus_reconfigure() creates the hidden directory on remount
read-write with the mount's nls table. As a result, with nls=cp437,
for example, the hidden directory is created with garbled name that
neither macOS nor the next mount recognizes.

At first, define the on-disk name of the hidden directory as
constant UTF-16 string hfsplus_hidden_dir_name_utf16, introduces
hfsplus_create_cat_uni() that creates catalog records for already
converted name, and removes the temporary nls replacement from
hfsplus_fill_super(). The length of the name is calculated from named
constants, and the UTF-8 and UTF-16 representations of the name are
distinguished by the HFSP_HIDDENDIR_NAME_UTF8* and
HFSP_HIDDENDIR_NAME_UTF16_LEN macros.

Secondly, add KUnit test that checks that hfsplus_asc2uni()
converts HFSP_HIDDENDIR_NAME_UTF8 with utf8 nls table into exactly
hfsplus_hidden_dir_name_utf16, with decomposition enabled and
disabled.

The hfsplus_unicode KUnit suite passes (35 tests) under UML.

Viacheslav Dubeyko (2):
hfsplus: make hidden directory name independent from mount's nls
hfsplus: add KUnit check for hidden directory name

fs/hfsplus/catalog.c | 83 ++++++++++++++++++++++++++++++--------
fs/hfsplus/hfsplus_fs.h | 6 +++
fs/hfsplus/super.c | 68 +++++++++++++++++--------------
fs/hfsplus/unicode_test.c | 55 +++++++++++++++++++++++++
include/linux/hfs_common.h | 20 ++++++++-
5 files changed, 182 insertions(+), 50 deletions(-)


base-commit: 71d5a8a05c83b61bce1884905c192eed34ed3069
--
2.43.0