shadPS4/src/core/libraries/kernel
Stephen Miller 6c39bf229c
libkernel: Various filesystem fixes (#2868)
* Proper handling of whence 3 & 4

* Accurate directory handling in open

Directories can be opened, and can be created in open, these changes should handle that more accurately.

* Mount /app0 as read only

On real hardware, it's read only.

* Proper directory flag handling.

Even when directory is specified, it will still succeed to open non-directories.

* Check for read only directories

* Earlier ro check in posix_rmdir

Hardware tests suggest these checks are in a different order

* Clear temp folder on boot

My tests rely on this, and some games do too.
Two birds with one stone

* Clang

* Add missing DeleteHandle calls

Whoops

* Final flags adjustment in sceKernelOpen

All my current tests are now hardware accurate.

* Fix truncates

Host ftruncate consistently fails on EINVAL, I'll need to test if this issue affected Windows too.

* Windows hacks

Windows is more limiting about how folders are opened and things like that. For now, pretend these calls didn't error.
Also fixes compilation for Windows

* Final touch-ups

After expanding my test suite further, I found a couple more edge cases that needed addressing.
Bloodborne audio is still broken, I'll look into that soon.

* Remove hacky read-only behavior in posix_stat

Bloodborne apparently uses the mode parameter here when querying it's audio files, and the mode we returned led to it disabling audio entirely.

* Clang

* Cleaner code

* Combine fsync and sync flags

According to FreeBSD docs, the "sync" flag is synonymous with the fsync flag, and is only included to meet the POSIX spec.

* Log if any currently unhandled flags are encountered.

These are rare and probably not too important, but log a warning when they're seen.

* Update file_system.cpp

* Update file_system.cpp

* Clang

* Revert truncate fix

Using ftruncate works fine after moving the call to before the proper file opening code.

* Truncate before open

Open the file as read-write, then try truncating.
This fixes read | truncate flag behavior on Windows.

* Slightly adjust check for invalid flags

Any open call with invalid flags should return EINVAL, regardless of other errors parameters might cause.
2025-05-01 14:47:43 +03:00
..
sync semaphore: Attempt to acquire before checking timeout 2024-12-24 15:39:17 +02:00
threads Minor libkernel changes (#2721) 2025-03-30 01:27:33 +02:00
aio.cpp sceKernelAio* implementation (#2160) 2025-01-16 18:27:52 +02:00
aio.h sceKernelAio* implementation (#2160) 2025-01-16 18:27:52 +02:00
debug.cpp Minor libkernel changes (#2721) 2025-03-30 01:27:33 +02:00
debug.h Minor libkernel changes (#2721) 2025-03-30 01:27:33 +02:00
equeue.cpp Fix VideoOut events (#2330) 2025-02-03 17:37:28 +02:00
equeue.h VideoOut event cleanup (#2849) 2025-04-27 09:04:17 +03:00
file_system.cpp libkernel: Various filesystem fixes (#2868) 2025-05-01 14:47:43 +03:00
file_system.h libkernel: Filesystem code cleanup (#2554) 2025-03-26 18:03:35 +02:00
kernel.cpp [Libs] sceNet (#2815) 2025-04-30 17:58:39 +03:00
kernel.h [Libs] sceNet (#2815) 2025-04-30 17:58:39 +03:00
memory.cpp Emulate memory behavior of libSceGnmDriver initialization (#2807) 2025-04-18 23:41:33 +03:00
memory.h core: better memory configuration (#1896) 2024-12-28 12:03:00 +01:00
orbis_error.h core: Library cleanup (#1631) 2024-11-30 22:37:36 +02:00
posix_error.h core: Library cleanup (#1631) 2024-11-30 22:37:36 +02:00
process.cpp Implement sceKernelGetModuleInfo, sceKernelGetModuleInfoInternal, and sceKernelGetModuleList (#2850) 2025-04-27 09:32:01 +03:00
process.h Handle error behavior in sceSysmoduleGetModuleInfoForUnwind stub (#2629) 2025-03-09 23:17:33 +02:00
threads.cpp kernel: Rewrite pthread emulation (#1440) 2024-11-21 22:59:38 +02:00
threads.h hotfix: reset stop source on thread stop 2025-01-02 12:30:05 +01:00
time.cpp clock_gettime fixes for windows (#2659) 2025-03-20 22:24:47 +02:00
time.h sceKernelAio* implementation (#2160) 2025-01-16 18:27:52 +02:00