Skip to content

fix(vfs): align statfs flags and sockfs metadata with Linux - #2586

Open
fslongjin wants to merge 1 commit into
DragonOS-Community:masterfrom
fslongjin:fix/gvisor-blocklist-sockfs-metadata
Open

fslongjin wants to merge 1 commit into
DragonOS-Community:masterfrom
fslongjin:fix/gvisor-blocklist-sockfs-metadata

Conversation

@fslongjin

Copy link
Copy Markdown
Member

Summary

This PR completes the P0 and P1 follow-ups from the gVisor blocklist revalidation and the Unix socket statfs/permission work, in one change set.

P0: gVisor blocklist infrastructure

  • Fix run_tests.sh corrupting its readv blocklist: awk ... "$BLOCKLIST_FILE" > "$BLOCKLIST_FILE" truncated the input before it was read. Rewrite through a sibling temp file and replace atomically with busybox mv -f.
  • Normalize ReadvTestNoFixture.TruncatedAtMax in both directions, so a persisted rootfs reused on a lower-memory machine cannot leave the 2GiB case enabled below the threshold. Matching now tolerates leading whitespace, #Test, and # Test forms.
  • Use busybox applets so the FAT32 rootfs does not depend on unsuffixed tools.
  • Correct the partial_bad_buffer_test spelling in both the whitelist and the blocklist filename.

P1: sockfs / statfs metadata semantics

  • Add StatFsFlags with the Linux UAPI ST_* values and translate the merged VFS mount/superblock flag word in From<SuperBlock> for PosixStatfs, mirroring Linux calculate_f_flags():
    • always report ST_VALID
    • translate RDONLY / NOSUID / NODEV / NOEXEC / SYNCHRONOUS / MANDLOCK / NOATIME / NODIRATIME / RELATIME / NOSYMFOLLOW
    • do not translate MS_DIRSYNC (Linux has no corresponding ST_* translation)
  • Report MMArch::PAGE_SIZE as the sockfs inode blk_size, matching Linux pseudo-filesystem i_blocksize().
  • Clarify that SuperBlock::flags carries the MountFS-merged mount + superblock flags.

Tests

  • sysfs_statfs_test: new StatfsFlags.MountFlagsUseStatfsAbi covering the MS_RELATIME | MS_NOSYMFOLLOW → ST_* translation.
  • unix_socket_stat_test: assert st_blksize == getpagesize(), sockfs f_flags == ST_VALID, and that fchmod updates mode/ctime without touching atime/mtime (avoids relying on inode timestamp initialization).

Validation

  • make kernel
  • cd kernel && cargo fmt --all -- --check
  • Host unix_socket_stat_test: 6/6 passed
  • Host sysfs_statfs_test: 4/4 passed
  • QEMU guest unix_socket_stat_test / sysfs_statfs_test: passed
  • QEMU guest gVisor statfs_test: 8 passed, 1 skipped
  • QEMU guest gVisor partial_bad_buffer_test: 19/19 after the blocklist entry, with only PartialBadBufferTest.SendMsgTCP still blocked

Scope

No web frontend changes. No unrelated refactoring.

Translate the merged VFS flag word into the statfs(2) ST_* ABI and
always advertise ST_VALID, matching Linux calculate_f_flags(). Report
PAGE_SIZE as the socket inode block size, and add dunitest coverage for
statfs flag translation and sockfs metadata.

Fix the gvisor runner corrupting its readv blocklist by redirecting awk
output onto the input file, normalize the heavy readv entry in both
memory-size directions, and use busybox applets so the FAT32 rootfs
does not depend on unsuffixed tools. Correct the partial_bad_buffer_test
spelling in the whitelist and blocklist filename.

Validated with make kernel, cargo fmt --check, host and QEMU guest
unix_socket_stat/sysfs_statfs runs, guest gvisor statfs_test (8 passed,
1 skipped), and guest partial_bad_buffer_test (19/19 after blocklist).

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin
fslongjin marked this pull request as ready for review November 5, 2026 06:52
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T06:56:57.705756Z 1fa57f5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added Bug fix A bug is fixed in this pull request test Unitest/User space test labels Nov 5, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 1fa57f5b02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

Bug fix A bug is fixed in this pull request test Unitest/User space test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant