On Fri, Dec 23, 2011 at 10:06:37PM +0800, Wanlong Gao wrote:
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@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);
This isn't safe. It'll remove unrelated guestfs.?????? directories that might be in use by other processes. Almost every Linux system out there has a /tmp cleaner process which will clean up anything that the current system doesn't catch. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top