[Libguestfs] [PATCH 3/4] sparsify: Warn instead of error if a filesystem cannot be fstrimmed (RHBZ#1364347).

Richard W.M. Jones rjones at redhat.com
Fri Aug 5 11:22:46 UTC 2016


Thanks:  Xianghua Chen
---
 sparsify/in_place.ml | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sparsify/in_place.ml b/sparsify/in_place.ml
index 5cd03ef..e2ee9d9 100644
--- a/sparsify/in_place.ml
+++ b/sparsify/in_place.ml
@@ -89,7 +89,14 @@ let run disk format ignores machine_readable zeroes =
             if mounted then (
               message (f_"Trimming %s") fs;
 
-              g#fstrim "/"
+              try g#fstrim "/"
+              with G.Error msg as exn ->
+                if g#last_errno () = G.Errno.errno_ENOTSUP then (
+                  let vfs_type = try g#vfs_type fs with _ -> "unknown" in
+                  warning (f_"fstrim operation is not supported on %s (%s).  Suppress this warning using '--ignore %s', or use copying mode instead.")
+                          fs vfs_type fs
+                )
+                else raise exn
             ) else (
               let is_linux_x86_swap =
                 (* Look for the signature for Linux swap on i386.
-- 
2.7.4




More information about the Libguestfs mailing list