Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,15 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
.. versionadded:: 3.15


.. data:: RWF_ATOMIC

Write data atomically. Requires alignment to the device's atomic write unit.

.. availability:: Linux >= 6.11

.. versionadded:: next


.. function:: ptsname(fd, /)

Return the name of the slave pseudo-terminal device associated with the
Expand Down Expand Up @@ -1598,6 +1607,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
- :data:`RWF_SYNC`
- :data:`RWF_APPEND`
- :data:`RWF_DONTCACHE`
- :data:`RWF_ATOMIC`

Return the total number of bytes actually written.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add :data:`os.RWF_ATOMIC` constant for Linux 6.11+.
3 changes: 2 additions & 1 deletion Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -12863,14 +12863,15 @@ The flags argument contains a bitwise OR of zero or more of the following flags:
- RWF_SYNC
- RWF_APPEND
- RWF_DONTCACHE
- RWF_ATOMIC
Copy link

Choose a reason for hiding this comment

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

(i work with clay and he has been keeping me updated on the discussion thx all)

May I suggest we follow the order from
https://github.com/torvalds/linux/blob/7f98ab9da046865d57c102fd3ca9669a29845f67/include/uapi/linux/fs.h#L429

these low level flags are pretty tricky to get right, and to validate, keeping the order the "same" helps triple check things.

Excited that this is getting a revival!

Copy link
Member

Choose a reason for hiding this comment

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

We can consider that for a follow-up PR. I think it's important to keep the blame intact here, so when Linux goes and adds new flags, we can quickly look up the precedent for adding them.


Using non-zero flags requires Linux 4.7 or newer.
[clinic start generated code]*/

static Py_ssize_t
os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset,
int flags)
/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=664a67626d485665]*/
/*[clinic end generated code: output=e3dd3e9d11a6a5c7 input=7de72245873f56bf]*/
{
Py_ssize_t cnt;
Py_ssize_t result;
Expand Down Expand Up @@ -18120,6 +18121,9 @@ all_ins(PyObject *m)
#ifdef RWF_DONTCACHE
if (PyModule_AddIntConstant(m, "RWF_DONTCACHE", RWF_DONTCACHE)) return -1;
#endif
#ifdef RWF_ATOMIC
if (PyModule_AddIntConstant(m, "RWF_ATOMIC", RWF_ATOMIC)) return -1;
#endif
#ifdef RWF_APPEND
if (PyModule_AddIntConstant(m, "RWF_APPEND", RWF_APPEND)) return -1;
#endif
Expand Down
Loading