12 releases

0.3.4 Aug 29, 2021
0.3.3 Dec 9, 2019
0.3.2 Oct 7, 2019
0.3.0 Feb 17, 2019
0.1.1 Aug 1, 2017

#579 in Filesystem

Download history 13566/week @ 2024-06-16 15540/week @ 2024-06-23 12641/week @ 2024-06-30 7187/week @ 2024-07-07 6734/week @ 2024-07-14 7684/week @ 2024-07-21 6420/week @ 2024-07-28 5580/week @ 2024-08-04 5778/week @ 2024-08-11 7112/week @ 2024-08-18 2629/week @ 2024-08-25 1011/week @ 2024-09-01 606/week @ 2024-09-08 602/week @ 2024-09-15 696/week @ 2024-09-22 898/week @ 2024-09-29

2,836 downloads per month
Used in 15 crates (6 directly)

MIT license

21KB
338 lines

(Slightly) faster temporary files on Linux

Build status Build status

On "recent" Linux (~2014+), filesystems support a new type of unnamed, persistable temporary file.

The excellent tempfile crate supports two types of temporary files:

  • unnamed temporary files, which are secure and fast, but which can never be written into real the filesystem.
  • named temporary files, which have some theoretical security risks and performance problems, but you must use if you ever want to write the data into the real filesystem efficiently.

It does not, however, expose unnamed (secure, fast), persistable (convenient) files. This crate does.

On non-modern-Linux, this crate falls back to using tempfile's NamedTemporaryFile directly.

"recent" Linux

Support for O_TMPFILE was added to:

  • Linux 3.11: ext2, ext3, ext4, UDF, Minix, shmem.
  • Linux 3.15: xfs
  • Linux 3.16: btrfs, f2fs
  • Linux 4.9: ubifs

Some distros, with release dates, End of Life dates, and kernel versions:

  • Ubuntu 12.04 (Apr 2012 - Apr 2017): 3.2
  • Debian Wheezy (May 2013 - May 2018): 3.2
  • Ubuntu 14.04.0 (Apr 2014 - Apr 2019): 3.13
  • RHEL 7 (Jun 2014 - Jun 2024): 3.10
  • Debian Jessie (Apr 2015 - Apr 2020): 3.16
  • OpenSUSE Leap 42.1 (Nov 2015 - May 2017): 4.1
  • Ubuntu 14.04.5 (Aug 2016 - Apr 2019): 4.4
  • Debian Stretch (Jun 2017 - ): 4.9

i.e. as of 2017, the latest version, and even the previous version, of everything except CentOS/RHEL looks pretty promising.

Upstreaming

An alternative implementation, ramming this into NamedTemporaryFile, was discussed in a pull-request. This was the result.

Dependencies

~2–10MB
~118K SLoC