[44-dev][x86_64] CIFS: file inside a just-renamed directory with non-ASCII name cannot be opened (EINVAL) - breaks RPCS3 trophies when saves are on a network share

Open
#16,591 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
linux

Research direction

Start by running the supplied Python reproduction on the CIFS share and comparing it with local ext4; the failure occurs when opening a file immediately after renaming a directory with a non-ASCII name. Investigate the kernel SMB/CIFS client behavior around that rename and open sequence. Done means the immediate open succeeds on the CIFS mount without the delay, while the ASCII-name and ext4 cases continue to work.

Written by the indexing model from the issue text.

Description

cannot reproduce
Batocera build version

44c2u7-dev-4ee7082784 2026/09/20 16:52 (also reproduced on 44c2u7-dev-0fabc0cfd6 2026/09/17), kernel 7.1.9

Your architecture

X86_64 (mini PC, AMD Ryzen 7 7840HS)

Your Graphic Processor Unit(s) (GPU)

Integrated AMD Radeon 780M (RADV PHOENIX)

Issue description

With /userdata/saves on an SMB/CIFS network share, many PS3 games crash in RPCS3 the first time they register their trophies:

·E Trophy: TROPUSRLoader::Load(): Failed to generate TROPUSR.DAT (path='/userdata/saves/ps3/rpcs3/dev_hdd0/home/00000001/trophy/NPWR00117_00/TROPUSR.DAT', cfg='/dev_hdd0/home/00000001/trophy/NPWR00117_00/TROPCONF.SFM', Invalid arguments)
·F {PPU[0x100000c] Thread (Trophy thread)} SIG: Thread terminated due to fatal error: Verification failed (object: 0x0)
(in file .../rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp:718[:2], in function 'error_code sceNpTrophyRegisterContext()') (errno=22=Invalid argument)

In our setup, 7 of 47 PSN titles crashed this way (e.g. Super Stardust HD, Tokyo Jungle, RayStorm HD, Legasista).

Root cause (isolated): the kernel SMB client in Batocera's kernel 7.1.9. If a directory whose name contains any non-ASCII character is renamed, opening a file inside the renamed directory fails with EINVAL for about one second. After that it works again.

RPCS3 hits this on every trophy install. TRPLoader::Install() extracts into <dir>.$temp$<n>, which contains U+FF04 FULLWIDTH DOLLAR SIGN, and renames that to <dir>. TROPUSRLoader::Generate() then immediately opens TROPCONF.SFM in it and gets EINVAL, which triggers the ensure() at sceNpTrophy.cpp:718.

RPCS3 is not at fault, and neither is the NAS:

  • The same sequence in Python on the same Batocera box fails on the CIFS mount and works on local ext4.
  • The same sequence from a macOS SMB client against the same NAS folder works for every character.
Temp dir suffix before rename Batocera → NAS (CIFS) Batocera local ext4 macOS → same NAS folder
.tmpx, .$temp$1 (ASCII) ok ok ok
.ätemp, .€temp, .$temp$1, .Atemp, .😀temp EINVAL ok ok

Mount options make no difference. Tested: vers=3.0 / vers=3.1.1, with and without iocharset=utf8, noserverino, nomapposix, nomapchars, cache=none, actimeo=0.

This probably affects other emulators too: any program that renames a directory with a non-ASCII name on a network share and opens files in it right away.

Detailed reproduction steps
  1. Mount saves from an SMB server via sharenetwork_smb (here: UGREEN NAS, SMB 3.0; options vers=3.0,iocharset=utf8,noserverino).
  2. Run on the Batocera box:
import os, shutil
base = "/userdata/saves/test"            # any directory on the CIFS share
os.makedirs(base, exist_ok=True)
fin, tmp = base + "/DIR", base + "/DIR.ätemp"   # any non-ASCII char in the old name
os.mkdir(tmp); open(tmp + "/F", "wb").write(b"x")
os.rename(tmp, fin)
os.open(fin + "/F", os.O_RDONLY)         # -> OSError: [Errno 22] Invalid argument

With time.sleep(1.5) before the open(), or with an ASCII-only temp name, it works.

  1. In RPCS3: launch any PSN/disc game whose trophies were not yet installed (dev_hdd0 = /userdata/saves/ps3/rpcs3/dev_hdd0 on the share) → fatal error in sceNpTrophyRegisterContext.
Details of any attempts to fix this yourself

Workaround: bind-mount a local directory over saves/ps3/rpcs3/dev_hdd0/home/00000001/trophy at boot, using a user service. After that, all 7 affected games register their trophies and run. A proper fix would need to land in the kernel SMB client (or in a newer kernel if it is already fixed upstream). An alternative is for RPCS3 to use an ASCII-only temp directory name.

Details of any modifications you have made to Batocera.

/userdata is local ext4. roms, saves and bios come from a NAS via sharenetwork_smb1..3. There are user services for an AMD reboot workaround and for the local trophy bind-mount described above.

Logs and data

RPCS3 v0.0.42 (Batocera build). Relevant RPCS3.log lines are quoted above. The kernel log shows nothing for the failing open().

Dominant language
Python
Stars
3.2k
Forks
748
Avg merge
9h 51m
Merged PRs (30d)
170

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from batocera-linux/batocera.linux

All issues in batocera-linux/batocera.linux

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.