From f8bd55160cde8a678a9ddbf69b7555504b253bef Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 10 Sep 2008 11:30:46 -0400 Subject: [PATCH] debugfs: Add the ability to specify the hash seed to the "hash" command Also add the ability to specify the hash algorithm by name instead of by number. Signed-off-by: "Theodore Ts'o" --- debugfs/htree.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/debugfs/htree.c b/debugfs/htree.c index 983dc9a2..4b8d7e9d 100644 --- a/debugfs/htree.c +++ b/debugfs/htree.c @@ -294,10 +294,19 @@ void do_dx_hash(int argc, char *argv[]) hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0; reset_getopt(); - while ((c = getopt (argc, argv, "h:")) != EOF) { + while ((c = getopt (argc, argv, "h:s:")) != EOF) { switch (c) { case 'h': - hash_version = atoi(optarg); + hash_version = e2p_string2hash(optarg); + if (hash_version < 0) + hash_version = atoi(optarg); + break; + case 's': + if (uuid_parse(optarg, hash_seed)) { + fprintf(stderr, "Invalid UUID format: %s\n", + optarg); + return; + } break; default: goto print_usage; @@ -305,7 +314,8 @@ void do_dx_hash(int argc, char *argv[]) } if (optind != argc-1) { print_usage: - com_err(argv[0], 0, "usage: dx_hash filename"); + com_err(argv[0], 0, "usage: dx_hash [-h hash_alg] " + "[-s hash_seed] filename"); return; } err = ext2fs_dirhash(hash_version, argv[optind], strlen(argv[optind]),