Don't use O_EXCL when using O_TMPFILE
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
Proposal:
I was working on a tool on Linux where I'm updating yaml files on disk. I need to replace the file when the data changes. I was looking into using a tempfile created with O_TMPFILE, writing the content, and then replacing the original file using linkat. This would provide a simple atomic replacement of the file without needing to do a lot of file handshaking, etc.
However, at the moment tempfile.TemporaryFile passes the O_EXCL flag to io.open, this prevents the file descriptor from being used in a linkat call.
The TemporaryFile code already removes the O_CREAT flags from the standard open flags when using O_TMPFILE.
Would it be okay to remove O_EXCL from the open flags as well?
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
- gh-136281
- gh-136430
- gh-136534
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Python 的 tempfile.TemporaryFile 实现入手,检查使用 O_TMPFILE 时它如何将 flags 传递给 io.open。确认仅在此路径下省略 O_EXCL,然后验证生成的描述符可以与 linkat 一起使用,同时不改变 TemporaryFile 的其他行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- linux, python
- 领域
- operating-systems
- Issue 类型
- 功能
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100