" -h|--cmd-help cmd Display detailed help on 'cmd'\n"
" -a image Add image\n"
" -m dev[:mnt] Mount dev on mnt (if omitted, /)\n"
+ " -n|--no-sync Don't autosync\n"
/*" --ro|-r All mounts are read-only\n"*/
" -v|--verbose Verbose messages\n"
"For more information, see the manpage guestfish(1).\n");
{ "cmd-help", 2, 0, 'h' },
{ "help", 0, 0, '?' },
{ "mount", 1, 0, 'm' },
+ { "no-sync", 0, 0, 'n' },
{ "verbose", 0, 0, 'v' },
{ 0, 0, 0, 0 }
};
exit (1);
}
+ guestfs_set_autosync (g, 1);
+
for (;;) {
c = getopt_long (argc, argv, options, long_options, NULL);
if (c == -1) break;
mps = mp->next;
break;
+ case 'n':
+ guestfs_set_autosync (g, 0);
+ break;
+
case 'v':
verbose++;
guestfs_set_verbose (g, verbose);
This returns the current out of memory handler.
+=head1 AUTOSYNC
+
+=head2 guestfs_set_autosync
+
+ void guestfs_set_autosync (guestfs_h *handle, int autosync);
+
+If C<autosync> is true, this enables autosync. Libguestfs will make a
+best effort attempt to run C<guestfs_sync> when the handle is closed
+(also if the program exits without closing handles).
+
+=head2 guestfs_get_autosync
+
+ int guestfs_get_autosync (guestfs_h *handle);
+
+Get the autosync flag.
+
=head1 VERBOSE MESSAGES
=head2 guestfs_set_verbose
int cmdline_size;
int verbose;
+ int autosync;
/* Callbacks. */
guestfs_abort_cb abort_cb;
if (g->verbose)
fprintf (stderr, "closing guestfs handle %p (state %d)\n", g, g->state);
+ /* Try to sync if autosync flag is set. */
+ if (g->autosync && g->state == READY)
+ guestfs_sync (g);
+
/* Remove any handlers that might be called back before we kill the
* subprocess.
*/
return g->verbose;
}
+void
+guestfs_set_autosync (guestfs_h *g, int a)
+{
+ g->autosync = a;
+}
+
+int
+guestfs_get_autosync (guestfs_h *g)
+{
+ return g->autosync;
+}
+
/* Add a string to the current command line. */
static void
incr_cmdline_size (guestfs_h *g)
extern void guestfs_set_out_of_memory_handler (guestfs_h *g, guestfs_abort_cb);
extern guestfs_abort_cb guestfs_get_out_of_memory_handler (guestfs_h *g);
+/* Misc. */
extern void guestfs_set_verbose (guestfs_h *g, int verbose);
extern int guestfs_get_verbose (guestfs_h *g);
+extern void guestfs_set_autosync (guestfs_h *g, int a);
+extern int guestfs_get_autosync (guestfs_h *g);
#include <guestfs-actions.h>