Repository navigation
Conversation
…sed and replaced ids
…elative name An absolute host temp path is not mapped by the Linux guest resolver. Found by xXPBSXx on boykopovar#9097.
The PS5 3.20 export lists have ksem_* in libkernel as well as libkernel_sys, and on Windows a libkernel import never reaches libkernel_sys, so titles importing them from libkernel did not find them. Following pipe1os's review on boykopovar#9284, also: ENOSPC from ksem_init when no descriptor is left, the SEM_MAX limit of 30 with ENOSPC, and dup/dup2 from a ksem id throwing as for a kqueue.
… libkernel too Following the move of the unnamed calls: ksem_open now allocates the descriptor and writes the id before checking the name, as ksem_create does, and the 30-semaphore limit counts semaphore objects, with a linked name counting until it is unlinked (ENFILE for a new name).
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Exports with a name or library/NID already present in
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Builds on boykopovar#9284 and adds the named
ksem_*exports tolibkernel/Semaphore/src/Ksem.cpp, following FreeBSD 11sys/kern/uipc_sem.c. Until boykopovar#9284 merges, this PR's diff also shows boykopovar#9284's commits.Moved to libkernel so libkernel imports reach it on Windows, as boykopovar#9284 now is. The PS5 3.20 lists export
ksem_*from libkernel too, and a Windows libkernel import never searches libkernel_sys. The libkernel_sys stubs forksem_open,ksem_closeandksem_unlinkare removed.ksem_open(semid_t* idp, const char* name, int oflag, mode_t mode, u_int value)ksem_close(semid_t)EINVALon an unnamed id, which needsksem_destroyksem_unlink(const char* name)ENOENTif it is absent; ids already open keep working, and a laterO_CREATopen makes a new semaphoreksem_open's rules, in the order ofsys_ksem_openandksem_create:EINVALforoflagbits other thanO_CREAT | O_EXCL, then forvalue > SEM_VALUE_MAX.EMFILEorENFILEwhen none is left), and the id is written to*idp(EFAULTfor a NULLidp) before the name is checked, as FreeBSD's early copyout does.EFAULTfor a NULL name,ENAMETOOLONGfor 1024 bytes or more, andEINVALfor a name that doesn't start with/.ENOENTfor a missing name withoutO_CREAT, andEEXISTfor an existing name withO_CREAT | O_EXCL.ENFILEwhen a new name would exceed the 30 semaphores (SEM_MAX).Each successful open returns a new descriptor id that shares the semaphore.
The limit counts semaphore objects, as FreeBSD's
nsemsdoes. Two opens of one name are one semaphore, and a name still linked counts untilksem_unlink, even with no open id. Unnamedksem_initgivesENOSPCpast the limit, as in boykopovar#9284. (Points from pipe1os's review on boykopovar#9284.)ksem_destroynow givesEINVALon a named id, which needsksem_close, as FreeBSD'sKS_ANONYMOUScheck does. A debt line inlibkernel.mdrecords that named semaphores are kept per process, which fits a single guest process:modeis accepted, and the owner and permission checks are not modelled.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release. These are CPU-side exports, so no GPU is involved.
guest_kernel_sys_ksemgainsNamed():ksem_destroyon a named id andksem_closeon an unnamed id giveEINVAL;ksem_unlinkthe name is gone (ENOENT), but the open ids still work;ksem_closeinvalidates its id, and the other id is unaffected;O_CREATopen after the unlink starts from its own value.NamedLimit():EFAULTwith the id already written but dead;ksem_initgivesENOSPCand a new name givesENFILE;ksem_unlink, there's room again.ksem_open_nid_postfix not implemented. On this branch it passes, 5 of 5 runs.tools/check_conventions.pypasses, including the duplicate-export rule (all tenksem_*are now exported by libkernel only).tools/pr_overlap.pycrashes on this machine's partial clone, so it was replaced by a check against an index of every open PR's diff plusgit merge-tree. This branch merges cleanly withmainand with feat(libkernel_sys): identify the initial pthread boykopovar/AnyPS5#9160, feat(libkernel_sys): implement uuidgen boykopovar/AnyPS5#9195, feat(libkernel_sys): implement wait3 and wait4 boykopovar/AnyPS5#9162, feat(libkernel_sys): implement statfs symlinkat and futimesat boykopovar/AnyPS5#9161, feat(libkernel): implement four pthread_attr forms boykopovar/AnyPS5#9156, feat(libkernel): implement getlogin boykopovar/AnyPS5#9171, feat(libkernel): implement pselect over select boykopovar/AnyPS5#9273, feat(libkernel): implement tcgetsid boykopovar/AnyPS5#9242, feat(libkernel_sys): implement pwrite through the shared POSIX provider boykopovar/AnyPS5#9019, feat(libkernel_sys): implement fstat boykopovar/AnyPS5#9008, feat(libkernel_sys): implement sceKernelFlock over flock boykopovar/AnyPS5#9097, feat(libkernel_sys): implement the scePthread scope, atfork and setconcurrency forms boykopovar/AnyPS5#9141, feat(libkernel_sys): implement chown, lchown, fchownat and linkat boykopovar/AnyPS5#9103, feat(libkernel_sys): implement the scePthreadBarrier, cpuclockid, concurrency and msync forms boykopovar/AnyPS5#8987 and feat(libkernel): report open, read and close notes on watched files boykopovar/AnyPS5#7121.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)