Repository navigation
fix(libkernel): getdirentries reports the file number lstat reports on Windows - #11311
Gruzzberry wants to merge 1 commit into
Conversation
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
160c10b to
3997396
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
The NTFS/file-ID path is well targeted: it reuses WindowsFileNumber_nid_no_patch and the Windows regression compares d_fileno with lstat across stable rereads, Unicode names and a symlink. I found one explicitly acknowledged uncovered behavior that needs resolution before approval: when GetFileInformationByHandleEx cannot supply file IDs, libc falls back to StableFileNumber(seed, fileName) in Directory.cpp, but this kernel path assigns enumeration-order numbers. In that case getdents still disagrees with readdir/lstat, and insertion order can change a name’s value. Please either use the same fallback algorithm here or record this known gap in docs/dev/debt/libkernel.md as required for known behavior gaps. The volume-root ./.. exception should be included in the note if it remains. Hosted conventions, eligibility, intake, labels and report pass; Windows product jobs were skipped by path policy, so the author-reported WinLibs test is the available platform execution evidence.
…n Windows Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3997396 to
ed7b7e9
Compare
|
Closing as superseded: since #8520 (0a64d23) This PR conflicts with The test is still useful: |
What
On Windows
getdirentriesandgetdentsnumbered the entries of a directory 1, 2, 3 in the order they were read, sod_filenonever matched thest_inothatstatandlstatreport for the same file, and the same name could get a different number after the directory changed and was read again. FreeBSD 11.4'sufs_readdir(ufs_vnops.c) setsdstdp.d_fileno = dp->d_ino, the inodestatreturns. The libcreaddiralready does this on Windows, taking the file id from the directory listing (FileIdBothDirectoryInfo) throughWindowsFileNumber_nid_no_patch; the kernel call now reads the same listing and uses the same function, so both give the same number for every entry, and for entrieslstatcan read (the common case, accented and Japanese names and links included) that is also the numberlstatreports. Two cases are not covered: a file system that cannot list file ids (libc falls back to a hash of the name, the kernel call keeps the running number it had before), and..at the guest root and.or..at a volume root, which are host directories.The same probe found nothing else to change in
getdirentriesthat is not already covered:(8 + namlen + 1 + 3) & ~3, the 4-byteGENERIC_DIRSIZof FreeBSD 11, and names in UTF-8 are reported byte for byte.EINVAL, a descriptor that is not a directoryEINVAL, a closed oneEBADF, a null bufferEFAULT, and the end of the directory0.d_typefor Windows links is the subject of fix(libkernel): classify Windows directory links by app0 scope #8726 and is left alone. A zero-length buffer returnsEINVALhere and an existing test pins that;kern_getdirentriesin FreeBSD would return0, which I did not change.Tested
Windows 11 (10.0.26200), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
-DBUILD_TESTING=ON, on currentmain.guest_directory_entries: new checks (Windows only) thatd_filenoof every entry read withgetdentsequals thest_inooflstaton the same name, for the fixture directory and for a directory with a file link and file names containing an accented letter and Japanese characters, and that the numbers of existing names do not change after another file is added and the directory is read again. Onmainthe test fails; with this change it passes, three runs out of three.pr_overlap_encoding,agc_host_import_cut_lifetimeandagc_driver_depth_plane_partial_store, which fail onmainin this environment too.python tools/check_conventions.py --base upstream/main: passes.Overlaps
#8520, #8726 and #9947 change nearby lines of
DirectoryDescriptor.cpp: proposed on each that it goes first and this PR rebases.Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); no silent stubs added.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code