Skip to content

fix(utils): map common Linux filesystem magic values#3023

Merged
overtrue merged 1 commit into
mainfrom
fix/646-linux-fs-magic-types
May 20, 2026
Merged

fix(utils): map common Linux filesystem magic values#3023
overtrue merged 1 commit into
mainfrom
fix/646-linux-fs-magic-types

Conversation

@overtrue
Copy link
Copy Markdown
Collaborator

Summary

  • Add tested Linux filesystem magic mappings for XFS and BTRFS.
  • Move the filesystem magic mapping helper into a small shared module so the mapping can be unit-tested on non-Linux hosts.
  • Preserve the unverified, less common magic values as TODOs instead of guessing mappings.

Backlog: rustfs/backlog#646

Validation

  • RED: PATH="$HOME/.cargo/bin:$PATH" cargo test -p rustfs-utils --features os map_common_linux_filesystem_magic_numbers -- --nocapture failed with UNKNOWN for XFS before adding the mappings.
  • GREEN: PATH="$HOME/.cargo/bin:$PATH" cargo test -p rustfs-utils --features os map_common_linux_filesystem_magic_numbers -- --nocapture
  • PATH="$HOME/.cargo/bin:$PATH" cargo test -p rustfs-utils --features os os:: -- --nocapture
  • PATH="$HOME/.cargo/bin:$PATH" cargo fmt --all --check
  • PATH="$HOME/.cargo/bin:$PATH" cargo clippy -p rustfs-utils --features os --tests -- -D warnings

Performance

  • The runtime work remains a single match on the filesystem magic number. The refactor only moves the helper for testability and adds two constant arms.

Copilot AI review requested due to automatic review settings May 20, 2026 01:40
@github-actions
Copy link
Copy Markdown
Contributor

CLA requirements are satisfied for this pull request.

Copy link
Copy Markdown
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 improves Linux filesystem type detection in rustfs-utils by adding verified magic-number mappings for XFS and BTRFS, and refactoring the mapping into a shared module so it can be unit-tested even on non-Linux hosts.

Changes:

  • Added XFS (0x58465342) and BTRFS (0x9123683E) filesystem magic mappings.
  • Moved the filesystem magic mapping helper out of os/linux.rs into a new os/fs_type.rs module.
  • Added unit tests covering the new magic-number mappings and preserved unverified mappings as TODOs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/utils/src/os/mod.rs Adds the new fs_type module to the OS utilities module tree.
crates/utils/src/os/linux.rs Switches Linux disk info code to use the shared get_fs_type helper.
crates/utils/src/os/fs_type.rs Introduces a shared filesystem-magic mapping helper and unit tests for XFS/BTRFS.

@overtrue overtrue added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit 1105426 May 20, 2026
12 checks passed
@overtrue overtrue deleted the fix/646-linux-fs-magic-types branch May 20, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants