Repository navigation
Conversation
…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.
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
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)