summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fish/guestfish.pod5
-rw-r--r--src/appliance.c4
-rw-r--r--src/guestfs-internal.h1
-rw-r--r--src/guestfs.pod5
-rw-r--r--src/launch.c18
5 files changed, 27 insertions, 6 deletions
diff --git a/fish/guestfish.pod b/fish/guestfish.pod
index 5ec6689e..0f318f04 100644
--- a/fish/guestfish.pod
+++ b/fish/guestfish.pod
@@ -1052,12 +1052,13 @@ set, it uses C<more>.
=item TMPDIR
-Location of temporary directory, defaults to C</tmp>.
+Location of temporary directory, defaults to C</tmp> except for the
+cached supermin appliance which defaults to C</var/tmp>.
If libguestfs was compiled to use the supermin appliance then the
real appliance is cached in this directory, shared between all
handles belonging to the same EUID. You can use C<$TMPDIR> to
-configure another directory to use in case C</tmp> is not large
+configure another directory to use in case C</var/tmp> is not large
enough.
=back
diff --git a/src/appliance.c b/src/appliance.c
index 1b6b505e..ef724be5 100644
--- a/src/appliance.c
+++ b/src/appliance.c
@@ -308,7 +308,7 @@ check_for_cached_appliance (guestfs_h *g,
uid_t uid,
char **kernel, char **initrd, char **appliance)
{
- const char *tmpdir = guestfs_tmpdir ();
+ const char *tmpdir = guestfs___persistent_tmpdir ();
/* len must be longer than the length of any pathname we can
* generate in this function.
@@ -419,7 +419,7 @@ build_supermin_appliance (guestfs_h *g,
if (g->verbose)
guestfs___print_timestamped_message (g, "begin building supermin appliance");
- const char *tmpdir = guestfs_tmpdir ();
+ const char *tmpdir = guestfs___persistent_tmpdir ();
/* len must be longer than the length of any pathname we can
* generate in this function.
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 08b459bc..194c8928 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -257,6 +257,7 @@ extern char *guestfs_safe_strndup (guestfs_h *g, const char *str, size_t n);
extern void *guestfs_safe_memdup (guestfs_h *g, void *ptr, size_t size);
extern char *guestfs_safe_asprintf (guestfs_h *g, const char *fs, ...)
__attribute__((format (printf,2,3)));
+extern const char *guestfs___persistent_tmpdir (void);
extern void guestfs___print_timestamped_argv (guestfs_h *g, const char *argv[]);
extern void guestfs___print_timestamped_message (guestfs_h *g, const char *fs, ...);
extern void guestfs___free_inspect_info (guestfs_h *g);
diff --git a/src/guestfs.pod b/src/guestfs.pod
index ab4e768d..b8b8ca22 100644
--- a/src/guestfs.pod
+++ b/src/guestfs.pod
@@ -2501,12 +2501,13 @@ has the same effect as calling C<guestfs_set_trace (g, 1)>.
=item TMPDIR
-Location of temporary directory, defaults to C</tmp>.
+Location of temporary directory, defaults to C</tmp> except for the
+cached supermin appliance which defaults to C</var/tmp>.
If libguestfs was compiled to use the supermin appliance then the
real appliance is cached in this directory, shared between all
handles belonging to the same EUID. You can use C<$TMPDIR> to
-configure another directory to use in case C</tmp> is not large
+configure another directory to use in case C</var/tmp> is not large
enough.
=back
diff --git a/src/launch.c b/src/launch.c
index e009aae1..a7a86b97 100644
--- a/src/launch.c
+++ b/src/launch.c
@@ -770,6 +770,7 @@ guestfs__launch (guestfs_h *g)
/* Return the location of the tmpdir (eg. "/tmp") and allow users
* to override it at runtime using $TMPDIR.
+ * http://www.pathname.com/fhs/pub/fhs-2.3.html#TMPTEMPORARYFILES
*/
const char *
guestfs_tmpdir (void)
@@ -788,6 +789,23 @@ guestfs_tmpdir (void)
return tmpdir;
}
+/* Return the location of the persistent tmpdir (eg. "/var/tmp") and
+ * allow users to override it at runtime using $TMPDIR.
+ * http://www.pathname.com/fhs/pub/fhs-2.3.html#VARTMPTEMPORARYFILESPRESERVEDBETWEE
+ */
+const char *
+guestfs___persistent_tmpdir (void)
+{
+ const char *tmpdir;
+
+ tmpdir = "/var/tmp";
+
+ const char *t = getenv ("TMPDIR");
+ if (t) tmpdir = t;
+
+ return tmpdir;
+}
+
/* Compute Y - X and return the result in milliseconds.
* Approximately the same as this code:
* http://www.mpp.mpg.de/~huber/util/timevaldiff.c