From f7e6ffa8a82f8a7a214a47ff32f46d9e893902d8 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 30 Apr 2009 17:34:23 +0100 Subject: [PATCH] Autosync now runs umount-all; sync --- fish/cmds.c | 2 +- guestfish-actions.pod | 6 +++++- guestfs-actions.pod | 6 +++++- java/com/redhat/et/libguestfs/GuestFS.java | 9 ++++++--- perl/lib/Sys/Guestfs.pm | 6 +++++- python/guestfs.py | 9 ++++++--- src/generator.ml | 8 ++++++-- src/guestfs.c | 4 +++- 8 files changed, 37 insertions(+), 13 deletions(-) diff --git a/fish/cmds.c b/fish/cmds.c index f0da329..1e8cb30 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -165,7 +165,7 @@ void display_command (const char *cmd) pod2text ("get-path - get the search path", " get-path\n\nReturn the current search path.\n\nThis is always non-NULL. If it wasn't set already, then this will\nreturn the default path."); else if (strcasecmp (cmd, "set_autosync") == 0 || strcasecmp (cmd, "set-autosync") == 0 || strcasecmp (cmd, "autosync") == 0) - pod2text ("set-autosync - set autosync mode", " set-autosync \n\nIf C is true, this enables autosync. Libguestfs will make a\nbest effort attempt to run C when the handle is closed\n(also if the program exits without closing handles).\n\nYou can use 'autosync' as an alias for this command."); + pod2text ("set-autosync - set autosync mode", " set-autosync \n\nIf C is true, this enables autosync. Libguestfs will make a\nbest effort attempt to run C followed by\nC when the handle is closed\n(also if the program exits without closing handles).\n\nThis is disabled by default (except in guestfish where it is\nenabled by default).\n\nYou can use 'autosync' as an alias for this command."); else if (strcasecmp (cmd, "get_autosync") == 0 || strcasecmp (cmd, "get-autosync") == 0) pod2text ("get-autosync - get autosync mode", " get-autosync\n\nGet the autosync flag."); diff --git a/guestfish-actions.pod b/guestfish-actions.pod index 62688ee..fce1b31 100644 --- a/guestfish-actions.pod +++ b/guestfish-actions.pod @@ -823,9 +823,13 @@ Remove the single directory C. set-autosync true|false If C is true, this enables autosync. Libguestfs will make a -best effort attempt to run C when the handle is closed +best effort attempt to run C followed by +C when the handle is closed (also if the program exits without closing handles). +This is disabled by default (except in guestfish where it is +enabled by default). + =head2 set-e2label set-e2label device label diff --git a/guestfs-actions.pod b/guestfs-actions.pod index 260cb4f..210e825 100644 --- a/guestfs-actions.pod +++ b/guestfs-actions.pod @@ -1099,9 +1099,13 @@ This function returns 0 on success or -1 on error. int autosync); If C is true, this enables autosync. Libguestfs will make a -best effort attempt to run C when the handle is closed +best effort attempt to run C followed by +C when the handle is closed (also if the program exits without closing handles). +This is disabled by default (except in guestfish where it is +enabled by default). + This function returns 0 on success or -1 on error. =head2 guestfs_set_busy diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java index fdf6e4e..7e7cd68 100644 --- a/java/com/redhat/et/libguestfs/GuestFS.java +++ b/java/com/redhat/et/libguestfs/GuestFS.java @@ -319,9 +319,12 @@ public class GuestFS { * set autosync mode * * If "autosync" is true, this enables autosync. Libguestfs - * will make a best effort attempt to run "g.sync" when the - * handle is closed (also if the program exits without - * closing handles). + * will make a best effort attempt to run "g.umount_all" + * followed by "g.sync" when the handle is closed (also if + * the program exits without closing handles). + * + * This is disabled by default (except in guestfish where + * it is enabled by default). * * @throws LibGuestFSException */ diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 90384da..efc2845 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -758,9 +758,13 @@ Remove the single directory C. =item $h->set_autosync ($autosync); If C is true, this enables autosync. Libguestfs will make a -best effort attempt to run C<$h-Esync> when the handle is closed +best effort attempt to run C<$h-Eumount_all> followed by +C<$h-Esync> when the handle is closed (also if the program exits without closing handles). +This is disabled by default (except in guestfish where it is +enabled by default). + =item $h->set_busy (); This sets the state to C. This is only used when implementing diff --git a/python/guestfs.py b/python/guestfs.py index ab0154f..2fced28 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -194,9 +194,12 @@ class GuestFS: def set_autosync (self, autosync): u"""If "autosync" is true, this enables autosync. Libguestfs - will make a best effort attempt to run "g.sync" when the - handle is closed (also if the program exits without - closing handles). + will make a best effort attempt to run "g.umount_all" + followed by "g.sync" when the handle is closed (also if + the program exits without closing handles). + + This is disabled by default (except in guestfish where + it is enabled by default). """ return libguestfsmod.set_autosync (self._o, autosync) diff --git a/src/generator.ml b/src/generator.ml index ae640e2..9a9c168 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -339,8 +339,12 @@ return the default path."); "set autosync mode", "\ If C is true, this enables autosync. Libguestfs will make a -best effort attempt to run C when the handle is closed -(also if the program exits without closing handles)."); +best effort attempt to run C followed by +C when the handle is closed +(also if the program exits without closing handles). + +This is disabled by default (except in guestfish where it is +enabled by default)."); ("get_autosync", (RBool "autosync", []), -1, [], [], diff --git a/src/guestfs.c b/src/guestfs.c index 05c02f3..c2d58e8 100644 --- a/src/guestfs.c +++ b/src/guestfs.c @@ -267,8 +267,10 @@ guestfs_close (guestfs_h *g) 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) + if (g->autosync && g->state == READY) { + guestfs_umount_all (g); guestfs_sync (g); + } /* Remove any handlers that might be called back before we kill the * subprocess. -- 1.8.3.1