mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-12-04 16:40:32 +00:00
5.4 KiB
5.4 KiB
libkernel
change a socket keeps the libSceNet path
- fcntl (libkernel) follows FreeBSD 11.4's
kern_fcntlandkern_dupon file, directory, pipe and character device descriptors; a socket keeps the libSceNet path (F_DUPFD,F_DUP2FD,F_DUP2FD_CLOEXEC,F_GETFL,F_SETFL,F_GETFDandF_SETFD,EINVALfor every other command, see the next entry). On Linux and macOS a host socket that is not a guest socket, such as a standard descriptor a service manager connected to its journal, takes the flag handling of a pipe end andFIONREADasks the host for its queued bytes (for a datagram socket Linux counts only the next datagram, where FreeBSD'ssoo_ioctlcounts every buffered byte); its record locks and read-ahead hints fail withEBADF, as FreeBSD fails them on a descriptor without a vnode, andO_ASYNCon it throws. The close-on-exec flag and the status flags live in a guest table, the status flags shared bydup,dup2andF_DUPFDas in an open file description; a descriptor the table has not seen, such as 0 to 2, starts from the host's flags, since the console's are not known.F_DUPFDreturns the lowest free host descriptor at or above the start, so the bound is the host table (EMFILEon Windows,EINVALpastRLIMIT_NOFILEon Linux), not the console's unknownRLIMIT_NOFILEandkern.maxfilesperproc.O_NONBLOCKswitches a host pipe (PIPE_NOWAITon Windows, where an empty read and a full write then reportEAGAIN) and is only recorded on files, directories and the random device, as their reads never block; on a Windows console or other character device it throws.O_ASYNCon a pipe or character device (SIGIOis not delivered) andF_SETLK_REMOTEthrow;F_GETOWNandF_SETOWNon a pipe store and return the owner, shared bydup,dup2andF_DUPFDlike the status flags, as a payload process on a PS5 (firmware 11.60) did (0, the pid set, 0 after setting 0) and signal nothing, and on any other descriptor they throw;O_FSYNCset byopenorF_SETFLmakes eachwrite,pwrite,writevandpwritevon a file sync it before returning, asvn_writeaddsIO_SYNC; thesceKernelAioSubmitWriteCommandswrites are not synced, as whether the console's AIO honours the flag is unknown; on Linux a file opened with it keeps the hostO_SYNCafterF_SETFLclears it.O_DIRECT,F_RDAHEADandF_READAHEADare recorded as the hints they are. Record locks (F_GETLK,F_SETLK,F_SETLKWand their forms withoutl_sysid) use the host's POSIX locks on Linux and macOS.F_GETLKwithF_UNLCKasks the host withF_RDLCK: as inlf_blocksonly another owner's overlapping write lock conflicts with either request. On Windows they followkern_fcntlandlf_advlockasyncfor the one guest process, which owns every lock:EOVERFLOWfor anSEEK_CURstart pastOFF_MAX, thenEBADFforF_RDLCKwithout read access orF_WRLCKwithout write access andEINVALfor another type, thenEINVALandEOVERFLOWfor the range; aslf_blocksnever lets locks of one owner conflict, whichever descriptor or thread asks,F_SETLKandF_SETLKWthen succeed without waiting andF_GETLKreportsF_UNLCK, so no lock list is kept and merging, splitting and the release on close have nothing to change. Nothing is held on the host, since Windows byte-range locks are mandatory and would fail the guest's own reads and writes through other descriptors, so other host processes neither see these locks nor are seen; a lock from the end of a directory throws. The return values and error codes are unverified on a console
add Functional
- F_SETFL on a socket (libkernel) -
O_NOFOLLOWfails withEOPNOTSUPPand changes nothing, though FreeBSD 11.4 keeps it asFPOSIXSHMin a kernel built withCOMPAT_FREEBSD4toCOMPAT_FREEBSD7(amd64GENERIChas them) and ignores it otherwise; the console's options are unknown, and nothing here was measured on a console. On a guest socket or a libSceNet socket,F_SETFLkeepsO_APPEND,O_ASYNC,O_FSYNC,O_DIRECTand the read-ahead bit besidesO_NONBLOCK, ignores other bits andF_GETFLreports them, as inkern_fcntl;dupshares them andacceptcopies them. They change nothing:O_ASYNCraisesSIGIOonly for an owner (sowakeup), and no socket here can get one