[Libguestfs] [PATCH 3/2] lib: remove all temporary directories may remained last launching

Wanlong Gao wanlong.gao at gmail.com
Fri Dec 23 14:06:37 UTC 2011


If guestfish or other progs which launching appliance was aborted or
killed last time, the temp dir will be remained, so delete it when
this time launching.
Prevent the possible waste of disk space.

Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
---
 src/appliance.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/appliance.c b/src/appliance.c
index 57ff38f..4ce8405 100644
--- a/src/appliance.c
+++ b/src/appliance.c
@@ -36,6 +36,8 @@
 #include <sys/types.h>
 #endif
 
+#include "ignore-value.h"
+
 #include "guestfs.h"
 #include "guestfs-internal.h"
 #include "guestfs-internal-actions.h"
@@ -437,6 +439,14 @@ build_supermin_appliance (guestfs_h *g,
    */
   size_t len = strlen (tmpdir) + 128;
 
+  /* If guestfish or other progs which launching appliance was aborted or
+   * killed last time, the temp dir will be remained, so delete it when
+   * this time launching.
+   */
+  char cmd[len];
+  snprintf (cmd, len, "rm -rf %s/guestfs.??????", tmpdir);
+  ignore_value (system (cmd));
+
   /* Build the appliance into a temporary directory. */
   char tmpcd[len];
   snprintf (tmpcd, len, "%s/guestfs.XXXXXX", tmpdir);
-- 
1.7.8




More information about the Libguestfs mailing list