Skip to content

libfatx: Allow 42-character file names - #107

Merged
mborgerson merged 1 commit into
XboxDev:masterfrom
xmutantson:libfatx-allow-42-char-names
Oct 29, 2026
Merged

mborgerson merged 1 commit into
XboxDev:masterfrom
xmutantson:libfatx-allow-42-char-names

Conversation

@xmutantson

Copy link
Copy Markdown
Contributor

A FATX directory entry holds names of up to 42 bytes (FATX_MAX_FILENAME_LEN), but fatx_create_dirent() and fatx_rename() rejected names with strlen(...) >= FATX_MAX_FILENAME_LEN, so the maximum was effectively 41. Retail games ship files whose names are exactly 42 characters (for example 10_Good_Epilogue_Comp_Sisterkilled_PAL.xmv in Fable, and over a hundred in Tony Hawk's American Wasteland's data/animsaves), and copying them with fatxfs fails with Operation not permitted.

The in-memory buffers (struct fatx_dirent, struct fatx_attr) are FATX_MAX_FILENAME_LEN + 1 bytes, and the on-disk field is FATX_MAX_FILENAME_LEN bytes with the length stored in filename_len, so a 42-character name already fits everywhere it is copied; only the three checks change from >= to >.

Added test_filename_max_length to pyfatx/tests/test.py: create, read, list and rename a 42-character name, and check that 43 characters is still refused. It fails on master and passes with this change; the rest of the suite passes either way.

This is independent of #106; both append a test to the end of test.py, so whichever lands second may need a trivial rebase.

A FATX directory entry holds names of up to 42 bytes (FATX_MAX_FILENAME_LEN),
and retail games ship files with names of exactly that length. The length
checks in fatx_create_dirent() and fatx_rename() used >=, so those names
were rejected and copying such a file failed with EPERM.

The in-memory name buffers are FATX_MAX_FILENAME_LEN+1 bytes and the
on-disk field is FATX_MAX_FILENAME_LEN bytes with the length stored
separately, so a 42-character name already fits everywhere it is copied.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the change enabling FATX’s full 42-byte filename capacity.

No open issues 🎉

What changed in this PR

Fixes an off-by-one limit in libfatx so file creation and renaming accept the full 42-byte filename capacity supported by FATX.

Changes:

  • Allow names exactly FATX_MAX_FILENAME_LEN bytes long while retaining rejection of longer names.
  • Add regression coverage for creating, reading, listing, and renaming 42-character names, plus rejecting 43-character names during creation.
File Description
pyfatx/​tests/​test.py Adds filename-length boundary regression coverage.
libfatx/​fatx_file.c Allows 42-byte source and destination basenames during rename.
libfatx/​fatx_dir.c Allows 42-byte basenames when creating directory entries.

Review effort: Balanced

@mborgerson
mborgerson merged commit b42fd39 into XboxDev:master Oct 29, 2026
18 checks passed
@mborgerson

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants