This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [posixmodule] [Refactoring patch] Simply call into *at() functions unconditionally when present
Type: Stage:
Components: Extension Modules Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Alex.Willmer, EdSchouten, matrixise
Priority: normal Keywords: patch

Created on 2016-08-07 08:45 by EdSchouten, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
posixmodule-refactoring.diff EdSchouten, 2016-08-07 08:45 Patch for making posixmodule more CloudABI friendly review
patch-issue27701 EdSchouten, 2016-09-11 18:07 review
27701.diff EdSchouten, 2016-10-22 05:17 review
Messages (3)
msg272114 - (view) Author: Ed Schouten (EdSchouten) * Date: 2016-08-07 08:45
CloudABI is a sandboxed UNIX-like environment (https://mail.python.org/pipermail/python-dev/2016-July/145708.html). As it implements a security framework similar to FreeBSD's Capsicum, file system access is only permitted by using POSIX-2008-style directory file descriptors. To explain it simply, the API is as follows:

- Take POSIX 2008
- Remove all the non-*at() functions
- Remove AT_FDCWD

It would be nice if Python could support CloudABI out of the box, but in my opinion this should be done in a way that's as unintrusive as possible. We shouldn't make a mess out of Python, just to support CloudABI. I've been looking at Python's posixmodule and I think there's some low-hanging fruit. We can make changes that significantly reduce the size of our patchset for CloudABI, while also making the existing code easier to understand:

- When support for *at() functions was added, they didn't replace the calls to the non-*at() functions. The non-*at() functions are still invoked when dir_fd == AT_FDCWD. This can be changed to invoke the *at() functions unconditionally. The advantage of this approach is that AT_FDCWD then only needs to be used in dir_fd_converter() and a small number of other places. It also means that the code builds on systems that don't prove the non-*at() functions.

- The *_DIR_FD_CONVERTER macros aren't used in a small number of places, requiring us to do additional checks against AT_FDCWD in os_*_impl(). In os.link(), os.rename() and os.replace(), we call into dir_fd_converter() unconditionally, only to let the respective implementation functions perform additional checks. If dir_fd_unavailable() would be used instead, the implementations would be cleaner.

The attached patch does this refactoring, also making some minor cleanups along the way.
msg275822 - (view) Author: Ed Schouten (EdSchouten) * Date: 2016-09-11 18:07
Hmmm... Taking a second look at my patch: I still think it's conceptually a good idea to pursue this, but I think it may be wiser to first focus on the bits that are strictly necessary from my side. The patch that I've posted previously has the disadvantage that it's hard to grasp what belongs to gether.

Attached is a trimmed down version of my original patch that only focuses on patching up the os_*_impl()s to use the *at() functions exclusively if possible. Hopefully this change should be fairly easy to understand.

Any thoughts?
msg279180 - (view) Author: Ed Schouten (EdSchouten) * Date: 2016-10-22 05:17
Attached is an updated version of the patch that applies cleanly against Python 3.6.0b2.
History
Date User Action Args
2022-04-11 14:58:34adminsetgithub: 71888
2016-10-22 05:17:07EdSchoutensetfiles: + 27701.diff

messages: + msg279180
2016-09-11 18:07:39EdSchoutensetfiles: + patch-issue27701

messages: + msg275822
2016-08-09 04:11:20Alex.Willmersetnosy: + Alex.Willmer
2016-08-07 09:22:02matrixisesetnosy: + matrixise
2016-08-07 08:45:56EdSchoutencreate