Repository navigation
Conversation
EVFILT_VNODE and sceKernelAddFileEvent threw for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, NOTE_READ, NOTE_REVOKE and unknown bits, and for a descriptor that is not a file, a directory, a pipe or a socket. As FreeBSD 11's vop_open_post, vop_read_post, vop_readdir_post and vop_close_post raise them, a successful open, read, readv, pread, preadv, AIO read or getdents now reports NOTE_OPEN or NOTE_READ to the vnode watches of that file, and closing the last descriptor of an open file, dup2 onto it included, reports NOTE_CLOSE, or NOTE_CLOSE_WRITE when the file was opened for writing. Files are matched by the st_dev and st_ino that fstat reports, and the watches of a closed descriptor are removed before its close is reported, as closefp calls knote_fdclose first. NOTE_REVOKE and unknown bits are accepted, as vfs_kqfilter does not check fflags, and a file read from app0.zar is watched for these notes only. A character device fails with ENODEV and a terminal with EINVAL, as no_kqfilter and ttydev_kqfilter answer.
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
EVFILT_VNODE(kevent) andsceKernelAddFileEventthrew forNOTE_OPEN,NOTE_CLOSE,NOTE_CLOSE_WRITE,NOTE_READ,NOTE_REVOKEand unknown bits, and for a descriptor that is not a file, a directory, a pipe or a socket. They now follow FreeBSD 11:vop_open_postNOTE_OPENafter a successful open of the file (open,openat,sceKernelOpen)vop_read_post,vop_readdir_postNOTE_READafter a successfulread,readv,pread,preadv, theirsceKernel*forms, AIO read orgetdents/getdirentries, zero bytes includedvop_close_postNOTE_CLOSE, orNOTE_CLOSE_WRITEwhen it was opened for writing;dup2onto it counts; adupstill open defers itclosefpcallsknote_fdclosefirstNOTE_REVOKE, unknown bitsvfs_kqfilterdoes not checkfflagsno_kqfilterENODEV(/dev/urandom, the null device)ttydev_kqfilterEINVALWindows and macOS have no host notification for opens, reads or closes, so these notes come from libkernel's own calls on every host: each vnode watch is recorded with the
st_devandst_inothatfstatreports, and the open, read and close paths deliver to the watches of the same file. Nothing is looked up while no watch exists. The last-descriptor test uses the open-file status thatdupalready shares; the write test asks the host access mode asfcntl(F_GETFL)does. A file read from app0.zar is watched for these notes only, as the archive never changes.Gaps, in the libkernel debt entry: libc streams (
fopen,fread) read through the host C runtime and raise none of these notes; other host processes neither; JIT shared memory is watched as its host file, where FreeBSD shared memory answersEINVAL.Overlaps: boykopovar#7088 (kevent read and write on regular files) changes the
VnodeWatchconstructor, and boykopovar#7092 (NOTE_LOWAT) the lines next to the removedfflagscheck inKqueue.cpp; both merge into this with one-line conflicts, whichever lands second.Tested
Windows 10 Pro 22H2 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Ninja, Release,
BUILD_TESTING=ON, onmaine09dbc2b4:guest_kqueuewith two new cases.AccessNotes: open, read, read at end of file andpreadof another descriptor reportNOTE_OPENthenNOTE_READ; closing aduped descriptor reports nothing until the last copy closes (NOTE_CLOSE); a read-write descriptor closes withNOTE_CLOSE_WRITE;dup2onto an open descriptor reportsNOTE_CLOSE;sceKernelAddFileEventgetsNOTE_OPENwith itsudata; closing the watched descriptor removes its own watch while a watch through another descriptor getsNOTE_CLOSE;/dev/urandomfails withENODEVfrom both calls.DirectoryAccessNotes: open,getdentsand close of a directory.FileWatchnow checks thatNOTE_REVOKEwith an unknown bit is accepted and reports nothing. Passes 20 of 20 repeated runs.main's libkernel fails withEVFILT_VNODE: fflags 1048640 not implemented.ctest -j 12: 1379 of 1382 pass. The three others are unrelated:select_testsneeds symbolic link privilege on Windows, andagc_driver_f16_fma_denormal_modesandagc_driver_fma_mix_f16_denormal_modesget NVIDIA's f16 NaN (0x7fff) where they expect 0xfe00.python tools/check_conventions.py --base origin/mainpasses.isatty, and the notes come from the same shared code.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)