]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/hash.c
bda331662ed9af5ae9fda164f8fef41a4936da90
[thirdparty/xfsprogs-dev.git] / db / hash.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6
7 #include "libxfs.h"
8 #include "addr.h"
9 #include "command.h"
10 #include "type.h"
11 #include "io.h"
12 #include "output.h"
13
14 static int hash_f(int argc, char **argv);
15 static void hash_help(void);
16
17 static const cmdinfo_t hash_cmd =
18 { "hash", NULL, hash_f, 1, 1, 0, N_("string"),
19 N_("calculate hash value"), hash_help };
20
21 static void
22 hash_help(void)
23 {
24 dbprintf(_(
25 "\n"
26 " 'hash' prints out the calculated hash value for a string using the\n"
27 "directory/attribute code hash function.\n"
28 "\n"
29 " Usage: \"hash <string>\"\n"
30 "\n"
31 ));
32
33 }
34
35 /* ARGSUSED */
36 static int
37 hash_f(
38 int argc,
39 char **argv)
40 {
41 xfs_dahash_t hashval;
42
43 hashval = libxfs_da_hashname((unsigned char *)argv[1], (int)strlen(argv[1]));
44 dbprintf("0x%x\n", hashval);
45 return 0;
46 }
47
48 void
49 hash_init(void)
50 {
51 add_command(&hash_cmd);
52 }