FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

host_env: Simplify stat, fstatat with Rustix by joshuamegnauth54 · Pull Request #8455 · RustPython/RustPython · GitHub

host_env: Simplify stat, fstatat with Rustix - #8455

Merged
youknowone merged 1 commit into
RustPython:mainfrom
joshuamegnauth54:host_env-simplify-fstatat
Aug 8, 2026
Merged

host_env: Simplify stat, fstatat with Rustix#8455
youknowone merged 1 commit into
RustPython:mainfrom
joshuamegnauth54:host_env-simplify-fstatat

Conversation

joshuamegnauth54 commented Aug 5, 2026
edited by coderabbitai Bot
Loading

Copy link
Copy Markdown
Contributor

According to POSIX, time_t should be 64 bits. musl changed its time_t to an i64 over five years ago. glibc provides compatibility features that declare time_t as either i32 or i64. Rustix uses the raw Linux syscall for stat which returns an i64. For our purposes, an i64 makes sense because it's modern and avoids the year 2038 problem. It also reduces our dependency on what libc defines.

Sources:

Summary

Summary by CodeRabbit

  • Bug Fixes

    • Improved file and directory metadata handling across Unix-like platforms.
    • Preserved accurate directory detection and symbolic-link behavior.
    • Improved error handling for file status operations.
    • Standardized timestamp and filesystem block metadata for more reliable results.
  • Refactor

    • Unified filesystem status operations across supported Unix-like environments.
    • Improved compatibility across Unix-like and WASI platforms while preserving Windows behavior.

coderabbitai Bot commented Aug 5, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info ⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: b52aead3-702d-4304-b5fa-87220018cf62

📥 Commits

Reviewing files that changed from the base of the PR and between 1c7759c and 29ee814.

📒 Files selected for processing (6)
  • crates/host_env/src/fileutils.rs
  • crates/host_env/src/io.rs
  • crates/host_env/src/posix.rs
  • crates/host_env/src/posix_unix_like.rs
  • crates/host_env/src/posix_wasi.rs
  • crates/vm/src/stdlib/os.rs
💤 Files with no reviewable changes (2)
  • crates/host_env/src/posix_wasi.rs
  • crates/host_env/src/posix.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/host_env/src/fileutils.rs
  • crates/vm/src/stdlib/os.rs
  • crates/host_env/src/io.rs

📝 Walkthrough

Walkthrough

The change replaces non-Windows libc stat operations with Rustix, moves stat_path to the Unix-like implementation, updates VM path-stat wiring, and normalizes timestamp and filesystem block fields.

Changes

Filesystem stat migration

Layer / File(s) Summary
Rustix stat primitives
crates/host_env/src/fileutils.rs, crates/host_env/src/io.rs
Non-Windows stat structures, file descriptor stat calls, directory detection, and ISDIR errors now use Rustix.
Path stat implementation and wiring
crates/host_env/src/posix_unix_like.rs, crates/host_env/src/posix.rs, crates/host_env/src/posix_wasi.rs, crates/vm/src/stdlib/os.rs
Unix-like stat_path now uses Rustix statat. The previous platform implementations are removed. stat_inner passes OsPath directly and uses DirFd::get_opt().
Stat result normalization
crates/vm/src/stdlib/os.rs
Timestamp fields use i64. Filesystem block fields use u64. NetBSD uses the shared timestamp extraction path. Block conversions use fallback values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: youknowone

🚥 Pre-merge checks | ✅ 5 ✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: simplifying stat and fstatat handling in host_env with Rustix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

joshuamegnauth54 marked this pull request as ready for review August 5, 2026 02:36

coderabbitai Bot 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/host_env/src/fileutils.rs`:
- Line 5: Update the NetBSD branch in the OS stdlib implementation to access
StatStruct fields st_atime_nsec, st_mtime_nsec, and st_ctime_nsec, replacing the
legacy st_atimensec, st_mtimensec, and st_ctimensec names while preserving the
existing timestamp behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info ⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 30728473-f83e-44b2-88e7-d046b6050213

📥 Commits

Reviewing files that changed from the base of the PR and between 1fa76a3 and b08a96b.

📒 Files selected for processing (6)
  • crates/host_env/src/fileutils.rs
  • crates/host_env/src/io.rs
  • crates/host_env/src/posix.rs
  • crates/host_env/src/posix_unix_like.rs
  • crates/host_env/src/posix_wasi.rs
  • crates/vm/src/stdlib/os.rs
💤 Files with no reviewable changes (2)
  • crates/host_env/src/posix_wasi.rs
  • crates/host_env/src/posix.rs

joshuamegnauth54 marked this pull request as draft August 5, 2026 02:46

ShaharNaveh 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

as always, great finding!

ty<3

joshuamegnauth54 force-pushed the host_env-simplify-fstatat branch from b08a96b to 1c5a481 Compare August 6, 2026 02:44
joshuamegnauth54 marked this pull request as ready for review August 6, 2026 19:00
joshuamegnauth54 force-pushed the host_env-simplify-fstatat branch from 1c5a481 to 71d5994 Compare August 6, 2026 19:00

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

coderabbitai Bot 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/vm/src/stdlib/os.rs`:
- Around line 1237-1243: Fix the conditional compilation around the timestamp
assignments in the enclosing function by making the NetBSD condition consistent
across both adjacent cfg attributes. Remove NetBSD from the exclusion in the
second cfg so atime, mtime, and ctime are assigned for NetBSD while retaining
the existing WASI exclusion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info ⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5da13ae1-5f7a-4177-8be0-3eaf2ee864fc

📥 Commits

Reviewing files that changed from the base of the PR and between 1c7759c and 71d5994.

📒 Files selected for processing (6)
  • crates/host_env/src/fileutils.rs
  • crates/host_env/src/io.rs
  • crates/host_env/src/posix.rs
  • crates/host_env/src/posix_unix_like.rs
  • crates/host_env/src/posix_wasi.rs
  • crates/vm/src/stdlib/os.rs
💤 Files with no reviewable changes (2)
  • crates/host_env/src/posix.rs
  • crates/host_env/src/posix_wasi.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/host_env/src/posix_unix_like.rs
  • crates/host_env/src/fileutils.rs
  • crates/host_env/src/io.rs

Comment thread crates/vm/src/stdlib/os.rs Outdated
joshuamegnauth54 force-pushed the host_env-simplify-fstatat branch from 71d5994 to 62419ec Compare August 6, 2026 19:10

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

According to POSIX, `time_t` should be 64 bits. `musl` changed its
`time_t` to an `i64` over five years ago. `glibc` provides compatibility
features that declare `time_t` as either `i32` or `i64`. Rustix uses the
raw Linux syscall for stat which returns an `i64`. For our purposes, an
`i64` makes sense because it's modern and avoids the year 2038 problem.
It also reduces our dependency on what `libc` defines.

Sources:
* https://www.man7.org/linux/man-pages/man3/time_t.3type.html
* https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html
joshuamegnauth54 force-pushed the host_env-simplify-fstatat branch from 62419ec to 29ee814 Compare August 7, 2026 02:52

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Copy link
Copy Markdown
Contributor Author

Cargo shear failed randomly. 🤔

fanninpm commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Cargo shear failed randomly. 🤔

@ShaharNaveh

youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks, I wish we didn't lose CPython compatible behavior by this

youknowone merged commit 1819677 into RustPython:main Aug 8, 2026
51 of 52 checks passed
joshuamegnauth54 deleted the host_env-simplify-fstatat branch August 8, 2026 18:17
kyokuping pushed a commit to kyokuping/RustPython that referenced this pull request Aug 9, 2026
According to POSIX, `time_t` should be 64 bits. `musl` changed its
`time_t` to an `i64` over five years ago. `glibc` provides compatibility
features that declare `time_t` as either `i32` or `i64`. Rustix uses the
raw Linux syscall for stat which returns an `i64`. For our purposes, an
`i64` makes sense because it's modern and avoids the year 2038 problem.
It also reduces our dependency on what `libc` defines.

Sources:
* https://www.man7.org/linux/man-pages/man3/time_t.3type.html
* https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html
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
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.

4 participants


Back | FazBrowse Home | New Git URL