Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Use Linux' O_TMPFILE for tmpfiles #2

Open
untitaker opened this issue Jan 28, 2015 · 6 comments
Open

Use Linux' O_TMPFILE for tmpfiles #2

untitaker opened this issue Jan 28, 2015 · 6 comments

Comments

@untitaker
Copy link
Owner

untitaker/rust-atomicwrites#2

@untitaker untitaker changed the title Use Linux' API for tmpfiles Use Linux' O_TMPFILE for tmpfiles Feb 6, 2015
@untitaker
Copy link
Owner Author

Unsure how to call linkat in Python.

@AndCycle
Copy link

@jwilk
Copy link
Contributor

jwilk commented Jul 15, 2016

Something like this seems to work since Python 3.4:

import os
fd = os.open('.', os.O_TMPFILE | os.O_RDWR)
path = '/proc/self/fd/{0}'.format(fd)
os.link(path, 'spam', src_dir_fd=0, follow_symlinks=True)

@untitaker
Copy link
Owner Author

@jwilk That doesn't seem particularly performant or elegant though. It seems that there is a package on PyPI that provides bindings for this call, however, that would be quite a microdependency.

@earonesty
Copy link

earonesty commented Dec 6, 2017

AFAICT NamedTemporaryFile already sets this flag

@jwilk
Copy link
Contributor

jwilk commented Dec 6, 2017

I think you meant (unnamed) TemporaryFile, which indeed tries to use O_TMPFILE since Python 3.5:
https://bugs.python.org/issue21515

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants