build_verity_tree: Add verbose flag

Signed-off-by: Mohamad Ayyash <mkayyash@google.com>

(cherry picked from commit 70f72fb1035e753f5cef176339618723fba943e2)

Change-Id: Ic1f4c843e9597a9e7c0f43eb908c17420c259d9a
diff --git a/verity/build_verity_tree.cpp b/verity/build_verity_tree.cpp
index 5e04ce5..e7bfa40 100644
--- a/verity/build_verity_tree.cpp
+++ b/verity/build_verity_tree.cpp
@@ -115,6 +115,7 @@
            "  -A,--salt-hex=<hex digits>   set salt to <hex digits>\n"
            "  -h                           show this help\n"
            "  -s,--verity-size=<data size> print the size of the verity tree\n"
+           "  -v,                          enable verbose logging\n"
            "  -S                           treat <data image> as a sparse file\n"
         );
 }
@@ -128,6 +129,7 @@
     bool sparse = false;
     size_t block_size = 4096;
     uint64_t calculate_size = 0;
+    bool verbose = false;
 
     while (1) {
         const static struct option long_options[] = {
@@ -136,9 +138,10 @@
             {"help", no_argument, 0, 'h'},
             {"sparse", no_argument, 0, 'S'},
             {"verity-size", required_argument, 0, 's'},
+            {"verbose", no_argument, 0, 'v'},
             {NULL, 0, 0, 0}
         };
-        int c = getopt_long(argc, argv, "a:A:hSs:", long_options, NULL);
+        int c = getopt_long(argc, argv, "a:A:hSs:v", long_options, NULL);
         if (c < 0) {
             break;
         }
@@ -187,6 +190,9 @@
                 calculate_size = (uint64_t)inSize;
             }
             break;
+        case 'v':
+            verbose = true;
+            break;
         case '?':
             usage();
             return 1;
@@ -260,7 +266,7 @@
     if (sparse) {
         file = sparse_file_import(fd, false, false);
     } else {
-        file = sparse_file_import_auto(fd, false);
+        file = sparse_file_import_auto(fd, false, verbose);
     }
 
     if (!file) {