Repository navigation
feat(libkernel): support SEEK_DATA and SEEK_HOLE in lseek - #6936
AlexOfTheForest wants to merge 3 commits 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.
|
|
Windows run, since the PR lists Windows as untested and the Windows CI job is skipped on this head: Windows 11 10.0.26200.9711 (NTFS), WinLibs GCC 15.2.0 posix UCRT r7, Release, BUILD_TESTING=ON, head 8392e0c merged onto main f3263df (clean merge, no new build errors).
Not checked: sparse files with real holes on NTFS, or a title. AI-assisted: yes |
8392e0c to
b173bb7
Compare
b173bb7 to
1de206c
Compare
…of throwing sceKernelLseek threw on a whence other than SET, CUR and END, and lseek returned EINVAL before looking at the descriptor. FreeBSD 11.4's kern_lseek fetches the file first and dispatches to its fo_seek: a closed descriptor is EBADF, a pipe ESPIPE whatever the whence, and vn_seek rejects the unknown whence with EINVAL. Both calls now resolve the descriptor before the whence.
FreeBSD 11.4 accepts whence 3 and 4: vn_seek forwards them to FIOSEEKDATA and FIOSEEKHOLE, which UFS answers through vn_bmap_seekhole. An offset at or past the end of a regular file is ENXIO, a directory ENOTTY and a pipe ESPIPE; inside the file SEEK_DATA finds the next data and SEEK_HOLE the next hole, the end of the file counting as one. Linux and macOS ask the host for the same regions; Windows has no holes to report, so SEEK_DATA keeps the offset and SEEK_HOLE moves to the size. A negative offset, shared memory and devices throw, as the source does not settle them.
An archived descriptor fell through to AppArchiveDescriptorSeek, which throws on any whence but SET, CUR and END. An archived file has no holes: SEEK_DATA keeps an offset inside the file, SEEK_HOLE moves to its size and an offset at or past the end is ENXIO, as for a regular file.
1de206c to
f06949d
Compare
Review of PR #6936: feat(libkernel): support SEEK_DATA and SEEK_HOLE in lseekVerdict: stale+rebase Findings
Freshness Envelope
Cross-PR Ledger
|
There was a problem hiding this comment.
Correction (2026-11-01): the title-ID/log demand below is not a CONTRIBUTING requirement; Unblocks: none is allowed. The technical points below are unaffected.
The PR names no title that calls lseek with SEEK_DATA or SEEK_HOLE ("Unblocks: none") and shows no log line of a title reaching the change on main. Without that the new Seek.cpp surface (about 250 changed lines) is unreachable from anything that runs, and this kind of PR gets closed. Please add the title ID and the log line.
Two questions on the code:
sceKernelLseekused to throw on an unknown whence and now returnsEINVALfor anything outside 0 to 4. The description says this matcheskern_lseek; is that checked against a console trace or only against FreeBSD sources? The debt entry says the console's filesystems are unknown, and the same uncertainty applies to which errno the console returns here.- On Windows
SEEK_HOLEreturns the file size andSEEK_DATAreturns the offset, i.e. the whole file is data. That is correct for a filesystem without sparse reporting, but sparse files on NTFS do exist; if a title probes for holes it would see a different layout than on Linux. Is that recorded indocs/dev/debt/libkernel.md, or only the console side?
What
FreeBSD 11.4's
lseekacceptsSEEK_DATA(3) andSEEK_HOLE(4); AnyPS5 rejected them,sceKernelLseekthrew on any unknown whence, andlseekreturnedEINVALbefore looking at the descriptor. Three commits:fix(libkernel): an unknown whence fails as in FreeBSD'skern_lseek. The file is fetched first, so a closed descriptor isEBADFand a pipeESPIPEwhatever the whence.vn_seekrejects the unknown whence withEINVAL.sceKernelLseekno longer throws.feat(libkernel):SEEK_DATA/SEEK_HOLEasvn_seekandvn_bmap_seekholedefine them:ENXIO. Inside the file,SEEK_DATAfinds the next data andSEEK_HOLEthe next hole, with the end of the file counting as one.ENOTTY. Pipe:ESPIPE.SEEK_HOLEreturns the file size.feat(libkernel): the same onapp0.zardescriptors, which have no holes.The logic lives in
File/src/Seek.cpp. The console's filesystems are unknown (one withoutFIOSEEKDATAwould answerENOTTY), so this is recorded indocs/dev/debt/libkernel.md.GuestPosixScalarIoexpectedEINVALfor whence 3; it now checks an unknown whence (5) instead.Tested
Linux x86-64, GCC.
guest_lseek_whence:EINVAL,EBADFandESPIPE, through bothsceKernelLseekandlseek;SEEK_DATA/SEEK_HOLEinside a file, at its end and past it, and on an empty file, a directory and a pipe;guest_kernel_app_archivecovers archived files.guest_posix_scalar_io,guest_filesystemand the archive tests pass.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)