Repository navigation
libfatx: Allow 42-character file names - #107
Merged
mborgerson merged 1 commit intoOct 29, 2026
Merged
Conversation
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.
There was a problem hiding this comment.
🟢 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_LENbytes 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
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A FATX directory entry holds names of up to 42 bytes (
FATX_MAX_FILENAME_LEN), butfatx_create_dirent()andfatx_rename()rejected names withstrlen(...) >= FATX_MAX_FILENAME_LEN, so the maximum was effectively 41. Retail games ship files whose names are exactly 42 characters (for example10_Good_Epilogue_Comp_Sisterkilled_PAL.xmvin Fable, and over a hundred in Tony Hawk's American Wasteland'sdata/animsaves), and copying them withfatxfsfails withOperation not permitted.The in-memory buffers (
struct fatx_dirent,struct fatx_attr) areFATX_MAX_FILENAME_LEN + 1bytes, and the on-disk field isFATX_MAX_FILENAME_LENbytes with the length stored infilename_len, so a 42-character name already fits everywhere it is copied; only the three checks change from>=to>.Added
test_filename_max_lengthtopyfatx/tests/test.py: create, read, list and rename a 42-character name, and check that 43 characters is still refused. It fails onmasterand 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.