X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fguestfs.c;h=9f7348665966f961698041380ab4b4bd05767ab1;hp=170d0d321c07df328df69ec52dee8eaa15457994;hb=690ff694ca6db586c06ec484ea158261c156aa2f;hpb=f1041e912b72116d66274d2f15e50ce34a9531fd diff --git a/src/guestfs.c b/src/guestfs.c index 170d0d3..9f73486 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -72,7 +72,6 @@ #include "guestfs_protocol.h" static void default_error_cb (guestfs_h *g, void *data, const char *msg); -static void remove_tmpdir (guestfs_h *g); static void close_handles (void); gl_lock_define_initialized (static, handles_lock); @@ -224,7 +223,8 @@ guestfs_close (guestfs_h *g) if (g->recoverypid > 0) waitpid (g->recoverypid, NULL, 0); /* Remove whole temporary directory. */ - remove_tmpdir (g); + guestfs___remove_tmpdir (g->tmpdir); + free (g->tmpdir); if (g->cmdline) { size_t i; @@ -260,43 +260,6 @@ guestfs_close (guestfs_h *g) free (g); } -/* g->tmpdir can contain any files (but not subdirectories). Remove - * those and the directory itself. Note that errors in this function - * aren't really that important: if we end up not deleting temporary - * files it's only annoying. - */ -static void -remove_tmpdir (guestfs_h *g) -{ - DIR *dir; - struct dirent *d; - - if (!g->tmpdir) - return; - - dir = opendir (g->tmpdir); - if (dir == NULL) { - perror (g->tmpdir); - return; - } - - while ((d = readdir (dir)) != NULL) { - if (STRNEQ (d->d_name, ".") && STRNEQ (d->d_name, "..")) { - if (unlinkat (dirfd (dir), d->d_name, 0) == -1) - perror (d->d_name); - } - } - - if (closedir (dir) == -1) - perror (g->tmpdir); - - if (rmdir (g->tmpdir) == -1) - perror (g->tmpdir); - - free (g->tmpdir); - g->tmpdir = NULL; -} - /* Close all open handles (called from atexit(3)). */ static void close_handles (void) @@ -373,6 +336,8 @@ guestfs___debug (guestfs_h *g, const char *fs, ...) if (len < 0) return; guestfs___call_callbacks_message (g, GUESTFS_EVENT_LIBRARY, msg, len); + + free (msg); } /* Call trace messages. These are enabled by setting g->trace, and @@ -1008,6 +973,7 @@ guestfs___free_drives (struct drive **drives) free (i->path); free (i->format); free (i->iface); + free (i->name); free (i); i = next;