-
Notifications
You must be signed in to change notification settings - Fork 4
feat: implement preadv, pwritev, preadv2, pwritev2 syscalls #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
This commit adds support for positioned vectored I/O syscalls: - preadv: read from fd at offset into multiple buffers - pwritev: write to fd at offset from multiple buffers - preadv2: like preadv with RWF_* flags support - pwritev2: like pwritev with RWF_* flags support Key features: - Supports RWF_HIPRI, RWF_DSYNC, RWF_SYNC, RWF_NOWAIT, RWF_APPEND flags - offset=-1 in v2 variants falls back to readv/writev behavior - Returns ESPIPE for pipes/sockets (no positioned I/O) - Returns EINVAL for negative offsets - Returns EOPNOTSUPP for unknown flags - Handles x86 vs x86_64 ABI differences Includes unit tests for: - Basic preadv/pwritev operations - preadv2 with offset=-1 fallback - Invalid offset handling - Invalid flags handling
Address code review feedback by adding validation for iovcnt parameter. This prevents potential resource exhaustion from extremely large iovcnt values by limiting it to 1024 (Linux's UIO_MAXIOV).
|
🤖 SemverChecks 🤖 Click for details |
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.
Summary
This PR implements the positioned vectored I/O syscalls:
preadv: read from fd at offset into multiple bufferspwritev: write to fd at offset from multiple bufferspreadv2: like preadv with RWF_* flags supportpwritev2: like pwritev with RWF_* flags supportImplementation Details
New Types
RwfFlagsbitflags type with support for:RWF_HIPRI: High priority requestRWF_DSYNC: Per-I/O O_DSYNCRWF_SYNC: Per-I/O O_SYNCRWF_NOWAIT: Non-blocking operationRWF_APPEND: Per-I/O O_APPENDSyscall Behavior
offset=-1in v2 variants falls back to readv/writev behavior (uses current file position)ESPIPEfor pipes/sockets (positioned I/O not supported)EINVALfor negative offsetsEINVALforRWF_APPENDon read operationsEOPNOTSUPPfor unknown flagsFiles Modified
litebox_common_linux/src/lib.rs: Added RwfFlags type, syscall request variants, and parsinglitebox_shim_linux/src/lib.rs: Added syscall dispatch caseslitebox_shim_linux/src/syscalls/file.rs: Implemented syscall handlerslitebox_shim_linux/src/syscalls/tests.rs: Added unit testsTesting
test_preadv_pwritev_basic: Tests basic preadv and pwritev operationstest_preadv2_offset_minus_one: Tests preadv2 fallback to readv when offset=-1test_preadv_invalid_offset: Tests EINVAL for negative offsettest_preadv2_invalid_flags: Tests EINVAL for RWF_APPEND on readReferences
man 2 preadv,man 2 preadv2fs/read_write.c