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 — gh-83714: Use `statx` on more recent Linux to expose `st_flags` and `st_btime` on all platforms by ntninja · Pull Request #19125 · python/cpython

Conversation

@ntninja

@ntninja ntninja commented Mar 23, 2020 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown

Still missing tests, but I'd appreciate feedback on the changes themselves in the meantime. Also ideas for properly testing btime would be appreciated.

#83714

  • Issue: Add os.statx() function #83714

Sorry, something went wrong.

Uh oh!

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

jbosboom, SebAlbert, efiop, and landcaster reacted with thumbs up emoji
All reactions
  • 👍 4 reactions
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 23, 2020
@bedevere-bot bedevere-bot added the awaiting review label Mar 23, 2020
@ntninja
ntninja force-pushed the fix-issue-39533 branch 4 times, most recently from 1c474bf to bd158bb Compare March 27, 2020 17:48
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
SebAlbert
SebAlbert reviewed Sep 5, 2022
View reviewed changes
Comment thread Doc/library/os.rst Resolved

Uh oh!

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

@ntninja
ntninja force-pushed the fix-issue-39533 branch from bd158bb to 8a8bab2 Compare September 12, 2022 23:17
@ghost

ghost commented Sep 12, 2022 •
edited by ghost
Loading

Uh oh!

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

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

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

@alexander255 alexander255 mannequin mentioned this pull request Sep 12, 2022
Add os.statx() function #83714
Closed
@ntninja
ntninja force-pushed the fix-issue-39533 branch 3 times, most recently from 667ece4 to 4d1edcc Compare September 13, 2022 00:44
ntninja added 7 commits September 15, 2022 16:51
@ntninja
Update file flag bits in the stat module and add the relevant Linux ones
4d82bc3
@ntninja
Always expose st_flags and st_btime{,_ns} on all platforms
e6bd28b
On BSD/macOS this uses the value of `st_birthtime` (which remains for
compatibity reasons), on Windows it duplicates the value of `st_ctime`.

A Linux implementation is added in subsequent commits.
@ntninja
Add option to enable Linux statx in configure
c07edf2
It cannot be enabled by default because this implementation does not have
any fallback to plain stat for older kernels and Linux 4.11 is still fairly
recent. The configure checks also ensure that the C library expose the
proper stub functions (glibc 2.28+ only).
@ntninja
Add statx-based stat implementation for Linux
54a23b5
@ntninja
Map Linux STATX_FLAG_* and Windows FILE_ATTRIBUTE_* flags to their BS…
53cee11
…D UF_* equivalent as defined by FreeBSD
@ntninja
bpo-39533: Add documentation on new :func:os.stat properties
16775d0
@ntninja
Add support for STATX_ATTR_{VERITY,DAX} and the new stx_mnt_id field
9aae324
@ntninja
ntninja force-pushed the fix-issue-39533 branch from 4d1edcc to 9aae324 Compare September 15, 2022 14:56
@martonivan martonivan mentioned this pull request Mar 6, 2024
gh-84649: Make TimedRotatingFileHandler use CTIME instead of MTIME #24660
Merged
@jbosboom jbosboom mentioned this pull request Jul 6, 2025
gh-83714: Use statx on Linux 4.11 and later in os.stat #136334
Closed
ExplodingCabbage
ExplodingCabbage reviewed Aug 27, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2020-03-23-18-21-49.bpo-32592.KvFMeC.rst
Use the ``statx(2)`` system call for :func:`os.stat` under Linux to provide
cross-platform support for btime (time of file creation) and file
attributes. On Windows btime is emulated using ctime and both Linux and
Windows file attributes are converted to their (Free)BSD equivalent were

@ExplodingCabbage ExplodingCabbage Aug 27, 2025

Copy link
Copy Markdown

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.

typo - "were" should be "where"

Sorry, something went wrong.

Uh oh!

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

All reactions
gpshead
gpshead approved these changes Aug 30, 2025
View reviewed changes
Comment thread Doc/library/stat.rst
STATX_ATTR_VERITY
STATX_ATTR_DAX

.. versionadded:: 3.12

@gpshead gpshead Aug 30, 2025

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.

tip - update version markers in docs to "next" and it'll automagically use the right version.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Aug 30, 2025
@cmaloney

cmaloney commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

Could this be performance checked against the existing stat? Stat is called a lot (in Python 3.14 on linux once for every file opened which includes imports by default) and my worry is issues like https://lwn.net/Articles/944214/ where the different variants of stat have quite a bit of performance delta.

All reactions

Sorry, something went wrong.

Uh oh!

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

@gpshead

gpshead commented Aug 31, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Another take on this: How about not modifying os.stat behavior at all but instead introduce an os.statx API that uses the more modern system call when available and exposes its functionality - in particular the mask functionality so that people can call it and get only the specific data they want instead of a large everything-bagel os.stat result.

The os module is all about providing wrappers around the underlying platform APIs.
(edit: raised this question on the issue)

cmaloney reacted with thumbs up emoji hydrargyrum reacted with thumbs down emoji
All reactions
  • 👍 1 reaction
  • 👎 1 reaction

Sorry, something went wrong.

Uh oh!

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

@gpshead gpshead changed the title bpo-39533: Use statx on more recent Linux to expose st_flags and st_btime on all platforms gh-83714: Use statx on more recent Linux to expose st_flags and st_btime on all platforms Aug 31, 2025
@vstinner

vstinner commented Oct 21, 2025

Copy link
Copy Markdown
Member

Another take on this: How about not modifying os.stat behavior at all but instead introduce an os.statx API that uses the more modern system call when available and exposes its functionality - in particular the mask functionality so that people can call it and get only the specific data they want instead of a large everything-bagel os.stat result.

os.statx() has been added. This PR is now outdated, I close it. There is a discussion on using os.statx() in pathlib.

cmaloney reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner closed this Oct 21, 2025
@vstinner

vstinner commented Oct 21, 2025

Copy link
Copy Markdown
Member

Thanks @ntninja for your contribution even if it was taken as it is. Exposing new syscalls is non trivial, it takes time to decide how to expose it in Python.

All reactions

Sorry, something went wrong.

Uh oh!

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

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

Reviewers

@gpshead gpshead gpshead approved these changes
+2 more reviewers
@SebAlbert SebAlbert SebAlbert left review comments
@ExplodingCabbage ExplodingCabbage ExplodingCabbage left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

awaiting merge

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.

9 participants

@ntninja @cmaloney @gpshead @vstinner @SebAlbert @ExplodingCabbage @the-knights-who-say-ni @ezio-melotti @bedevere-bot
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 01402503 — 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.