Implement sceFiosFHOpen, sceFiosFHOpenWithMode, sceFiosFHClose, sceFiosFHStat, sceFiosFHTruncate, sceFiosFHSync, the read, write, pread and pwrite families including the vectored forms with their Sync variants, and sceFiosFHSeek, sceFiosFHTell, sceFiosFHGetSize, sceFiosFHGetPath and sceFiosFHGetOpenParams. A handle owns a kernel descriptor and serializes its transfers. Transfers the open flags exclude, bad vector counts, negative sizes and offsets and closed handles return SCE_FIOS_ERROR_* codes.
9.5 KiB
libSceFios2 technical debt
Functional
- libSceFios2 prototypes (libSceFios2) - the implemented exports take the prototypes of RPCS3's Vita FIOS2 module (
Emu/ARMv7/Modules/sceFios.handsceFios.cpp, jacquesjk/RPCS-DX12 at9b8b7c9eea446095f24af19182032013837e6ca5, 64-bit types substituted), checked against the PS4 headers and call sites of kalaposfos13/fios2 (src/fios2.h,ae6ca1d78e7a822c2528f7660959167b9b3d8b63), sonny-tel/libSceFios2 (sceFios2.h,5d44f9e7a80ae00557af80fad335e4c74ef35d22), Inori/GPCS4 (SceFios2/sce_fios2.cpp) and SonicMastr/SceLibcPosix (src/internal/fios2.h, Vita,c2cd5e880a8770bdbfb58de761de11f396c1a2e7). TheSceFiosOpAttr,SceFiosOpenParams,SceFiosStatandSceFiosDirEntrylayouts and theSCE_FIOS_ERROR_*values (0x80820000plus the enumeration order) come from the same sources; vascon-es/lego-dimensions-pc confirms theSceFiosStatandSceFiosDirEntryoffsets and thefileSize,statFlagsbit 0 (directory) andoffsetToNamereads from the call sites of a PS4 title. None of it was measured on a PS5. TheSceFiosOpenParamsbuffer sits at offset 8 in kalaposfos13 and sonny-tel and at offset 0x10 in lego-dimensions-pc; onlyopenFlagsis read - Operations (libSceFios2) - there are no I/O or decompressor threads. An operation runs on the calling thread and is complete when the export returns, and its callback fires there with
SCE_FIOS_OPEVENT_COMPLETE; whilesceFiosSuspendis in effect new operations queue and run on the thread whosesceFiosResumeends the suspension.deadline,priority,opflags,userTag,userPtrand the scheduler fields are stored and returned but have no effect, andSCE_FIOS_OPEVENT_STARTis never sent. The*Syncexports are the asynchronous export followed bysceFiosOpSyncWait, so they also fire the completion andSCE_FIOS_OPEVENT_DELETEcallbacks.sceFiosOpSyncWaitreturns the error or the low 32 bits of the result (1 or 0 for the existence queries, as in kalaposfos13/fios2),sceFiosOpGetActualCountreturns the result (the size forsceFiosFileGetSize) also for a failed operation, andsceFiosOpGetErrorreturns 1 while an operation is queued; none of these is measured. Handles of operations, files and directories share one number space that starts at 1. Nothing requiressceFiosInitializefirst, andSceFiosParamsis stored asparamsSizebytes (the 15 bits at bit 1 of the first word) without interpretation, so the storage buffers,pathMax(1024 is used), thread and scheduler settings are ignored - sceFiosExists, sceFiosFileExists, sceFiosDirectoryExists, sceFiosFileGetSize, sceFiosStat and their Sync forms (libSceFios2) - paths go to
sceKernelStat, so archive and alias mapping is the kernel's. A missing path is not an error for the existence queries.SceFiosStatcarries only the sizes, the nanosecond dates as seconds since 1970 times 10^9 plus nanoseconds (the epoch and unit are not measured),statFlagsbit 0 for a directory, and the kernelst_uid,st_gid,st_dev,st_inoandst_mode; otherstatFlagsbits are 0.sceFiosFileExistsandsceFiosDirectoryExiststake thepOutExistsargument of RPCS3's prototype, which kalaposfos13/fios2 omits, andsceFiosFileGetSizehas no output pointer as in kalaposfos13/fios2 and sonny-tel (RPCS3 declares one) - sceFiosDelete, sceFiosFileDelete, sceFiosDirectoryCreate, sceFiosDirectoryDelete, sceFiosRename, sceFiosFileRead, sceFiosFileWrite, sceFiosFileTruncate and their Sync forms (libSceFios2) - behaviour is inferred from the export names; none of it is measured. They run on
sceKernelStat,sceKernelOpen,sceKernelPread,sceKernelPwrite,sceKernelFtruncate,sceKernelMkdir,sceKernelRmdir,sceKernelUnlinkandsceKernelRename, so guest path mapping and the read-only application directory are the kernel's.sceFiosFileWriteopens the file write-only with creation and no truncation,sceFiosFileTruncatedoes not create it, directories are created with mode 0777 and files with 0666,sceFiosDeleteremoves a file or an empty directory, and a negative length returnsSCE_FIOS_ERROR_BAD_SIZE, a negative offsetSCE_FIOS_ERROR_BAD_OFFSET. A read stops at the end of the file and returns the bytes read. The mapping of kernel errors toSCE_FIOS_ERROR_*is chosen here:ENOENTandENOTDIRtoBAD_PATH,EPERM,EACCESandENOTEMPTYtoACCESS,EROFStoREAD_ONLY,EEXISTtoALREADY_EXISTS,EISDIRtoNOT_A_FILE,EINVALtoBAD_OFFSET,ENFILEandEMFILEtoCANT_ALLOCATE_FH,ENAMETOOLONGtoPATH_TOO_LONG,EFAULTtoBAD_PTR, and anything else toUNKNOWN. The prototypes follow RPCS3 (sceFios.cppsceFiosFileWrite,sceFiosFileTruncate,sceFiosRename,sceFiosDelete) and kalaposfos13/fios2 (sceFiosFileRead) - sceFiosFHOpen, sceFiosFHOpenWithMode, sceFiosFHClose, sceFiosFHStat, sceFiosFHTruncate, sceFiosFHSync, sceFiosFHRead, sceFiosFHWrite, sceFiosFHPread, sceFiosFHPwrite, the vectored forms with their Sync forms, sceFiosFHSeek, sceFiosFHTell, sceFiosFHGetSize, sceFiosFHGetPath and sceFiosFHGetOpenParams (libSceFios2) - a file handle owns one kernel descriptor, and
sceFiosFHRead,sceFiosFHWrite,sceFiosFHSeekandsceFiosFHTelluse its kernel position.openFlagsmap asSCE_FIOS_O_READ1,SCE_FIOS_O_WRITE2,SCE_FIOS_O_APPEND4,SCE_FIOS_O_CREAT8 andSCE_FIOS_O_TRUNC16 (sonny-tel/libSceFios2, SonicMastr/SceLibcPosix);SCE_FIOS_O_DIRECT(1 << 12) is ignored, no flags or null parameters open read-only, and the handle returnsSCE_FIOS_ERROR_WRITE_ONLYorSCE_FIOS_ERROR_READ_ONLYfor a transfer its flags exclude (the console result is not measured). The creation mode is 0777 unlesssceFiosFHOpenWithModeis given one (-1means the default, as in kalaposfos13/fios2). Opening a directory returnsSCE_FIOS_ERROR_NOT_A_FILE. An invalidwhenceor a negative resulting position returnsSCE_FIOS_ERROR_BAD_OFFSET, a vector count outside 1 to 1024SCE_FIOS_ERROR_BAD_IOVCNT. The Readv and Writev exports transfer the vectors in order and stop at the first short one.sceFiosFHGetPathandsceFiosFHGetOpenParamsreturn pointers that stay valid until the handle is closed; the storedSceFiosOpenParamshas no buffer. The handle prototypes follow RPCS3'ssceFios.cppand kalaposfos13/fios2;sceFiosFHToFilenoandsceFiosFilenoToFHhave no source and keep throwing
Unknown function info
-
sceFiosArchiveGetDecompressorThreadCount, sceFiosArchiveGetMountBufferSize, sceFiosArchiveGetMountBufferSizeSync, sceFiosArchiveMount, sceFiosArchiveMountSync, sceFiosArchiveMountWithOrder, sceFiosArchiveMountWithOrderSync, sceFiosArchiveSetDecompressorThreadCount, sceFiosArchiveUnmount, sceFiosArchiveUnmountSync, sceFiosCacheContainsFileRangeSync, sceFiosCacheContainsFileSync, sceFiosCacheFlushFileRangeSync, sceFiosCacheFlushFileSync, sceFiosCacheFlushSync, sceFiosCachePrefetchFH, sceFiosCachePrefetchFHRange, sceFiosCachePrefetchFHRangeSync, sceFiosCachePrefetchFHSync, sceFiosCachePrefetchFile, sceFiosCachePrefetchFileRange, sceFiosCachePrefetchFileRangeSync, sceFiosCachePrefetchFileSync, sceFiosClearTimeStamps, sceFiosDHClose, sceFiosDHCloseSync, sceFiosDHGetPath, sceFiosDHOpen, sceFiosDHOpenSync, sceFiosDHRead, sceFiosDHReadSync, sceFiosDLLInitialize, sceFiosDLLTerminate, sceFiosDeallocatePassthruFH, sceFiosDebugDumpDH, sceFiosDebugDumpDate, sceFiosDebugDumpError, sceFiosDebugDumpFH, sceFiosDebugDumpOp, sceFiosDirectoryCreateWithMode, sceFiosDirectoryCreateWithModeSync, sceFiosFHToFileno, sceFiosFilenoToFH, sceFiosIOFilterAdd, sceFiosIOFilterCache, sceFiosIOFilterGetInfo, sceFiosIOFilterPsarcDearchiver, sceFiosIOFilterRemove, sceFiosOpReschedule, sceFiosOpRescheduleWithPriority, sceFiosOpSetBuffer, sceFiosOpWaitUntil, sceFiosOverlayAdd, sceFiosOverlayGetInfo, sceFiosOverlayGetList, sceFiosOverlayModify, sceFiosOverlayRemove, sceFiosOverlayResolveSync, sceFiosPathNormalize, sceFiosPathcmp, sceFiosPathncmp, sceFiosPrintTimeStamps, sceFiosPrintf, sceFiosResolve, sceFiosResolveSync, sceFiosSaveTimeStamp, sceFiosTimeGetCurrent, sceFiosTimeIntervalFromNanoseconds, sceFiosTimeIntervalToNanoseconds, sceFiosTraceTimestamp and sceFiosVprintf (libSceFios2) - names and NIDs are present in the PS5 3.20 export inventory, but no credible prototypes were found. The declarations have no parameters solely to resolve known imports; this is not an ABI claim and callers must not call them until signatures are verified
-
sceFiosDateFromComponents, sceFiosDateGetCurrent and sceFiosDateToComponents (libSceFios2) - the date packing is unverified and the declarations in Export.cpp still carry no parameters. kalaposfos13/fios2 (
src/fios2.h, PS4) and RPCS3 (Emu/PSP2/Modules/sceFios.cpp) independently declaresceFiosDateFromComponents(tm*)andsceFiosDateGetCurrent()returning a 64-bit date,sceFiosDateToComponents(int64_t, tm*)returning thetmpointer, but both may descend from one leaked Vita SDK and kalaposfos13's bodies are guesses (mktimetimes 1e9). sonny-tel/libSceFios2 (a header read from a Fortnite build) givesSceFiosParams,SceFiosOpAttr,SceFiosOpenParamsandSceFiosStatlayouts, unverified against firmware