X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fcommand.c;h=7c67d830b0849f1081ef89b34f2756953843864b;hp=b2350ecb311c2c4e635138e83dc44781aab05854;hb=9ba779ea367b2ea7077da7bdd75e813cd06c7eea;hpb=3cf719bc077a5f0d4f1a79279a5ba6e41d53c9b9 diff --git a/daemon/command.c b/daemon/command.c index b2350ec..7c67d83 100644 --- a/daemon/command.c +++ b/daemon/command.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -22,10 +22,18 @@ #include #include -#include "../src/guestfs_protocol.h" +#include "guestfs_protocol.h" #include "daemon.h" #include "actions.h" +#include "ignore-value.h" + +static inline void +umount_ignore_fail (const char *path) +{ + ignore_value (command (NULL, NULL, "umount", path, NULL)); +} + char * do_command (char *const *argv) { @@ -36,14 +44,14 @@ do_command (char *const *argv) int dev_ok, dev_pts_ok, proc_ok, selinux_ok, sys_ok; /* We need a root filesystem mounted to do this. */ - NEED_ROOT (return NULL); + NEED_ROOT (, return NULL); /* Conveniently, argv is already a NULL-terminated argv-style array * of parameters, so we can pass it straight in to our internal * commandv. We just have to check the list is non-empty. */ if (argv[0] == NULL) { - reply_with_error ("command: passed an empty list"); + reply_with_error ("passed an empty list"); return NULL; } @@ -88,11 +96,11 @@ do_command (char *const *argv) r = commandv (&out, &err, (const char * const *) argv); CHROOT_OUT; - if (sys_ok) command (NULL, NULL, "umount", sysroot_sys, NULL); - if (selinux_ok) command (NULL, NULL, "umount", sysroot_selinux, NULL); - if (proc_ok) command (NULL, NULL, "umount", sysroot_proc, NULL); - if (dev_pts_ok) command (NULL, NULL, "umount", sysroot_dev_pts, NULL); - if (dev_ok) command (NULL, NULL, "umount", sysroot_dev, NULL); + if (sys_ok) umount_ignore_fail (sysroot_sys); + if (selinux_ok) umount_ignore_fail (sysroot_selinux); + if (proc_ok) umount_ignore_fail (sysroot_proc); + if (dev_pts_ok) umount_ignore_fail (sysroot_dev_pts); + if (dev_ok) umount_ignore_fail (sysroot_dev); free (sysroot_dev); free (sysroot_dev_pts);