| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,33 +31,54 @@ descriptor. | |||
| 31 | 31 | raise an :exc:`OSError`. | |
| 32 | 32 | ||
| 33 | 33 | .. versionchanged:: 3.8 | |
| 34 | - The fcntl module now contains ``F_ADD_SEALS``, ``F_GET_SEALS``, and | ||
| 34 | + The :mod:`!fcntl` module now contains ``F_ADD_SEALS``, ``F_GET_SEALS``, and | ||
| 35 | 35 | ``F_SEAL_*`` constants for sealing of :func:`os.memfd_create` file | |
| 36 | 36 | descriptors. | |
| 37 | 37 | ||
| 38 | 38 | .. versionchanged:: 3.9 | |
| 39 | - On macOS, the fcntl module exposes the ``F_GETPATH`` constant, which obtains | ||
| 40 | - the path of a file from a file descriptor. | ||
| 41 | - On Linux(>=3.15), the fcntl module exposes the ``F_OFD_GETLK``, ``F_OFD_SETLK`` | ||
| 42 | - and ``F_OFD_SETLKW`` constants, which are used when working with open file | ||
| 43 | - description locks. | ||
| 39 | + On macOS, the :mod:`!fcntl` module exposes the ``F_GETPATH`` constant, | ||
| 40 | + which obtains the path of a file from a file descriptor. | ||
| 41 | + On Linux(>=3.15), the :mod:`!fcntl` module exposes the ``F_OFD_GETLK``, | ||
| 42 | + ``F_OFD_SETLK`` and ``F_OFD_SETLKW`` constants, which are used when working | ||
| 43 | + with open file description locks. | ||
| 44 | 44 | ||
| 45 | 45 | .. versionchanged:: 3.10 | |
| 46 | - On Linux >= 2.6.11, the fcntl module exposes the ``F_GETPIPE_SZ`` and | ||
| 46 | + On Linux >= 2.6.11, the :mod:`!fcntl` module exposes the ``F_GETPIPE_SZ`` and | ||
| 47 | 47 | ``F_SETPIPE_SZ`` constants, which allow to check and modify a pipe's size | |
| 48 | 48 | respectively. | |
| 49 | 49 | ||
| 50 | 50 | .. versionchanged:: 3.11 | |
| 51 | - On FreeBSD, the fcntl module exposes the ``F_DUP2FD`` and ``F_DUP2FD_CLOEXEC`` | ||
| 52 | - constants, which allow to duplicate a file descriptor, the latter setting | ||
| 53 | - ``FD_CLOEXEC`` flag in addition. | ||
| 51 | + On FreeBSD, the :mod:`!fcntl` module exposes the ``F_DUP2FD`` and | ||
| 52 | + ``F_DUP2FD_CLOEXEC`` constants, which allow to duplicate a file descriptor, | ||
| 53 | + the latter setting ``FD_CLOEXEC`` flag in addition. | ||
| 54 | 54 | ||
| 55 | 55 | .. versionchanged:: 3.12 | |
| 56 | 56 | On Linux >= 4.5, the :mod:`fcntl` module exposes the ``FICLONE`` and | |
| 57 | 57 | ``FICLONERANGE`` constants, which allow to share some data of one file with | |
| 58 | 58 | another file by reflinking on some filesystems (e.g., btrfs, OCFS2, and | |
| 59 | 59 | XFS). This behavior is commonly referred to as "copy-on-write". | |
| 60 | 60 | ||
| 61 | + .. versionchanged:: 3.13 | ||
| 62 | + On Linux >= 2.6.32, the :mod:`!fcntl` module exposes the | ||
| 63 | + ``F_GETOWN_EX``, ``F_SETOWN_EX``, ``F_OWNER_TID``, ``F_OWNER_PID``, ``F_OWNER_PGRP`` constants, which allow to direct I/O availability signals | ||
| 64 | + to a specific thread, process, or process group. | ||
| 65 | + On Linux >= 4.13, the :mod:`!fcntl` module exposes the | ||
| 66 | + ``F_GET_RW_HINT``, ``F_SET_RW_HINT``, ``F_GET_FILE_RW_HINT``, | ||
| 67 | + ``F_SET_FILE_RW_HINT``, and ``RWH_WRITE_LIFE_*`` constants, which allow | ||
| 68 | + to inform the kernel about the relative expected lifetime of writes on | ||
| 69 | + a given inode or via a particular open file description. | ||
| 70 | + On Linux >= 5.1 and NetBSD, the :mod:`!fcntl` module exposes the | ||
| 71 | + ``F_SEAL_FUTURE_WRITE`` constant for use with ``F_ADD_SEALS`` and | ||
| 72 | + ``F_GET_SEALS`` operations. | ||
| 73 | + On FreeBSD, the :mod:`!fcntl` module exposes the ``F_READAHEAD``, ``F_ISUNIONSTACK``, and ``F_KINFO`` constants. | ||
| 74 | + On macOS and FreeBSD, the :mod:`!fcntl` module exposes the ``F_RDAHEAD`` | ||
| 75 | + constant. | ||
| 76 | + On NetBSD and AIX, the :mod:`!fcntl` module exposes the ``F_CLOSEM`` | ||
| 77 | + constant. | ||
| 78 | + On NetBSD, the :mod:`!fcntl` module exposes the ``F_MAXFD`` constant. | ||
| 79 | + On macOS and NetBSD, the :mod:`!fcntl` module exposes the ``F_GETNOSIGPIPE`` | ||
| 80 | + and ``F_SETNOSIGPIPE`` constant. | ||
| 81 | + | ||
| 61 | 82 | The module defines the following functions: | |
| 62 | 83 | ||
| 63 | 84 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Expose more platform specific constants in the :mod:`fcntl` module on Linux, | ||
| 2 | + macOS, FreeBSD and NetBSD. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -583,6 +583,30 @@ all_ins(PyObject* m) | |||
| 583 | 583 | #ifdef FICLONERANGE | |
| 584 | 584 | if (PyModule_AddIntMacro(m, FICLONERANGE)) return -1; | |
| 585 | 585 | #endif | |
| 586 | + #ifdef F_GETOWN_EX | ||
| 587 | + // since Linux 2.6.32 | ||
| 588 | + if (PyModule_AddIntMacro(m, F_GETOWN_EX)) return -1; | ||
| 589 | + if (PyModule_AddIntMacro(m, F_SETOWN_EX)) return -1; | ||
| 590 | + if (PyModule_AddIntMacro(m, F_OWNER_TID)) return -1; | ||
| 591 | + if (PyModule_AddIntMacro(m, F_OWNER_PID)) return -1; | ||
| 592 | + if (PyModule_AddIntMacro(m, F_OWNER_PGRP)) return -1; | ||
| 593 | + #endif | ||
| 594 | + #ifdef F_GET_RW_HINT | ||
| 595 | + // since Linux 4.13 | ||
| 596 | + if (PyModule_AddIntMacro(m, F_GET_RW_HINT)) return -1; | ||
| 597 | + if (PyModule_AddIntMacro(m, F_SET_RW_HINT)) return -1; | ||
| 598 | + if (PyModule_AddIntMacro(m, F_GET_FILE_RW_HINT)) return -1; | ||
| 599 | + if (PyModule_AddIntMacro(m, F_SET_FILE_RW_HINT)) return -1; | ||
| 600 | + #ifndef RWH_WRITE_LIFE_NOT_SET // typo in Linux < 5.5 | ||
| 601 | + # define RWH_WRITE_LIFE_NOT_SET RWF_WRITE_LIFE_NOT_SET | ||
| 602 | + #endif | ||
| 603 | + if (PyModule_AddIntMacro(m, RWH_WRITE_LIFE_NOT_SET)) return -1; | ||
| 604 | + if (PyModule_AddIntMacro(m, RWH_WRITE_LIFE_NONE)) return -1; | ||
| 605 | + if (PyModule_AddIntMacro(m, RWH_WRITE_LIFE_SHORT)) return -1; | ||
| 606 | + if (PyModule_AddIntMacro(m, RWH_WRITE_LIFE_MEDIUM)) return -1; | ||
| 607 | + if (PyModule_AddIntMacro(m, RWH_WRITE_LIFE_LONG)) return -1; | ||
| 608 | + if (PyModule_AddIntMacro(m, RWH_WRITE_LIFE_EXTREME)) return -1; | ||
| 609 | + #endif | ||
| 586 | 610 | ||
| 587 | 611 | /* OS X specifics */ | |
| 588 | 612 | #ifdef F_FULLFSYNC | |
@@ -599,6 +623,32 @@ all_ins(PyObject* m) | |||
| 599 | 623 | #ifdef F_DUP2FD_CLOEXEC | |
| 600 | 624 | if (PyModule_AddIntMacro(m, F_DUP2FD_CLOEXEC)) return -1; | |
| 601 | 625 | #endif | |
| 626 | + #ifdef F_READAHEAD | ||
| 627 | + if (PyModule_AddIntMacro(m, F_READAHEAD)) return -1; | ||
| 628 | + #endif | ||
| 629 | + #ifdef F_RDAHEAD | ||
| 630 | + if (PyModule_AddIntMacro(m, F_RDAHEAD)) return -1; | ||
| 631 | + #endif | ||
| 632 | + #ifdef F_ISUNIONSTACK | ||
| 633 | + if (PyModule_AddIntMacro(m, F_ISUNIONSTACK)) return -1; | ||
| 634 | + #endif | ||
| 635 | + #ifdef F_KINFO | ||
| 636 | + if (PyModule_AddIntMacro(m, F_KINFO)) return -1; | ||
| 637 | + #endif | ||
| 638 | + | ||
| 639 | + /* NetBSD specifics */ | ||
| 640 | + #ifdef F_CLOSEM | ||
| 641 | + if (PyModule_AddIntMacro(m, F_CLOSEM)) return -1; | ||
| 642 | + #endif | ||
| 643 | + #ifdef F_MAXFD | ||
| 644 | + if (PyModule_AddIntMacro(m, F_MAXFD)) return -1; | ||
| 645 | + #endif | ||
| 646 | + #ifdef F_GETNOSIGPIPE | ||
| 647 | + if (PyModule_AddIntMacro(m, F_GETNOSIGPIPE)) return -1; | ||
| 648 | + #endif | ||
| 649 | + #ifdef F_SETNOSIGPIPE | ||
| 650 | + if (PyModule_AddIntMacro(m, F_SETNOSIGPIPE)) return -1; | ||
| 651 | + #endif | ||
| 602 | 652 | ||
| 603 | 653 | /* For F_{GET|SET}FL */ | |
| 604 | 654 | #ifdef FD_CLOEXEC | |
@@ -673,6 +723,9 @@ all_ins(PyObject* m) | |||
| 673 | 723 | if (PyModule_AddIntMacro(m, F_SEAL_SHRINK)) return -1; | |
| 674 | 724 | if (PyModule_AddIntMacro(m, F_SEAL_GROW)) return -1; | |
| 675 | 725 | if (PyModule_AddIntMacro(m, F_SEAL_WRITE)) return -1; | |
| 726 | + #ifdef F_SEAL_FUTURE_WRITE | ||
| 727 | + if (PyModule_AddIntMacro(m, F_SEAL_FUTURE_WRITE)) return -1; | ||
| 728 | + #endif | ||
| 676 | 729 | #endif | |
| 677 | 730 | return 0; | |
| 678 | 731 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments