---
daemon/blkdiscard.c | 23 +++++++++++++++++++++++
generator/actions.ml | 13 +++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/daemon/blkdiscard.c b/daemon/blkdiscard.c
index 26d5f7d..0651788 100644
--- a/daemon/blkdiscard.c
+++ b/daemon/blkdiscard.c
@@ -75,3 +75,26 @@ do_blkdiscard (const char *device)
close (fd);
return 0;
}
+
+int
+do_blkdiscardzeroes (const char *device)
+{
+ int fd;
+ unsigned int arg;
+
+ fd = open (device, O_RDONLY|O_CLOEXEC);
+ if (fd == -1) {
+ reply_with_perror ("open: %s", device);
+ return -1;
+ }
+
+ if (ioctl (fd, BLKDISCARDZEROES, &arg) == -1) {
+ reply_with_perror ("ioctl: %s: BLKDISCARDZEROES", device);
+ close (fd);
+ return -1;
+ }
+
+ close (fd);
+
+ return arg != 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index beb1182..4e2c9e0 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -11833,6 +11833,19 @@ an error or even appear to run but do nothing. You must also
set the C<discard> attribute on the block device (see
C<guestfs_add_drive_opts>)." };
+ { defaults with
+ name = "blkdiscardzeroes";
+ style = RBool "zeroes", [Device "device"], [];
+ proc_nr = Some 418;
+ shortdesc = "return true if discarded blocks are read as zeroes";
+ longdesc = "\
+This call returns true if blocks on C<device> that have been
+discarded by a call to C<guestfs_blkdiscard> are returned as
+blocks of zero bytes when read the next time.
+
+If it returns false, then it may be that discarded blocks are
+read as stale or random data." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 53c86ff..29aae8e 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-417
+418
--
1.8.5.3