-
Notifications
You must be signed in to change notification settings - Fork 4
Implement statx syscall for extended file metadata #613
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
Draft
wdcui
wants to merge
2
commits into
main
Choose a base branch
from
wdcui/statx
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+834
−2
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
Add support for the Linux statx(2) syscall which provides extended file metadata retrieval capabilities beyond the traditional stat family. ## Changes ### litebox_common_linux/src/lib.rs - Add `StatxFlags` bitflags (AT_EMPTY_PATH, AT_SYMLINK_NOFOLLOW, etc.) - Add `StatxMask` bitflags (STATX_TYPE, STATX_MODE, STATX_BASIC_STATS, etc.) - Add `StatxTimestamp` struct (16 bytes, matches Linux ABI) - Add `Statx` struct (256 bytes, architecture-independent) - Add `From<FileStatus> for Statx` conversion - Add `Statx` variant to `SyscallRequest` enum - Add syscall parsing for `Sysno::statx` ### litebox_shim_linux/src/lib.rs - Add dispatch case for `SyscallRequest::Statx` ### litebox_shim_linux/src/syscalls/file.rs - Implement `sys_statx()` method with: - Flag validation (FORCE_SYNC/DONT_SYNC mutually exclusive) - Mask validation (reject STATX_RESERVED) - AT_EMPTY_PATH support - AT_SYMLINK_NOFOLLOW support - Path resolution via FsPath - Add `filestat_to_statx()` helper for FileStat to Statx conversion ### litebox_shim_linux/src/syscalls/tests.rs - Add 7 unit tests for statx functionality ## Supported Features - Basic file metadata (type, mode, uid, gid, ino, size) - AT_EMPTY_PATH flag for operating on file descriptors directly - AT_SYMLINK_NOFOLLOW flag for not following symlinks - Directory metadata ## Known Limitations - Timestamps (atime, mtime, ctime, btime) return 0 (not tracked) - stx_blocks returns 0 (not tracked) - stx_mnt_id returns 0 (mount ID not tracked) - Direct I/O alignment fields return 0 (not supported) Co-Authored-By: Claude Opus 4.5 <[email protected]>
## ABI Fixes (Critical) - Fix Statx struct to include all Linux fields: - stx_subvol (subvolume identifier) - stx_atomic_write_unit_min/max (atomic write limits) - stx_atomic_write_segments_max (atomic write segments) - stx_dio_read_offset_align (direct I/O read alignment) - stx_atomic_write_unit_max_opt (optimized atomic write max) - __spare2 padding - Reduced __spare3 from 12 to 8 u64s - Add compile-time assertion for struct size (256 bytes) - Fix device number encoding to use Linux 20-bit minor numbers (major = dev >> 20, minor = dev & 0xfffff) ## Additional Tests - test_statx_empty_path_without_flag: empty path without AT_EMPTY_PATH - test_statx_symlink_nofollow_flag: AT_SYMLINK_NOFOLLOW flag acceptance - test_statx_invalid_negative_dirfd: invalid negative dirfd (not AT_FDCWD) - test_statx_eventfd: statx on eventfd descriptor - test_statx_pipe: statx on pipe descriptor Total: 12 statx tests (was 7) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
🤖 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
Add support for the Linux
statx(2)syscall which provides extended file metadata retrieval capabilities beyond the traditionalstatfamily of syscalls.Syscall Details
Changes
litebox_common_linux/src/lib.rsStatx,StatxTimestamp,StatxFlags,StatxMasktypes; addStatxvariant toSyscallRequest; add syscall parsinglitebox_shim_linux/src/lib.rsSyscallRequest::Statxlitebox_shim_linux/src/syscalls/file.rssys_statx()method with flag/mask validation, path resolutionlitebox_shim_linux/src/syscalls/tests.rsSupported Features
AT_EMPTY_PATHflag for operating on file descriptors directlyAT_SYMLINK_NOFOLLOWflag for not following symlinksAT_STATX_FORCE_SYNC/AT_STATX_DONT_SYNCflag validationKnown Limitations
stx_blocksreturns 0 (not tracked)stx_mnt_idreturns 0 (mount ID not tracked)Error Handling
EINVALEINVALENOENTEBADFEFAULTTest Coverage
test_statx_basic- Basic statx on a regular filetest_statx_empty_path- AT_EMPTY_PATH with fdtest_statx_invalid_flags- EINVAL for conflicting flagstest_statx_invalid_mask- EINVAL for reserved mask bitstest_statx_enoent- ENOENT for non-existent filetest_statx_ebadf- EBADF for invalid dirfdtest_statx_directory- Directory metadataTest plan
cargo clippy --all-targets --all-features -- -D warningscleancargo fmt --all -- --checkclean🤖 Generated with Claude Code