Skip to content

Skip procfs symlinks in virtual proc_path resolution#211

Merged
jserv merged 1 commit into
sysprog21:mainfrom
open-sources-port:proc_path
Jul 17, 2026
Merged

Skip procfs symlinks in virtual proc_path resolution#211
jserv merged 1 commit into
sysprog21:mainfrom
open-sources-port:proc_path

Conversation

@doanbaotrung

@doanbaotrung doanbaotrung commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

To fix fstatfs returning the incorrect magic on open descriptors of procfs magic links and symlinks, exclude paths like /proc/self/exe, /proc/self/cwd, /proc/self/root, /proc/self/fd/N, and task-specific equivalents from resolving to a virtual proc_path stamp.

This prevents the guest fd table from recording these entries as part of the emulated procfs, letting fstatfs correctly query the filesystem information of their resolved host file targets.

Fix #142


Summary by cubic

Fix statfs/fstatfs to report the correct filesystem type for /proc symlink targets and FDs by skipping virtual proc_path stamping and making statfs follow /proc symlinks (with a loop cap). Prevents mislabeling as procfs and fixes incorrect f_type. Fixes #142.

  • Bug Fixes

    • Skip /proc symlink and magic-link paths in proc_path resolution (/proc/self/exe, /proc/self/cwd, /proc/self/root, /proc/self/fd/N, and task variants).
    • statfs on these paths now follows the link and reports the target host filesystem; statfs on /proc and real proc files returns PROC_SUPER_MAGIC.
    • fstatfs on FDs from these paths now reports the target host filesystem.
  • Refactors

    • Removed proc_intercept_statfs; unified /proc statfs handling with a 40-step symlink-follow limit.
    • dirfd base path now returns ENOTDIR when a non-directory FD has a proc_path.

Written for commit d698f05. Summary will update on new commits.

Review in cubic

@doanbaotrung

doanbaotrung commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @jserv

So sorray the last PR #207.
I fixed but forgot to push.
This is for the update base on comments.

@doanbaotrung
doanbaotrung requested a review from jserv July 16, 2026 19:47
cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv jserv changed the title fs: skip procfs symlinks in virtual proc_path resolution Skip procfs symlinks in virtual proc_path resolution Jul 17, 2026
@jserv
jserv requested a review from Max042004 July 17, 2026 02:19

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Always enforce rules specified in https://cbea.ms/git-commit/ without leading tags such as fs:.

Comment thread src/syscall/fs-stat.c Outdated
To fix fstatfs returning the incorrect magic on open descriptors of
procfs magic links and symlinks, exclude paths like /proc/self/exe,
/proc/self/cwd, /proc/self/root, /proc/self/fd/N, and task-specific
equivalents from resolving to a virtual proc_path stamp.

This prevents the guest fd table from recording these entries as part
of the emulated procfs, letting fstatfs correctly query the filesystem
information of their resolved host file targets.

Fix sysprog21#142
@jserv
jserv merged commit deaaac2 into sysprog21:main Jul 17, 2026
9 checks passed
@jserv

jserv commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Thank @doanbaotrung for contributing!

@doanbaotrung
doanbaotrung deleted the proc_path branch July 17, 2026 03:48
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.

Missing proc_path for Dynamic/Non-Stateful procfs Files in sys_fstatfs

2 participants