Skip to content

Conversation

@Brian-Perkins
Copy link
Contributor

Support STATX opcode which is used to support the linux statx call and has become the default stat operation in modern linux distros.

@Brian-Perkins Brian-Perkins requested review from a team as code owners December 18, 2025 17:43
@github-actions github-actions bot added the unsafe Related to unsafe code label Dec 18, 2025
@github-actions
Copy link

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the STATX operation in the FUSE filesystem implementation to support the Linux statx system call, which has become the default stat operation in modern Linux distributions.

Key Changes:

  • Introduces a new StatEx struct that represents extended stat information with additional fields like creation time, extended attributes, and device major/minor numbers
  • Updates the internal fstat() and lstat() methods to return StatEx instead of Stat, with automatic conversion to Stat where needed for backward compatibility
  • Implements the FUSE STATX protocol including request parsing, session handling, and response generation

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vm/devices/virtio/virtiofs/src/util.rs Adds conversion functions from StatEx and StatExTimestamp to FUSE protocol structures
vm/devices/virtio/virtiofs/src/lib.rs Implements get_statx() method to handle STATX requests in VirtioFs
vm/devices/virtio/virtiofs/src/inode.rs Adds get_statx() method to retrieve extended attributes for inodes
vm/devices/virtio/virtiofs/src/file.rs Adds get_statx() method for open files and updates get_attr() to convert StatEx to Stat
vm/devices/support/fs/plan9/src/fid.rs Updates to convert StatEx to Stat for Plan9 filesystem compatibility
vm/devices/support/fs/lxutil/src/windows/util.rs Updates return type and mode casting for StatEx compatibility
vm/devices/support/fs/lxutil/src/windows/mod.rs Changes lstat() and fstat() to return StatEx, with conversions where needed
vm/devices/support/fs/lxutil/src/windows/fs.rs Implements full StatEx construction from Windows file attributes
vm/devices/support/fs/lxutil/src/unix/util.rs Adds conversion function from libc statx to lx::StatEx
vm/devices/support/fs/lxutil/src/unix/mod.rs Updates fstat() to use statx syscall and return StatEx
vm/devices/support/fs/lxutil/src/lib.rs Updates public API for lstat() and fstat(), adds new statx() method
vm/devices/support/fs/lx/src/lib.rs Defines StatEx, StatExMask, StatExAttributes, and StatExTimestamp structures with conversion from StatEx to Stat
vm/devices/support/fs/lx/Cargo.toml Adds dependencies for bitfield-struct, static_assertions, and zerocopy
vm/devices/support/fs/fuse/src/session.rs Handles STATX operation in the FUSE session
vm/devices/support/fs/fuse/src/request.rs Adds STATX operation to request parser with test case
vm/devices/support/fs/fuse/src/protocol.rs Defines FUSE STATX protocol structures including fuse_statx, fuse_sx_time, StatxFlags, fuse_statx_in, and fuse_statx_out
vm/devices/support/fs/fuse/src/lib.rs Adds get_statx() trait method and fuse_statx_out constructor
vm/devices/support/fs/fuse/Cargo.toml Adds bitfield-struct dependency
Cargo.lock Updates lock file with new dependencies

Comment on lines +538 to 539
pub fn fstat(&self) -> lx::Result<lx::StatEx> {
self.inner.fstat()
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The public API of fstat() now returns lx::StatEx instead of lx::Stat. This is a breaking change that will affect any code comparing Stat and StatEx values. Consider whether StatEx should also derive PartialEq and Eq to maintain compatibility with existing patterns, or ensure that all comparison code is updated to convert StatEx to Stat explicitly using .into() when needed.

Suggested change
pub fn fstat(&self) -> lx::Result<lx::StatEx> {
self.inner.fstat()
pub fn fstat(&self) -> lx::Result<lx::Stat> {
self.inner.fstat().map(Into::into)

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant