summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-07-21 11:47:57 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-07-21 11:47:57 +0100
commit98430c35faa073c60d4c00542c090fe0407c5af7 (patch)
tree9f23e51d4cccf4820556f77d891e3825ff3f4029
parente315e0723ec8c2f84809f06d7f2ede4955dd6c67 (diff)
downloadlibguestfs-98430c35faa073c60d4c00542c090fe0407c5af7.tar.gz
libguestfs-98430c35faa073c60d4c00542c090fe0407c5af7.tar.xz
libguestfs-98430c35faa073c60d4c00542c090fe0407c5af7.zip
Allow TMPDIR to override directory used for temporary files (RHBZ#512905).
-rw-r--r--guestfish.pod10
-rw-r--r--guestfs.pod10
-rw-r--r--src/guestfs.c12
3 files changed, 31 insertions, 1 deletions
diff --git a/guestfish.pod b/guestfish.pod
index 32a30901..f2255f16 100644
--- a/guestfish.pod
+++ b/guestfish.pod
@@ -576,6 +576,16 @@ used.
The C<more> command uses C<$PAGER> as the pager. If not
set, it uses C<more>.
+=item TMPDIR
+
+Location of temporary directory, defaults to C</tmp>.
+
+If libguestfs was compiled to use the supermin appliance then each
+handle will require rather a large amount of space in this directory
+for short periods of time (~ 80 MB). You can use C<$TMPDIR> to
+configure another directory to use in case C</tmp> is not large
+enough.
+
=back
=head1 EXIT CODE
diff --git a/guestfs.pod b/guestfs.pod
index 2fd88cef..4235454e 100644
--- a/guestfs.pod
+++ b/guestfs.pod
@@ -937,6 +937,16 @@ used.
See also L<QEMU WRAPPERS> above.
+=item TMPDIR
+
+Location of temporary directory, defaults to C</tmp>.
+
+If libguestfs was compiled to use the supermin appliance then each
+handle will require rather a large amount of space in this directory
+for short periods of time (~ 80 MB). You can use C<$TMPDIR> to
+configure another directory to use in case C</tmp> is not large
+enough.
+
=back
=head1 SEE ALSO
diff --git a/src/guestfs.c b/src/guestfs.c
index f445adab..386dee6c 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -875,7 +875,8 @@ static const char *supermin_hostfiles_name =
int
guestfs_launch (guestfs_h *g)
{
- static const char *dir_template = "/tmp/libguestfsXXXXXX";
+ const char *tmpdir;
+ char dir_template[PATH_MAX];
int r, i, pmore;
size_t len;
int wfd[2], rfd[2];
@@ -885,6 +886,15 @@ guestfs_launch (guestfs_h *g)
char unixsock[256];
struct sockaddr_un addr;
+#ifdef P_tmpdir
+ tmpdir = P_tmpdir;
+#else
+ tmpdir = "/tmp";
+#endif
+
+ tmpdir = getenv ("TMPDIR") ? : tmpdir;
+ snprintf (dir_template, sizeof dir_template, "%s/libguestfsXXXXXX", tmpdir);
+
/* Configured? */
if (!g->cmdline) {
error (g, _("you must call guestfs_add_drive before guestfs_launch"));