hfsplus: fix "Illegal name" fsck failures from non-canonical decomposition
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | hfsplus: add Unicode combining-class and legacy decomposition datafs/ fs/ fs/ +2 more | +459 | 0 replies | |
| 2/3 | hfsplus: canonicalize decomposed catalog names like fsck_hfs expectsfs/ fs/ fs/ | +360 | 0 replies | |
| 3/3 | hfsplus: add KUnit coverage for canonical reordering and legacy fixupsfs/ | +308 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] hfsplus: fix "Illegal name" fsck failures from non-canonical decomposition
The xfstests generic/339 (fsstress-style dirhash collision testing) leaves an HFS+ volume corrupted and, as a result, fsck.hfsplus reports a long run of "Illegal name".
The root cause is that fs/hfsplus/unicode.c's decomposition table (Apple Technote #1150) decomposes each source character entirely on its own and never does anything further with the result. Real fsck_hfs has carried a permanent "FixDecomps" fixup in CatalogCheck.c for exactly what that leaves unhandled:
- combining marks contributed by two different source characters landing adjacent must be in ascending Unicode combining-class order, not just input order;
- a small, fixed set of characters either weren't decomposed at all, or were decomposed into a sequence Apple corrected back in Mac OS X 10.2 ("Jaguar"), and this driver's table still predates that.
A name that violates either of these gets flagged "Illegal name" by any real macOS system (or fsck_hfs) that later reads the volume, even though nothing else about it is wrong.
This series makes hfsplus store, hash and compare names the same way current macOS does:
1/3 adds the data: a Unicode combining-class table generated from UCD
12.1.0, and two legacy-decomposition correction tables decoded programmatically from hfsprogs 540.1's own DecompData.h. Pure data, no behavior change.
2/3 adds the logic that uses that data: canonical reordering of
decomposed names, a fallback to the legacy decomposition table, and legacy sequence substitution, all applied in hfsplus_asc2uni() so this is what actually gets stored. hfsplus_hash_dentry() and hfsplus_compare_dentry() are reworked to canonicalize names the same way, so a lookup can't disagree with what a create() of the same name actually wrote.
3/3 adds KUnit coverage for both: reordering, stability of equal-class
marks, the legacy decomposition and sequence fixups, and that hashing/comparison agree across differently-typed-but-equivalent spellings of the same name.
Viacheslav Dubeyko (3):
hfsplus: add Unicode combining-class and legacy decomposition data
hfsplus: canonicalize decomposed catalog names like fsck_hfs expects
hfsplus: add KUnit coverage for canonical reordering and legacy fixups
fs/hfsplus/hfsplus_fs.h | 6 +- fs/hfsplus/tables.c | 496 ++++++++++++++++++++++++++++++++++++++ fs/hfsplus/unicode.c | 390 ++++++++++++++++++++---------- fs/hfsplus/unicode.h | 63 +++++ fs/hfsplus/unicode_test.c | 309 ++++++++++++++++++++++++ 5 files changed, 1127 insertions(+), 137 deletions(-) create mode 100644 fs/hfsplus/unicode.h
Signature · 1 line
2.43.0