@@ -86,6 +86,7 @@ static bool arg_in_memory = false;
8686static char * * arg_argv = NULL ;
8787static char * arg_loop_ref = NULL ;
8888static ImagePolicy * arg_image_policy = NULL ;
89+ static bool arg_mtree_hash = true;
8990
9091STATIC_DESTRUCTOR_REGISTER (arg_image , freep );
9192STATIC_DESTRUCTOR_REGISTER (arg_root , freep );
@@ -137,6 +138,7 @@ static int help(void) {
137138 " --json=pretty|short|off\n"
138139 " Generate JSON output\n"
139140 " --loop-ref=NAME Set reference string for loopback device\n"
141+ " --mtree-hash=BOOL Whether to include SHA256 hash in the mtree output\n"
140142 "\n%3$sCommands:%4$s\n"
141143 " -h --help Show this help\n"
142144 " --version Show package version\n"
@@ -257,6 +259,7 @@ static int parse_argv(int argc, char *argv[]) {
257259 ARG_LOOP_REF ,
258260 ARG_IMAGE_POLICY ,
259261 ARG_VALIDATE ,
262+ ARG_MTREE_HASH ,
260263 };
261264
262265 static const struct option options [] = {
@@ -288,6 +291,7 @@ static int parse_argv(int argc, char *argv[]) {
288291 { "loop-ref" , required_argument , NULL , ARG_LOOP_REF },
289292 { "image-policy" , required_argument , NULL , ARG_IMAGE_POLICY },
290293 { "validate" , no_argument , NULL , ARG_VALIDATE },
294+ { "mtree-hash" , required_argument , NULL , ARG_MTREE_HASH },
291295 {}
292296 };
293297
@@ -505,6 +509,12 @@ static int parse_argv(int argc, char *argv[]) {
505509 arg_action = ACTION_VALIDATE ;
506510 break ;
507511
512+ case ARG_MTREE_HASH :
513+ r = parse_boolean_argument ("--mtree-hash=" , optarg , & arg_mtree_hash );
514+ if (r < 0 )
515+ return r ;
516+ break ;
517+
508518 case '?' :
509519 return - EINVAL ;
510520
@@ -1202,7 +1212,7 @@ static int mtree_print_item(
12021212 ansi_normal (),
12031213 (uint64_t ) sx -> stx_size );
12041214
1205- if (inode_fd >= 0 && sx -> stx_size > 0 ) {
1215+ if (arg_mtree_hash && inode_fd >= 0 && sx -> stx_size > 0 ) {
12061216 uint8_t hash [SHA256_DIGEST_SIZE ];
12071217
12081218 r = get_file_sha256 (inode_fd , hash );
0 commit comments