feat(libkernel): accept EVFILT_FS in kevent #14894
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14894"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by kallmek3nny on 2026-11-01T23:21:55Z.
What
keventthrewNotImplemented_nid_no_patchfor everyEVFILT_FSchange. It now acceptsEVFILT_FS, as FreeBSD 11.4 does. Invfs_subr.c,filt_fsattachaddsEV_CLEARto the knote and puts it on the globalfs_knlist, whatever its ident.filt_fseventORs each hint intokn_fflagsand reports the knote whilekn_fflagsis not 0. The only hints come fromvfs_event_signal, whichvfs_mount.ccalls withVQ_MOUNTinvfs_domount_firstand withVQ_UNMOUNTindounmount. Nothing here mounts or unmounts a filesystem (nmountthrows), so nothing sends such a hint:EV_ADDstores the knote withEV_CLEARadded andfflagsanddata0, askqueue_registermoveskev->fflagsandkev->dataintokn_sfflagsandkn_sdata.EV_ENABLE,EV_DISABLE,EV_DELETEandEV_FORCEONESHOTact on it as on other knotes.EV_DELETEorEV_ENABLEwith no knote fails withENOENT.The kevent measurements entry in
docs/dev/debt/libkernel.md(payload processes on a PS5, firmware 12.70) recorded thatEVFILT_FSat ident 0 was accepted there and still threw here. This PR rewrites that clause (line 172) to say it is accepted here and to point to the kqueue and kevent entry. That entry (line 167) now listsEVFILT_FSamong the filters that do not throw, with theEV_CLEARthatfilt_fsattachsets, and says it never fires. Only the acceptance at ident 0 was measured on a PS5;EV_CLEARand the clearedfflagsanddatafollow FreeBSD 11.4.Code:
RegisterinEqueue/src/Kqueue.cppacceptsEVFILT_FS(the new constant -9) and adds it with the newAddFsKnote, which stores the knote withEV_CLEARadded andfflagsanddatacleared in both the stored event and the change.Tests:
FilesystemEventsincore/libs/tests/GuestKqueue.cpp, at ident 0:EV_DELETEandEV_ENABLEwith no knote fail withENOENT.EV_ADDwithEV_RECEIPT,fflags7,data9 and audatareturns one receipt withEV_ERROR,data0 andfflags0, and no event follows.EV_ADD, thenEV_DISABLEandEV_ENABLE, return 0 and report no event.EV_FORCEONESHOTwith theudatareports one event withEV_RECEIPT,EV_CLEARandEV_ONESHOT,fflags0,data0 and theudata, then none. The knote is gone after that, soEV_DELETEfails withENOENT.EV_ADDthenEV_DELETEreturn 0, and a secondEV_DELETEfails withENOENT.Overlap: no open PR implements
EVFILT_FS.gh pr list --repo boykopovar/AnyPS5 --state open --searchforfilt_fsattach,filt_fsevent,VQ_MOUNTandVQ_UNMOUNTreturned no PRs.EVFILT_FSreturned only my #14854 (below), whose debt rewrite keeps theEVFILT_FSclause as it is onmain; my #14886 keeps it too.kevent fs,kqueue fsandkevent filesystemadded #14206 (selectfailing withEBADFwhen its pipe closes on Windows),kevent filesystemadded #7121 (open, read and close notes on watched files), andkqueue mountadded #9661 (rename onto or from a Windows directory symbolic link). By title #14206 and #9661 are unrelated; the diff search below found noEVFILT_FScode or text in #7121.tools/pr_overlap.pyreports four PRs:NOTE_LOWATbelow 1) rewrites debt lines 167 and 172 and changes other lines ofKqueue.cppandGuestKqueue.cpp.EVFILT_FScode or text. My #14854 and #14886 are below.EVFILT_PROCwithNOTE_EXITon the calling process) and #14886 (EVFILT_SIGNAL) change the same filter check inRegister, and each adds its own add function andRegisterbranch where this PR addsAddFsKnoteand its branch.git merge-treeof this branch with #14854's head575c14f9b4conflicts in three blocks inKqueue.cpp, inGuestKqueue.cpp(itsProcessExitOnSelfand this PR'sFilesystemEventsgo in the same place) and on debt lines 167 and 172. With #14886's head0211640a74it conflicts in the same threeKqueue.cppblocks and on debt lines 167 and 172. Each conflict is two changes to the same lines, and resolving it means keeping both, with every accepted filter in the one filter check. Whichever of these PRs merge later need a rebase of those lines.main. I searched each of their diffs for removed code lines this PR also removes, for the same debt lines or entries, and for added or removedEVFILT_FStext. None shares a removed code line or adds or removesEVFILT_FStext. #7088 (kevent read and write events on regular files) and #9843 (EV_CLEAREVFILT_WRITEwithNOTE_LOWATabove 1 on a Linux TCP socket) also rewrite the kqueue and kevent entry (line 167), so the second to merge will need a rebase there. #7088, #7121 and #9843 also change other lines ofKqueue.cppandGuestKqueue.cpp.Tested
Windows 11 Home 10.0.26300.9711, Git Bash, WinLibs gcc/g++, Ninja, Release, in the build tree configured with
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=ON -DPython3_EXECUTABLE=C:/Python314/python.exe. No title or homebrew; only the guest test below was run.0580e5c951), after the code, test and debt edits:cmake --build build --target guest_kqueue_tests: exit 0; it rebuiltlibkernel.prxandguest_kqueue_tests.ctest --test-dir build -R '^guest_kqueue$' --no-tests=error --output-on-failure --timeout 120: 1/1 passed. The commit8303e23a41is that working tree: 3 files, 45 insertions and 3 deletions. No header changed, sopublic_headersand a full build were not run.8303e23a41,python tools/check_conventions.py --base origin/mainexited 0 with 0 errors and 2debt-lengthwarnings fordocs/dev/debt/libkernel.md. Line 167 is 3771 characters (3537 onmain) and line 172 is 4409 characters (4336 onmain); both were already over 1000 characters onmain. None of the 3 files changed onorigin/main(4ac683fe02) since the merge base.python tools/pr_overlap.py --branch feat/libkernel-kevent-fs: exit 2. It found 1846 open PRs and fails closed when it cannot compare every one. The manual comparison is under What.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-01T23:59:55Z.
Review: APPROVED
Reviewed at
8303e23a41, merged locally intomain66e1f7f993(clean merge; GitHub reports it mergeable). Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, Ninja.Checked against FreeBSD 11.4's source (
release/11.4.0, source read, not run, not measured on a console):sys/sys/event.h:42:EVFILT_FSis-9.sys/kern/vfs_subr.c:4952-4958:filt_fsattachsetsEV_CLEARand adds the knote tofs_knlistwhatever its ident;filt_fseventORs the hint intokn_fflags, so with no hint it never fires.sys/kern/kern_event.c,kqueue_register: for a new knotekev->fflagsandkev->datamove intokn_sfflags/kn_sdataand are cleared, so theEV_RECEIPTevent hasfflags0, as the test expects. For an existing knoteEV_FORCEONESHOT(line 1431) setsEV_ONESHOTand activates it without leaving early, andkn->kn_kevent.udata = kev->udatafollows, so the forced event carries the change'sudata;kn_flagskeepsEV_RECEIPTfrom the first add (line 1396 strips only the action flags).kqueue_scan: anEV_ONESHOTknote is copied out fromkn_keventwithout callingf_eventagain and then dropped, so it is reported withfflagsanddata0 and a laterEV_DELETEfails withENOENT.So every assertion in
FilesystemEvents()matches 11.4.What I ran
ctest -R '^guest_kqueue$' --repeat until-fail:3: passes, 3 of 3.main'sEqueue/src/Kqueue.cppwith this PR's test: aborts withkevent: filter -9 not implemented.python tools/check_conventions.py --base upstream/main: no errors; twodebt-lengthwarnings on thekqueue and keventandkevent measurementsentries, which are already over the limit onmain.Looks good.
AI-assisted: yes (Claude Code)