aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-09-10 11:30:46 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-09-10 11:30:46 -0400
commitf8bd55160cde8a678a9ddbf69b7555504b253bef (patch)
tree3db675580e422240d29a2ff1242adbf7027606fc
parent52771ab59145d66b50399a8b953b8181cb2d5b04 (diff)
downloadandroid_external_e2fsprogs-f8bd55160cde8a678a9ddbf69b7555504b253bef.tar.gz
android_external_e2fsprogs-f8bd55160cde8a678a9ddbf69b7555504b253bef.tar.bz2
android_external_e2fsprogs-f8bd55160cde8a678a9ddbf69b7555504b253bef.zip
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" <tytso@mit.edu>
-rw-r--r--debugfs/htree.c16
1 files 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]),