Skip to content

Commit 7339cf7

Browse files
authored
gh-83714: Use "stx_" prefix for all os.statx_result members (#140432)
Rename stx_birthtime to stx_btime, and rename stx_birthtime_ns to stx_btime_ns.
1 parent b3a3843 commit 7339cf7

File tree

6 files changed

+263
-147
lines changed

6 files changed

+263
-147
lines changed

Doc/library/os.rst

Lines changed: 177 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3411,133 +3411,248 @@ features:
34113411

34123412
Information about a file returned by :func:`os.statx`.
34133413

3414-
:class:`!statx_result` has all the attributes that :class:`~stat_result` has
3415-
on Linux, making it :term:`duck-typing` compatible, but
3416-
:class:`!statx_result` is not a subclass of :class:`~stat_result` and cannot
3417-
be used as a tuple.
3418-
3419-
:class:`!statx_result` has the following additional attributes:
3414+
:class:`!statx_result` has the following attributes:
34203415

34213416
.. attribute:: stx_mask
34223417

34233418
Bitmask of :const:`STATX_* <STATX_TYPE>` constants specifying the
34243419
information retrieved, which may differ from what was requested.
34253420

3426-
.. attribute:: stx_attributes_mask
3421+
.. attribute:: stx_atime
34273422

3428-
Bitmask of :const:`STATX_ATTR_* <stat.STATX_ATTR_COMPRESSED>` constants
3429-
specifying the attributes bits supported for this file.
3423+
Time of most recent access expressed in seconds.
3424+
3425+
Equal to ``None`` if :data:`STATX_ATIME` is missing from
3426+
:attr:`~statx_result.stx_mask`.
3427+
3428+
.. attribute:: stx_atime_ns
3429+
3430+
Time of most recent access expressed in nanoseconds as an integer.
3431+
3432+
Equal to ``None`` if :data:`STATX_ATIME` is missing from
3433+
:attr:`~statx_result.stx_mask`.
3434+
3435+
.. attribute:: stx_atomic_write_segments_max
3436+
3437+
Maximum iovecs for direct I/O with torn-write protection.
3438+
3439+
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3440+
:attr:`~statx_result.stx_mask`.
3441+
3442+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3443+
userspace API headers >= 6.11.
3444+
3445+
.. attribute:: stx_atomic_write_unit_min
3446+
3447+
Minimum size for direct I/O with torn-write protection.
3448+
3449+
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3450+
:attr:`~statx_result.stx_mask`.
3451+
3452+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3453+
userspace API headers >= 6.11.
3454+
3455+
.. attribute:: stx_atomic_write_unit_max
3456+
3457+
Maximum size for direct I/O with torn-write protection.
3458+
3459+
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3460+
:attr:`~statx_result.stx_mask`.
3461+
3462+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3463+
userspace API headers >= 6.11.
3464+
3465+
.. attribute:: stx_atomic_write_unit_max_opt
3466+
3467+
Maximum optimized size for direct I/O with torn-write protection.
3468+
3469+
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3470+
:attr:`~statx_result.stx_mask`.
3471+
3472+
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3473+
userspace API headers >= 6.16.
34303474

34313475
.. attribute:: stx_attributes
34323476

34333477
Bitmask of :const:`STATX_ATTR_* <stat.STATX_ATTR_COMPRESSED>` constants
34343478
specifying the attributes of this file.
34353479

3436-
.. attribute:: stx_dev_major
3480+
.. attribute:: stx_attributes_mask
34373481

3438-
Major number of the device on which this file resides.
3482+
A mask indicating which bits in :attr:`stx_attributes` are supported by
3483+
the VFS and the filesystem.
34393484

3440-
.. attribute:: stx_dev_minor
3485+
.. attribute:: stx_blksize
34413486

3442-
Minor number of the device on which this file resides.
3487+
"Preferred" blocksize for efficient file system I/O. Writing to a file in
3488+
smaller chunks may cause an inefficient read-modify-rewrite.
34433489

3444-
.. attribute:: stx_rdev_major
3490+
.. attribute:: stx_blocks
34453491

3446-
Major number of the device this file represents.
3492+
Number of 512-byte blocks allocated for file.
3493+
This may be smaller than :attr:`stx_size`/512 when the file has holes.
34473494

3448-
.. attribute:: stx_rdev_minor
3495+
Equal to ``None`` if :data:`STATX_BLOCKS` is missing from
3496+
:attr:`~statx_result.stx_mask`.
34493497

3450-
Minor number of the device this file represents.
3498+
.. attribute:: stx_btime
34513499

3452-
.. attribute:: stx_mnt_id
3500+
Time of file creation expressed in seconds.
34533501

3454-
Mount identifier.
3502+
Equal to ``None`` if :data:`STATX_BTIME` is missing from
3503+
:attr:`~statx_result.stx_mask`.
34553504

3456-
Equal to ``None`` if :data:`STATX_MNT_ID` is missing from
3457-
:attr:`~os.statx_result.stx_mask`.
3505+
.. attribute:: stx_btime_ns
34583506

3459-
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3460-
userspace API headers >= 5.8.
3507+
Time of file creation expressed in nanoseconds as an integer.
34613508

3462-
.. attribute:: stx_dio_mem_align
3509+
Equal to ``None`` if :data:`STATX_BTIME` is missing from
3510+
:attr:`~statx_result.stx_mask`.
34633511

3464-
Direct I/O memory buffer alignment requirement.
3512+
.. attribute:: stx_ctime
34653513

3466-
Equal to ``None`` if :data:`STATX_DIOALIGN` is missing from
3467-
:attr:`~os.statx_result.stx_mask`.
3514+
Time of most recent metadata change expressed in seconds.
34683515

3469-
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3470-
userspace API headers >= 6.1.
3516+
Equal to ``None`` if :data:`STATX_CTIME` is missing from
3517+
:attr:`~statx_result.stx_mask`.
3518+
3519+
.. attribute:: stx_ctime_ns
3520+
3521+
Time of most recent metadata change expressed in nanoseconds as an
3522+
integer.
3523+
3524+
Equal to ``None`` if :data:`STATX_CTIME` is missing from
3525+
:attr:`~statx_result.stx_mask`.
3526+
3527+
.. attribute:: stx_dev
3528+
3529+
Identifier of the device on which this file resides.
3530+
3531+
.. attribute:: stx_dev_major
3532+
3533+
Major number of the device on which this file resides.
3534+
3535+
.. attribute:: stx_dev_minor
3536+
3537+
Minor number of the device on which this file resides.
34713538

34723539
.. attribute:: stx_dio_offset_align
34733540

34743541
Direct I/O file offset alignment requirement.
34753542

34763543
Equal to ``None`` if :data:`STATX_DIOALIGN` is missing from
3477-
:attr:`~os.statx_result.stx_mask`.
3544+
:attr:`~statx_result.stx_mask`.
34783545

34793546
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
34803547
userspace API headers >= 6.1.
34813548

3482-
.. attribute:: stx_subvol
3549+
.. attribute:: stx_dio_mem_align
34833550

3484-
Subvolume identifier.
3551+
Direct I/O memory buffer alignment requirement.
34853552

3486-
Equal to ``None`` if :data:`STATX_SUBVOL` is missing from
3487-
:attr:`~os.statx_result.stx_mask`.
3553+
Equal to ``None`` if :data:`STATX_DIOALIGN` is missing from
3554+
:attr:`~statx_result.stx_mask`.
34883555

34893556
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3490-
userspace API headers >= 6.10.
3557+
userspace API headers >= 6.1.
34913558

3492-
.. attribute:: stx_atomic_write_unit_min
3559+
.. attribute:: stx_dio_read_offset_align
34933560

3494-
Minimum size for direct I/O with torn-write protection.
3561+
Direct I/O file offset alignment requirement for reads.
34953562

3496-
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3497-
:attr:`~os.statx_result.stx_mask`.
3563+
Equal to ``None`` if :data:`STATX_DIO_READ_ALIGN` is missing from
3564+
:attr:`~statx_result.stx_mask`.
34983565

34993566
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3500-
userspace API headers >= 6.11.
3567+
userspace API headers >= 6.14.
35013568

3502-
.. attribute:: stx_atomic_write_unit_max
3569+
.. attribute:: stx_gid
35033570

3504-
Maximum size for direct I/O with torn-write protection.
3571+
Group identifier of the file owner.
35053572

3506-
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3507-
:attr:`~os.statx_result.stx_mask`.
3573+
Equal to ``None`` if :data:`STATX_GID` is missing from
3574+
:attr:`~statx_result.stx_mask`.
35083575

3509-
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3510-
userspace API headers >= 6.11.
3576+
.. attribute:: stx_ino
35113577

3512-
.. attribute:: stx_atomic_write_unit_max_opt
3578+
Inode number.
35133579

3514-
Maximum optimized size for direct I/O with torn-write protection.
3580+
Equal to ``None`` if :data:`STATX_INO` is missing from
3581+
:attr:`~statx_result.stx_mask`.
35153582

3516-
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3517-
:attr:`~os.statx_result.stx_mask`.
3583+
.. attribute:: stx_mnt_id
3584+
3585+
Mount identifier.
3586+
3587+
Equal to ``None`` if :data:`STATX_MNT_ID` is missing from
3588+
:attr:`~statx_result.stx_mask`.
35183589

35193590
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3520-
userspace API headers >= 6.16.
3591+
userspace API headers >= 5.8.
35213592

3522-
.. attribute:: stx_atomic_write_segments_max
3593+
.. attribute:: stx_mode
35233594

3524-
Maximum iovecs for direct I/O with torn-write protection.
3595+
File mode: file type and file mode bits (permissions).
35253596

3526-
Equal to ``None`` if :data:`STATX_WRITE_ATOMIC` is missing from
3527-
:attr:`~os.statx_result.stx_mask`.
3597+
.. attribute:: stx_mtime
35283598

3529-
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3530-
userspace API headers >= 6.11.
3599+
Time of most recent content modification expressed in seconds.
35313600

3532-
.. attribute:: stx_dio_read_offset_align
3601+
Equal to ``None`` if :data:`STATX_MTIME` is missing from
3602+
:attr:`~statx_result.stx_mask`.
35333603

3534-
Direct I/O file offset alignment requirement for reads.
3604+
.. attribute:: stx_mtime_ns
35353605

3536-
Equal to ``None`` if :data:`STATX_DIO_READ_ALIGN` is missing from
3537-
:attr:`~os.statx_result.stx_mask`.
3606+
Time of most recent content modification expressed in nanoseconds as an
3607+
integer.
3608+
3609+
Equal to ``None`` if :data:`STATX_MTIME` is missing from
3610+
:attr:`~statx_result.stx_mask`.
3611+
3612+
.. attribute:: stx_nlink
3613+
3614+
Number of hard links.
3615+
3616+
Equal to ``None`` if :data:`STATX_NLINK` is missing from
3617+
:attr:`~statx_result.stx_mask`.
3618+
3619+
.. attribute:: stx_rdev
3620+
3621+
Type of device if an inode device.
3622+
3623+
.. attribute:: stx_rdev_major
3624+
3625+
Major number of the device this file represents.
3626+
3627+
.. attribute:: stx_rdev_minor
3628+
3629+
Minor number of the device this file represents.
3630+
3631+
.. attribute:: stx_size
3632+
3633+
Size of the file in bytes, if it is a regular file or a symbolic link.
3634+
The size of a symbolic link is the length of the pathname it contains,
3635+
without a terminating null byte.
3636+
3637+
Equal to ``None`` if :data:`STATX_SIZE` is missing from
3638+
:attr:`~statx_result.stx_mask`.
3639+
3640+
.. attribute:: stx_subvol
3641+
3642+
Subvolume identifier.
3643+
3644+
Equal to ``None`` if :data:`STATX_SUBVOL` is missing from
3645+
:attr:`~statx_result.stx_mask`.
35383646

35393647
.. availability:: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3540-
userspace API headers >= 6.14.
3648+
userspace API headers >= 6.10.
3649+
3650+
.. attribute:: stx_uid
3651+
3652+
User identifier of the file owner.
3653+
3654+
Equal to ``None`` if :data:`STATX_UID` is missing from
3655+
:attr:`~statx_result.stx_mask`.
35413656

35423657
.. seealso:: The :manpage:`statx(2)` man page.
35433658

Doc/whatsnew/3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ os
438438

439439
* Add :func:`os.statx` on Linux kernel versions 4.11 and later with
440440
glibc versions 2.28 and later.
441-
(Contributed by Jeffrey Bosboom in :gh:`83714`.)
441+
(Contributed by Jeffrey Bosboom and Victor Stinner in :gh:`83714`.)
442442

443443

444444
os.path

0 commit comments

Comments
 (0)