From 85237c0b682b27d6a250dc629c89d3d95f1e37b4 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 15 Oct 2021 11:25:09 +0200 Subject: [PATCH] tempfile: add some comment Signed-off-by: Thomas Lamprecht --- src/PVE/Tools.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 2038abf..5586910 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -1581,6 +1581,13 @@ sub sendmail { close($mail); } +# creates a temporary file that does not shows up on the file system hierarchy. +# +# Uses O_TMPFILE if available, which makes it just an anon inode that never shows up in the FS. +# If O_TMPFILE is not available, which unlikely nowadays (added in 3.11 kernel and all FS relevant +# for us support it) back to open-create + immediate unlink while still holding the file handle. +# +# TODO: to avoid FS dependent features we could (transparently) switch to memfd_create as backend sub tempfile { my ($perm, %opts) = @_; @@ -1611,6 +1618,7 @@ sub tempfile { return $fh; } +# create an (ideally) anon file with the $data as content and return its FD-path and FH sub tempfile_contents { my ($data, $perm, %opts) = @_; -- 2.39.5