genfio: fix temporary file handling
authorVille Skyttä <ville.skytta@upcloud.com>
Tue, 2 Nov 2021 21:41:00 +0000 (23:41 +0200)
committerVille Skyttä <ville.skytta@upcloud.com>
Sun, 20 Feb 2022 18:23:44 +0000 (20:23 +0200)
As a side effect, the template temp file is no longer left behind, as
a unique filename is used for it on each run.

Use the same method of figuring out the temp dir as in
check_status_file().

Signed-off-by: Ville Skyttä <ville.skytta@upcloud.com>
tools/genfio

index 8518bbccf33a3111f097eb8221f14dbdb0f5b01b..fc7e6e46771f7dc683aaceab3bfbaae943682889 100755 (executable)
@@ -22,7 +22,8 @@
 BLK_SIZE=
 BLOCK_SIZE=4k
 SEQ=-1
-TEMPLATE=/tmp/template.fio
+TEMPLATE=$(mktemp "${TMPDIR:-${TEMP:-/tmp}}/template.fio.XXXXXX") || exit $?
+trap 'rm -f "$TEMPLATE"' EXIT
 OUTFILE=
 DISKS=
 PRINTABLE_DISKS=