GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — host_env: Simplify stat, fstatat with Rustix by joshuamegnauth54 · Pull Request #8455 · RustPython/RustPython

Conversation

@joshuamegnauth54

@joshuamegnauth54 joshuamegnauth54 commented Aug 5, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

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:

  • https://www.man7.org/linux/man-pages/man3/time_t.3type.html
  • https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html
  • Closes #xxxx
  • This PR follows our AI policy

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

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

  • RustPython/RustPython#7035: Updates related host_env filesystem and Rustix OS error handling.
  • RustPython/RustPython#7604: Refines the host_env stat APIs and stat_path implementation.
  • RustPython/RustPython#7932: Isolates platform-specific filesystem and stat APIs in host_env.

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshuamegnauth54
joshuamegnauth54 marked this pull request as ready for review August 5, 2026 02:36
coderabbitai[bot]
coderabbitai Bot reviewed Aug 5, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/host_env/src/fileutils.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@joshuamegnauth54
joshuamegnauth54 marked this pull request as draft August 5, 2026 02:46
ShaharNaveh
ShaharNaveh approved these changes Aug 5, 2026
View reviewed changes

@ShaharNaveh ShaharNaveh left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

as always, great finding!

ty<3

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]
coderabbitai Bot reviewed Aug 6, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/vm/src/stdlib/os.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@joshuamegnauth54
joshuamegnauth54 force-pushed the host_env-simplify-fstatat branch from 71d5994 to 62419ec Compare August 6, 2026 19:10
@coderabbitai

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshuamegnauth54
host_env: Simplify stat, fstatat with Rustix
29ee814
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
joshuamegnauth54 force-pushed the host_env-simplify-fstatat branch from 62419ec to 29ee814 Compare August 7, 2026 02:52
@coderabbitai

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshuamegnauth54

joshuamegnauth54 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Cargo shear failed randomly. 🤔

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fanninpm

fanninpm commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Cargo shear failed randomly. 🤔

@ShaharNaveh

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone
youknowone approved these changes Aug 8, 2026
View reviewed changes

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
youknowone merged commit 1819677 into RustPython:main Aug 8, 2026
51 of 52 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@joshuamegnauth54
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
@joshuamegnauth54 @kyokuping
host_env: Simplify stat, fstatat with Rustix (RustPython#8455)
ad084d7
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
youknowone pushed a commit that referenced this pull request Sep 16, 2026
@joshuamegnauth54
host_env: Simplify stat, fstatat with Rustix (#8455)
15f8590
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@youknowone youknowone youknowone approved these changes
@ShaharNaveh ShaharNaveh ShaharNaveh approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@joshuamegnauth54 @fanninpm @youknowone @ShaharNaveh
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.