[Libguestfs] [PATCH 3/6] dib: pass custom mkfs options after the filesystem type

Pino Toscano ptoscano at redhat.com
Thu Feb 2 13:43:22 UTC 2017


Make sure they are handled as options for the actual mkfs driver,
instead of mkfs itself.  Also, improve the documentation of
--mkfs-options accordingly.

This was fixed in diskimage-builder upstream as
commit 5e2330d89c6c0e55b270464abea7e99a4d3246ad.
---
 dib/dib.ml       | 3 ++-
 dib/virt-dib.pod | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/dib/dib.ml b/dib/dib.ml
index 7f05870..3f36997 100644
--- a/dib/dib.ml
+++ b/dib/dib.ml
@@ -803,6 +803,7 @@ let main () =
     | None -> []
     | Some o -> [ o ] in
   let mkfs_options =
+    [ "-t"; cmdline.fs_type ] @
     (match cmdline.fs_type with
     | "ext4" ->
       (* Very conservative to handle images being resized a lot
@@ -811,7 +812,7 @@ let main () =
        *)
       [ "-i"; "4096"; "-J"; "size=64" ]
     | _ -> []
-    ) @ mkfs_options @ [ "-t"; cmdline.fs_type; blockdev ] in
+    ) @ mkfs_options @ [ blockdev ] in
   ignore (g#debug "sh" (Array.of_list ([ "mkfs" ] @ mkfs_options)));
   g#set_label blockdev root_label;
   if String.is_prefix cmdline.fs_type "ext" then
diff --git a/dib/virt-dib.pod b/dib/virt-dib.pod
index 09251c7..8be40ae 100644
--- a/dib/virt-dib.pod
+++ b/dib/virt-dib.pod
@@ -271,8 +271,9 @@ The default can be found with this command:
 =item B<--mkfs-options> C<OPTION STRING>
 
 Add the specified options to L<mkfs(1)>, to be able to fine-tune
-the root filesystem creation.  Note that this is not possible
-to override the filesystem type.
+the root filesystem creation; the options are passed to the driver
+of L<mfks(1)>, and not to L<mfks(1)> itself.  Note that
+I<--fs-type> is used to to change the filesystem type.
 
 You should use I<--mkfs-options> at most once.  To pass multiple
 options, separate them with space, eg:
-- 
2.9.3




More information about the Libguestfs mailing list