@@ -3383,6 +3383,214 @@ features:
33833383 Added the :attr: `st_birthtime ` member on Windows.
33843384
33853385
3386+ .. function :: statx(path, mask, *, flags=0, dir_fd=None, follow_symlinks=True)
3387+
3388+ Get the status of a file or file descriptor by performing a :c:func: `!statx `
3389+ system call on the given path.
3390+
3391+ *path * is a :term: `path-like object ` or an open file descriptor. *mask * is a
3392+ combination of the module-level :const: `STATX_* <STATX_TYPE> ` constants
3393+ specifying the information to retrieve. *flags * is a combination of the
3394+ module-level :const: `AT_STATX_* <AT_STATX_FORCE_SYNC> ` constants and/or
3395+ :const: `AT_NO_AUTOMOUNT `. Returns a :class: `statx_result ` object whose
3396+ :attr: `~os.statx_result.stx_mask ` attribute specifies the information
3397+ actually retrieved (which may differ from *mask *).
3398+
3399+ This function supports :ref: `specifying a file descriptor <path_fd >`,
3400+ :ref: `paths relative to directory descriptors <dir_fd >`, and
3401+ :ref: `not following symlinks <follow_symlinks >`.
3402+
3403+ .. seealso :: The :manpage:`statx(2)` man page.
3404+
3405+ .. availability :: Linux >= 4.11 with glibc >= 2.28.
3406+
3407+ .. versionadded :: next
3408+
3409+
3410+ .. class :: statx_result
3411+
3412+ Information about a file returned by :func: `os.statx `.
3413+
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:
3420+
3421+ .. attribute :: stx_mask
3422+
3423+ Bitmask of :const: `STATX_* <STATX_TYPE> ` constants specifying the
3424+ information retrieved, which may differ from what was requested.
3425+
3426+ .. attribute :: stx_attributes_mask
3427+
3428+ Bitmask of :const: `STATX_ATTR_* <stat.STATX_ATTR_COMPRESSED> ` constants
3429+ specifying the attributes bits supported for this file.
3430+
3431+ .. attribute :: stx_attributes
3432+
3433+ Bitmask of :const: `STATX_ATTR_* <stat.STATX_ATTR_COMPRESSED> ` constants
3434+ specifying the attributes of this file.
3435+
3436+ .. attribute :: stx_dev_major
3437+
3438+ Major number of the device on which this file resides.
3439+
3440+ .. attribute :: stx_dev_minor
3441+
3442+ Minor number of the device on which this file resides.
3443+
3444+ .. attribute :: stx_rdev_major
3445+
3446+ Major number of the device this file represents.
3447+
3448+ .. attribute :: stx_rdev_minor
3449+
3450+ Minor number of the device this file represents.
3451+
3452+ .. attribute :: stx_mnt_id
3453+
3454+ Mount ID.
3455+
3456+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3457+ userspace API headers >= 5.8.
3458+
3459+ .. attribute :: stx_dio_mem_align
3460+
3461+ Direct I/O memory buffer alignment requirement.
3462+
3463+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3464+ userspace API headers >= 6.1.
3465+
3466+ .. attribute :: stx_dio_offset_align
3467+
3468+ Direct I/O file offset alignment requirement.
3469+
3470+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3471+ userspace API headers >= 6.1.
3472+
3473+ .. attribute :: stx_subvol
3474+
3475+ Subvolume ID.
3476+
3477+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3478+ userspace API headers >= 6.10.
3479+
3480+ .. attribute :: stx_atomic_write_unit_min
3481+
3482+ Minimum size for direct I/O with torn-write protection.
3483+
3484+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3485+ userspace API headers >= 6.11.
3486+
3487+ .. attribute :: stx_atomic_write_unit_max
3488+
3489+ Maximum size for direct I/O with torn-write protection.
3490+
3491+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3492+ userspace API headers >= 6.11.
3493+
3494+ .. attribute :: stx_atomic_write_unit_max_opt
3495+
3496+ Maximum optimized size for direct I/O with torn-write protection.
3497+
3498+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3499+ userspace API headers >= 6.11.
3500+
3501+ .. attribute :: stx_atomic_write_segments_max
3502+
3503+ Maximum iovecs for direct I/O with torn-write protection.
3504+
3505+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3506+ userspace API headers >= 6.11.
3507+
3508+ .. attribute :: stx_dio_read_offset_align
3509+
3510+ Direct I/O file offset alignment requirement for reads.
3511+
3512+ .. availability :: Linux >= 4.11 with glibc >= 2.28 and build-time kernel
3513+ userspace API headers >= 6.14.
3514+
3515+ .. seealso :: The :manpage:`statx(2)` man page.
3516+
3517+ .. availability :: Linux >= 4.11 with glibc >= 2.28.
3518+
3519+ .. versionadded :: next
3520+
3521+
3522+ .. data :: STATX_TYPE
3523+ STATX_MODE
3524+ STATX_NLINK
3525+ STATX_UID
3526+ STATX_GID
3527+ STATX_ATIME
3528+ STATX_MTIME
3529+ STATX_CTIME
3530+ STATX_INO
3531+ STATX_SIZE
3532+ STATX_BLOCKS
3533+ STATX_BASIC_STATS
3534+ STATX_BTIME
3535+ STATX_MNT_ID
3536+ STATX_DIOALIGN
3537+ STATX_MNT_ID_UNIQUE
3538+ STATX_SUBVOL
3539+ STATX_WRITE_ATOMIC
3540+ STATX_DIO_READ_ALIGN
3541+
3542+ Bitflags for use in the *mask * parameter to :func: `os.statx `. Flags
3543+ including and after :const: `!STATX_MNT_ID ` are only available when their
3544+ corresponding members in :class: `statx_result ` are available.
3545+
3546+ .. availability :: Linux >= 4.11 with glibc >= 2.28.
3547+
3548+ .. versionadded :: next
3549+
3550+ .. data :: AT_STATX_FORCE_SYNC
3551+
3552+ A flag for the :func: `os.statx ` function. Requests that the kernel return
3553+ up-to-date information even when doing so is expensive (for example,
3554+ requiring a round trip to the server for a file on a network filesystem).
3555+
3556+ .. availability :: Linux >= 4.11 with glibc >= 2.28.
3557+
3558+ .. versionadded :: next
3559+
3560+ .. data :: AT_STATX_DONT_SYNC
3561+
3562+ A flag for the :func: `os.statx ` function. Requests that the kernel return
3563+ cached information if possible.
3564+
3565+ .. availability :: Linux >= 4.11 with glibc >= 2.28.
3566+
3567+ .. versionadded :: next
3568+
3569+ .. data :: AT_STATX_SYNC_AS_STAT
3570+
3571+ A flag for the :func: `os.statx ` function. This flag is defined as ``0 ``, so
3572+ it has no effect, but it can be used to explicitly indicate neither
3573+ :data: `AT_STATX_FORCE_SYNC ` nor :data: `AT_STATX_DONT_SYNC ` is being passed.
3574+ In the absence of the other two flags, the kernel will generally return
3575+ information as fresh as :func: `os.stat ` would return.
3576+
3577+ .. availability :: Linux >= 4.11 with glibc >= 2.28.
3578+
3579+ .. versionadded :: next
3580+
3581+
3582+ .. data :: AT_NO_AUTOMOUNT
3583+
3584+ If the final component of a path is an automount point, operate on the
3585+ automount point instead of performing the automount. On Linux,
3586+ :func: `os.stat `, :func: `os.fstat ` and :func: `os.lstat ` always behave this
3587+ way.
3588+
3589+ .. availability :: Linux.
3590+
3591+ .. versionadded :: next
3592+
3593+
33863594.. function :: statvfs(path)
33873595
33883596 Perform a :c:func: `!statvfs ` system call on the given path. The return value is
0 commit comments