X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fguestfs.c;h=002418a446def731761205c423053fdf98ba2474;hp=7868e8f060e52ee474cbcbed3f8b5a0d6396814b;hb=60d5a50f4d3d9e2c2f5a7d42a6859de709bda3f6;hpb=b2f8627ab59daeb03f036dde6c66fb9da736950c diff --git a/src/guestfs.c b/src/guestfs.c index 7868e8f..002418a 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -169,15 +169,19 @@ guestfs_create (void) void guestfs_close (guestfs_h *g) { - int i; - guestfs_h *gg; - if (g->state == NO_HANDLE) { /* Not safe to call ANY callbacks here, so ... */ fprintf (stderr, _("guestfs_close: called twice on the same handle\n")); return; } + if (g->trace) { + const char trace_msg[] = "close"; + + guestfs___call_callbacks_message (g, GUESTFS_EVENT_TRACE, + trace_msg, strlen (trace_msg)); + } + debug (g, "closing guestfs handle %p (state %d)", g, g->state); /* Try to sync if autosync flag is set. */ @@ -219,6 +223,8 @@ guestfs_close (guestfs_h *g) remove_tmpdir (g); if (g->cmdline) { + size_t i; + for (i = 0; i < g->cmdline_size; ++i) free (g->cmdline[i]); free (g->cmdline); @@ -231,6 +237,8 @@ guestfs_close (guestfs_h *g) if (handles == g) handles = g->next; else { + guestfs_h *gg; + for (gg = handles; gg->next != g; gg = gg->next) ; gg->next = g->next; @@ -425,14 +433,8 @@ guestfs_perrorf (guestfs_h *g, const char *fs, ...) if (err < 0) return; -#if !defined(_GNU_SOURCE) || defined(__APPLE__) char buf[256]; strerror_r (errnum, buf, sizeof buf); -#else - char _buf[256]; - char *buf; - buf = strerror_r (errnum, _buf, sizeof _buf); -#endif msg = safe_realloc (g, msg, strlen (msg) + 2 + strlen (buf) + 1); strcat (msg, ": "); @@ -570,6 +572,12 @@ guestfs_get_error_handler (guestfs_h *g, void **data_rtn) return g->error_cb; } +void +guestfs_user_cancel (guestfs_h *g) +{ + g->user_cancel = 1; +} + int guestfs__set_verbose (guestfs_h *g, int v) { @@ -793,6 +801,19 @@ guestfs__get_attach_method (guestfs_h *g) return ret; } +int +guestfs__set_pgroup (guestfs_h *g, int v) +{ + g->pgroup = !!v; + return 0; +} + +int +guestfs__get_pgroup (guestfs_h *g) +{ + return g->pgroup; +} + /* Note the private data area is allocated lazily, since the vast * majority of callers will never use it. This means g->pda is * likely to be NULL.