Commit Graph
130 Commits
Author SHA1 Message Date
Henrik Rydgård c71fa5e32b sceIo: stop clobbering st_private, report FAT permissions, implement sceIoChstat
Cashing in the io/stat and io/shortname recordings.

__IoGetStat began with memset(stat, 0xfe, sizeof(SceIoStat)), which destroyed 24 bytes of the
caller's buffer that a real PSP never touches - it writes only as far as the timestamps and
leaves all six st_private words exactly as it found them. It also wrote a made-up sector number
into st_private[0] on the memory stick. That word carries the LBN on a UMD, which games read to
build disc0:/sce_lbn paths, so it stays for non-FAT and is left alone otherwise.

FAT has no permissions of its own and everything reads back as 0777. We were passing the host's
idea of the file through instead. The existing "all files look executable on FAT" hack for Beats
(issue #14812) was right in substance but lived only in sceIoDread, so sceIoGetstat and
sceIoDread disagreed about the same file where hardware has them agree. Both now go through one
path, which also gets the read-only case right: no write bits means mode 0555 and attr 0x21.

sceIoGetstat on the root of a volume is refused, as on hardware.

sceIoChstat was a logging stub. It now applies the read-only flag, which is what st_mode's write
bits and st_attr's 0x01 both mean on FAT - setting either produces both, and it's reversible.
That needs a new IFileSystem::SetFileWritable, defaulting to "can't" so read-only filesystems and
hosts that can't express it (Android content URIs) are unaffected; the call still succeeds there,
since hardware would have.

GenerateFatShortNames now accounts for capitalisation. FAT keeps a lowercase flag for the base and
another for the extension, but the PSP only honours the base one, so "shrt" becomes SHRT while
"readme.txt" becomes README~1.TXT. We were only adding a counter on collision. The unit test
carries the whole recorded set, including the corrected README~1.MD.

io/shortname stays in tests_next: its d_name column can't match while SimulateVFATBug is
uppercasing lowercase 8.3 names, which is deliberate and load-bearing for homebrew.
2026-09-10 09:52:01 -06:00
Henrik Rydgård 1295512866 MetaFileSystem: also warn against reordering existing mounts
The positional serialization means swapping two Mount() calls breaks every old
savestate just as thoroughly as adding one does, so say so. Also note that the
mount order spans more than MountFileSystems() - the UMD mounts are added first,
by MountGameISO, before we get there.
2026-08-31 00:23:53 +02:00
Henrik Rydgård 7b409af50f MetaFileSystem: spell out how to add a mount without breaking savestates
The positional serialization means adding a mount silently invalidates every
existing savestate unless its prefix is added to the skip list, which is exactly
how flash1: broke them. Write down the rule, and note that renaming or removing
a mount isn't something this scheme can handle at all.
2026-08-30 23:59:06 +02:00
Henrik RydgårdandClaude Opus 5 729653bf42 Fix loading savestates made before flash1: was mounted
78ef1eae82 added a flash1: mount, but MetaFileSystem::DoState serializes the
mounts positionally - one section each, with no length to skip by - so a state
written before that commit has one section fewer than we now have mounts.

The existing count check assumed a single missing entry could only be pfat0:,
which was the previous mount added this way. So it took the skipPfat0 path,
skipped pfat0's section while still only looping n times, and ended up making
n-1 DoState calls against n sections. Everything after that read shifted, and
the load died with "Failure at DirectoryFileSystem".

Make the "these were added later" set explicit and ordered instead, and iterate
over the mounts rather than over the saved count, so the number of DoState calls
matches the state regardless of which of them are missing.

Verified against Wipeout Pure (UCUS98612): both save slots report n=9 against 10
mounts and fail to load before this, and load after, in both the app and headless.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DCPmm7FoQUoqrbMdhfqhQ2
2026-08-30 23:52:09 +02:00
Henrik Rydgård b3a2178a5c ImDebugger: Show per-thread current directory in threads view 2026-08-24 10:21:27 +02:00
Henrik Rydgård 78ef1eae82 Instead of flash0directory, have a NAND subdirectory under PSP, where you can keep flash0, flash1 etc.
Also make it configurable via command line.
2026-08-24 09:53:37 +02:00
Henrik Rydgård 786a1530de Correct host0: mount 2026-08-24 09:30:44 +02:00
Henrik Rydgård b437ba0fc6 MetaFileSystem: Add subdirectory mounts 2026-08-24 09:30:44 +02:00
Henrik Rydgård b7ad74d309 MetaFileSystem: Turn another argument into string_view 2026-02-25 00:52:25 +01:00
Henrik Rydgård f2116c4236 Start using string_view in MetaFileSystem 2026-02-06 11:51:40 +01:00
Henrik Rydgård dbe6ec80a0 Fix some bad "for (auto x : y)" usage 2025-04-29 16:46:14 +02:00
Henrik Rydgård 05b1cf3b80 Startup cleanup, part 1 2025-03-26 09:24:14 +01:00
Henrik Rydgård ef386ac4c5 Add "GetFileInfoByHandle" function to (many) file systems 2025-03-19 10:42:30 +01:00
Henrik Rydgård 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Henrik Rydgård b6f648eecc MetaFileSystem: Clean up unused function 2024-11-29 14:13:56 +01:00
Henrik Rydgård 8a5be21140 MemStick screen: Call free_disk_space from async tasks
See #19522
2024-10-11 13:45:43 +02:00
Henrik Rydgård b1fae3ccda Add two missing mutex-locks in MetaFileSystem.
See #19272
2024-09-17 00:19:58 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Herman Semenov af41281761 [Core/Dialog/ELF/FileSystems/HLE/HW/Util] Added const reference for function params 2023-12-14 14:22:24 +03:00
Henrik Rydgård c5e0dafa44 Fix "double delay" error in sceNpDrmEdataSetupKey 2023-05-25 10:02:52 +02:00
Unknown W. Brackets 5b0748a61c Merge pull request #17137 from hrydgard/log-fixes
Log fixes
2023-03-17 18:51:47 -07:00
Henrik Rydgård df41a5cebd Improve default ini, logging fixes 2023-03-17 13:59:57 +01:00
Henrik Rydgård 66d2fb2aa4 Reduce logspam from fonts, and a less angry error message for missing textures.zip. 2023-03-16 23:12:46 +01:00
Unknown W. Brackets 4942692558 Io: Provide directory existence with listing.
Sometimes, you need to tell the difference between an empty directory and
one that doesn't exist at all.  We can do this in a single call.
2022-10-09 14:42:31 -07:00
Unknown W. Brackets d473aa6db0 Module: Cleanup file read pattern.
Let's always use ReadEntireFile() when we can.
2022-10-09 14:42:30 -07:00
Henrik Rydgård 36079b86d0 Optimize away a couple of existence checks 2021-09-11 19:53:19 +02:00
Henrik Rydgård 8e2b73b05f Optimize MetaFileSystem::ReadEntireFile 2021-09-11 19:32:37 +02:00
Henrik Rydgård 48310d15a9 Add metafilesystem hook to add optimized implementations of compute recursive directory size 2021-09-11 18:12:29 +02:00
Henrik Rydgård 09f65db91c Cleanup 2021-09-11 15:35:11 +02:00
Henrik Rydgård f53eb4ae0d Fix silly filesystem mounting bug introduced in #14638
Fixes #14650.
2021-07-27 22:55:02 +02:00
Henrik Rydgård 9ae00b80b1 Cleanup the ownership model in MetaFileSystem.
The old one was error-prone spaghetti.
2021-07-24 10:31:15 +02:00
Henrik Rydgård 96406364ca Fix for new bug in GetDirListing, oops 2021-07-19 20:43:10 +02:00
Henrik Rydgård 40ab92fe7b Remove unused function GetHostPath from filesystems 2021-05-13 10:39:17 +02:00
Henrik Rydgård 025bcb1673 Introduce Path, start using it all over the place.
Still lots left to convert!

Convert GetSysDirectory to return Path.

More buildfixing

Remove unnecessary Path( constructors
2021-05-13 10:39:16 +02:00
shenweip 166035a87b Simulates memory stick size to get fixed free space.
Some games may be sensitive to the changes of free space of memory stick, and Android's free space is usually variable.
2020-10-08 23:51:56 +08:00
Unknown W. Brackets b8342fb8ec SaveState: Rename ChunkFile files to Serialize.
Makes more sense and less weird than ChunkFileDoMap, etc.
2020-08-10 08:04:05 +00:00
Unknown W. Brackets 1dc5ee424b SaveState: Split out Do types to reduce headers. 2020-08-10 08:03:44 +00:00
Unknown W. Brackets 4b4e3432cd SaveState: Split Do() into a separate header. 2020-08-10 08:03:41 +00:00
Unknown W. Brackets d7ad43b1d9 Io: Cleanup access bits for files.
Also, we default a lot of these members, so don't need to reset.
2020-05-21 18:58:24 -07:00
Unknown W. Brackets 9b112efa0b Headless: Handle umd mapping with block devices. 2020-05-21 18:58:24 -07:00
Unknown W. Brackets 49abe9ed6c Io: Open sce_lbn references and whole ISO faster. 2020-05-21 18:58:24 -07:00
Unknown W. Brackets 3777d32ac8 Io: Cleanup sceIoOpen errors and logging. 2020-05-21 18:56:57 -07:00
shenweip 9fa4ae7b15 fix 2020-01-04 09:11:15 +08:00
shenweip d09543ebd7 Move umd replace to loaders. 2020-01-02 14:56:24 +08:00
shenweip fb696f8a71 Just return error if current directory not be setted. 2019-12-25 11:16:56 +08:00
shenweip c3a489fa90 Don't ignore SCE_KERNEL_ERROR_NOCWD in many cases.
Use a error 1 to mean the uccessful mapping but carry with  SCE_KERNEL_ERROR_NOCWD error.
2019-12-13 17:59:55 +08:00
shenweip fd6b0554d6 IO:Re-grab SCE_KERNEL_ERROR_NOCWD.
Fix issue#12492,the issue occur since commit e09296b9b1
2019-12-13 11:15:58 +08:00
Unknown W. Brackets 913121cf2b Io: Consistently use error codes with OpenFile().
This gets rid of OpenWithError(), and just always returns a negative value
on error for OpenFile().  Also fixed the sequence rollover, which could've
returned 0.

0 should be considered a valid handle ideally, but left it never returning
0 to simplify cleanup in some areas.
2019-10-20 11:03:37 -07:00
Henrik Rydgard 26a2d42731 Big mutex overhaul - remove our custom ones, make them non-recursive where possible 2017-02-28 11:40:29 +01:00
Henrik Rydgard b94572e3ba Assorted cleanup 2016-03-13 15:17:31 +01:00