From 0badc1ee0e6ab8622b2f9b4ebc3c5ab96f0b58d0 Mon Sep 17 00:00:00 2001 From: aurel32 Date: Mon, 10 Mar 2008 00:05:34 +0000 Subject: [PATCH] Honor TMPDIR environment variable git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4033 c046a42c-6fe2-441c-8c8c-71466251a162 --- block.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 0f8ad7bce2..07309541f3 100644 --- a/block.c +++ b/block.c @@ -191,8 +191,12 @@ void get_tmp_filename(char *filename, int size) void get_tmp_filename(char *filename, int size) { int fd; + char *tmpdir; /* XXX: race condition possible */ - pstrcpy(filename, size, "/tmp/vl.XXXXXX"); + tmpdir = getenv("TMPDIR"); + if (!tmpdir) + tmpdir = "/tmp"; + snprintf(filename, size, "%s/vl.XXXXXX", tmpdir); fd = mkstemp(filename); close(fd); }