feat(libSceUsbStorage): pass the host's USB FAT and exFAT volumes through #11046
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11046"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by simnJS on 2026-10-25T15:05:41Z.
What
libSceUsbStorage can pass the host's USB drives through instead of always answering "no device".
Switch: the passthrough is off unless
APS5_USB_STORAGE_PASSTHROUGHis set (documented indocs/dev/ENVIRONMENT.md). Unset, no host volume is scanned or exposed and the guest sees no USB storage, as onmain.Devices: the FAT and exFAT volumes the host has mounted from USB mass-storage devices. Linux reads
/proc/self/mountinfoand keeps whole-file-systemvfat/msdos/exfatmounts whose sysfs block device has a USB interface of class 08 among its ancestors. Windows keeps the FAT/FAT32/exFAT drive letters whose storage descriptor reportsBusTypeUsb, and reads VID/PID/revision through SetupAPI and CfgMgr. macOS lists none.Lifecycle:
sceUsbStorageInitbuilds the list and starts a service thread (scePthreadCreate) that rescans once a second;sceUsbStorageTermjoins it and frees the list, as the debt entry asked. A volume keeps the lowest free of eight ids while it stays mounted, and/mnt/usb<id>resolves to it through a libc path alias.Callbacks:
sceUsbStorageRegisterCallback/Unregisterdeliver SharpProspero's recovered 16-byte event (1 mount, 2 unmount, device id, flags) to the callbacks of that event type.Device info: the 0x338-byte record (SharpProspero layout, shadPS4 ids/lengths/flag bits) with the file-system capacity, SCSI inquiry vendor/product, USB serial and flags (read-only, FAT, exFAT).
Paths and scans:
GetMountPointOfShellCore,IsExist,RequestMap/RequestMapWSB/RequestUnmapand the getdents scan follow shadPS4's virtual-device model for the filled paths, as the debt entry asked.Unknown answers: these still throw or keep the marker. They include a non-null
Initattribute, nonzero map flags or volume size, a second map of a directory, unmapping something not mapped, closing a scan that is not open, and the map-available/unavailable callbacks.docs/dev/debt/libSceUsbStorage.mdis rewritten around what is still unverified.Tested
BUILD_TESTING=ON):ctest -R '^guest_usb_storage$'passes, five runs in a row, about 3 s each.vfat, a USBext4and a bind mount of a subdirectory./mnt/usb0.public_headers*,conventions_*,test_registration,env_reference,progress_*pass.cmake --build build --target libssucceeds.python3 tools/check_conventions.py --base upstream/mainpasses.ctest -R '^guest_usb_storage$'passes, ten runs in a row, about 10 s each.sceUsbStorageInitor after a rescan, no mount event arrives, device 0 has no info and cannot be mapped, and/mnt/usb0does not reach the volume. Without the check inScanHostVolumesit fails.tools/pr_overlap.pycould not run, becauseghis not authenticated here. The merge refs of the 1303 open pull requests show none touchinglibSceUsbStorageorlibSceAutoMounterClient.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:16:26Z.
Review: CHANGES_REQUESTED
On Windows, RelativeDirectory accepts a drive-qualified value such as C:/Windows because it only rejects backslashes and dot components. Map then constructs a filesystem path from that string and appends it to the selected volume root. A Windows filesystem path with a different root name replaces the left-hand path during operator/=, so is_directory can check C:/Windows instead of the USB volume. If that directory exists, the request succeeds but returns a path under /mnt/usbN that does not refer to the directory that was checked. A drive-relative value such as C:Windows can also carry a root name. Please reject root names and root directories before joining, or build the host path from validated relative components, and add Windows regression coverage for a different-drive path.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:28:35Z.
Review: DISMISSED
The Windows root-path escape I reported on the previous head is fixed in
4de4eeff2e46d057c9a442046f6b2bbec213f773:DirectoryNamesrejects a root path before joining validated components, and the tests cover bothC:/WindowsandC:Windows. I rechecked that change and found no remaining instance of that escape. The new Windows host-volume enumerator inHostVolumesWindows.cppis still only cross-compiled according to the PR report; the hosted Windows product test is skipped by path policy. Please runguest_usb_storageon Windows and report whether the synthetic-volume cases execute or are skipped, since that is the only runtime coverage for this PR’s Windows-specific discovery and path behavior. I am keeping the review request open pending that result.