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

#471 in Filesystem

Download history 7564/week @ 2024-07-20 6581/week @ 2024-07-27 5524/week @ 2024-08-03 5674/week @ 2024-08-10 7187/week @ 2024-08-17 2703/week @ 2024-08-24 1030/week @ 2024-08-31 594/week @ 2024-09-07 629/week @ 2024-09-14 695/week @ 2024-09-21 871/week @ 2024-09-28 769/week @ 2024-10-05 916/week @ 2024-10-12 635/week @ 2024-10-19 711/week @ 2024-10-26 564/week @ 2024-11-02

2,930 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

~1.8–10MB
~117K SLoC