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.

Title: Do not automount in stat() by default
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.8, Python 3.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: larry, pixelbeat, serhiy.storchaka, vstinner
Priority: normal Keywords: patch, patch, patch

Created on 2019-01-07 09:17 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11455 closed serhiy.storchaka, 2019-01-07 09:30
PR 11455 closed serhiy.storchaka, 2019-01-07 09:30
PR 11455 closed serhiy.storchaka, 2019-01-07 09:30
Messages (5)
msg333143 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-01-07 09:17
There is a subtle difference between implementations of os.stat() that use system calls stat() and fstatat(). On Linux, fstatat() by default automounts the terminal ("basename") component of pathname if it is a directory that is an automount point. The Linux-specific AT_NO_AUTOMOUNT flag should be set to prevent automounting. Both stat() and lstat() act as though AT_NO_AUTOMOUNT was set.

Therefore os.stat() should set AT_NO_AUTOMOUNT if it is defined to simulate the behavior of stat() and lstat(). New keyword parameter can be added to os.stat() in new Python release to control this behavior.

There is the same issue with DirEntry.stat().
msg333155 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-07 14:40
What if someone relies on the current behavior of os.stat(filename, dir_fd=fd)? Would it make sense to add a new "automount=False" optional parameter to os.stat()? AT_NO_AUTOMOUNT would only be added if automount is false.
msg333291 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-01-09 06:53
I was going to merge PR 11455 as a bug fix and backport it to 3.7, and add a new "automount=False" optional parameter in a separate issue.
msg414852 - (view) Author: Pádraig Brady (pixelbeat) Date: 2022-03-10 15:30
I think this change is not needed as fstatat() implies AT_NO_AUTOMOUNT since Linux 4.11
The fstatat(2) man page is confusing, and I've attempted to clarify with the patch attached to:
msg414894 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2022-03-11 08:38
Glad to see that this old inconsistency was fixed.

But seems that if we will add support for statx() we will need to set AT_NO_AUTOMOUNT by default.
Date User Action Args
2022-04-11 14:59:10adminsetgithub: 79858
2022-03-11 08:38:02serhiy.storchakasetstatus: open -> closed
messages: + msg414894

keywords: patch, patch, patch
resolution: out of date
stage: patch review -> resolved
2022-03-10 15:30:06pixelbeatsetnosy: + pixelbeat
messages: + msg414852
2019-01-09 06:53:06serhiy.storchakasetkeywords: patch, patch, patch

messages: + msg333291
2019-01-07 14:40:56vstinnersetkeywords: patch, patch, patch
nosy: + vstinner
messages: + msg333155

2019-01-07 09:30:45serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request10926
2019-01-07 09:30:40serhiy.storchakasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10925
2019-01-07 09:30:35serhiy.storchakasetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10924
2019-01-07 09:17:58serhiy.storchakacreate