Add the option force and lazy for force and lazy umount.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/mount.c | 25 +++++++++++++++++++++++--
generator/generator_actions.ml | 22 +++++++++++-----------
gobject/Makefile.inc | 2 ++
po/POTFILES | 1 +
4 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/daemon/mount.c b/daemon/mount.c
index 1bac1a7..0b91433 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -29,6 +29,8 @@
#include "daemon.h"
#include "actions.h"
+#define MAX_ARGS 64
+
/* You must mount something on "/" first before many operations.
* Hence we have an internal function which can test if something is
* mounted on *or under* the sysroot directory. (It has to be *or
@@ -187,16 +189,35 @@ do_mount_options (const char *options, const char *device,
* is kept updated.
*/
int
-do_umount (const char *pathordevice)
+do_umount (const char *pathordevice,
+ int force, int lazy)
{
int r;
char *err;
char *buf;
+ char prog[] = "umount";
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
DUP_RESOLVE_DEVICE_OR_PATH (pathordevice, buf, ,
{ free (buf); return -1;});
- r = command (NULL, &err, "umount", buf, NULL);
+ if (!(optargs_bitmask & GUESTFS_UMOUNT_FORCE_BITMASK))
+ force = 0;
+ if (!(optargs_bitmask & GUESTFS_UMOUNT_LAZE_BITMASK))
+ lazy = 0;
+
+ ADD_ARG (argv, i, prog);
+
+ if (force)
+ ADD_ARG (argv, i, "-f");
+ if (lazy)
+ ADD_ARG (argv, i, "-l");
+
+ ADD_ARG (argv, i, buf);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (NULL, &err, argv);
free (buf);
if (r == -1) {
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 1ce4026..67116b5 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -2742,7 +2742,7 @@ characters does I<not> work, even if the length is
specified." };
{ defaults with
name = "umount";
- style = RErr, [String "pathordevice"], [];
+ style = RErr, [String "pathordevice"], [OBool "force"; OBool
"laze"];
proc_nr = Some 45;
fish_alias = ["unmount"];
tests = [
@@ -2755,7 +2755,7 @@ characters does I<not> work, even if the length is
specified." };
[["part_disk"; "/dev/sda"; "mbr"];
["mkfs"; "ext2"; "/dev/sda1"; "";
"NOARG"; ""; ""];
["mount_options"; ""; "/dev/sda1";
"/"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["mounts"]], [])
];
shortdesc = "unmount a filesystem";
@@ -3437,12 +3437,12 @@ To download an uncompressed tarball, use
C<guestfs_tar_out>." };
proc_nr = Some 73;
tests = [
InitBasicFS, Always, TestLastFail (
- [["umount"; "/"];
+ [["umount"; "/"; "false"; "false"];
["mount_ro"; "/dev/sda1"; "/"];
["touch"; "/new"]]);
InitBasicFS, Always, TestOutput (
[["write"; "/new"; "data"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["mount_ro"; "/dev/sda1"; "/"];
["cat"; "/new"]], "data")
];
@@ -3685,10 +3685,10 @@ C<device>." };
fish_output = Some FishOutputHexadecimal;
tests = [
InitBasicFS, Always, TestOutputInt (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false";
"false"];
["fsck"; "ext2"; "/dev/sda1"]], 0);
InitBasicFS, Always, TestOutputInt (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false";
"false"];
["zero"; "/dev/sda1"];
["fsck"; "ext2"; "/dev/sda1"]], 8)
];
@@ -3729,7 +3729,7 @@ This command is entirely equivalent to running C<fsck -a -t
fstype device>." };
progress = true;
tests = [
InitBasicFS, Always, TestRun (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false";
"false"];
["zero"; "/dev/sda1"]])
];
shortdesc = "write zeroes to the device";
@@ -4051,7 +4051,7 @@ the human-readable, canonical hex dump of the file." };
["mkfs"; "ext3"; "/dev/sda1"; "";
"NOARG"; ""; ""];
["mount_options"; ""; "/dev/sda1";
"/"];
["write"; "/new"; "test file"];
- ["umount"; "/dev/sda1"];
+ ["umount"; "/dev/sda1"; "false";
"false"];
["zerofree"; "/dev/sda1"];
["mount_options"; ""; "/dev/sda1";
"/"];
["cat"; "/new"]], "test file")
@@ -4175,7 +4175,7 @@ are activated or deactivated." };
["mkfs"; "ext2"; "/dev/VG/LV"; "";
"NOARG"; ""; ""];
["mount_options"; ""; "/dev/VG/LV";
"/"];
["write"; "/new"; "test content"];
- ["umount"; "/"];
+ ["umount"; "/"; "false"; "false"];
["lvresize"; "/dev/VG/LV"; "20"];
["e2fsck_f"; "/dev/VG/LV"];
["e2fsck"; "/dev/VG/LV"; "true";
"false"];
@@ -6534,7 +6534,7 @@ Rename a logical volume C<logvol> with the new name
C<newlogvol>." };
proc_nr = Some 220;
tests = [
InitBasicFSonLVM, Always, TestOutputList (
- [["umount"; "/"];
+ [["umount"; "/"; "false"; "false"];
["vg_activate"; "false"; "VG"];
["vgrename"; "VG"; "VG2"];
["vg_activate"; "true"; "VG2"];
@@ -7655,7 +7655,7 @@ it contains all zero bytes." };
proc_nr = Some 284;
tests = [
InitBasicFS, Always, TestOutputTrue (
- [["umount"; "/dev/sda1"];
+ [["umount"; "/dev/sda1"; "false";
"false"];
["zero_device"; "/dev/sda1"];
["is_zero_device"; "/dev/sda1"]]);
InitBasicFS, Always, TestOutputFalse (
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index c73e5df..230d114 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -45,6 +45,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-inspect_get_icon.h \
include/guestfs-gobject/optargs-mount_local.h \
include/guestfs-gobject/optargs-umount_local.h \
+ include/guestfs-gobject/optargs-umount.h \
include/guestfs-gobject/optargs-mkfs.h \
include/guestfs-gobject/optargs-mount_9p.h \
include/guestfs-gobject/optargs-ntfsresize.h \
@@ -90,6 +91,7 @@ guestfs_gobject_sources= \
src/optargs-inspect_get_icon.c \
src/optargs-mount_local.c \
src/optargs-umount_local.c \
+ src/optargs-umount.c \
src/optargs-mkfs.c \
src/optargs-mount_9p.c \
src/optargs-ntfsresize.c \
diff --git a/po/POTFILES b/po/POTFILES
index 69291fa..700c199 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -163,6 +163,7 @@ gobject/src/optargs-ntfsresize_opts.c
gobject/src/optargs-set_e2attrs.c
gobject/src/optargs-test0.c
gobject/src/optargs-tune2fs.c
+gobject/src/optargs-umount.c
gobject/src/optargs-umount_local.c
gobject/src/session.c
gobject/src/struct-application.c
--
1.7.11.2.249.g31c7954