@@ -36,26 +36,42 @@ hash_help(void)
" 'hash' prints out the calculated hash value for a string using the\n"
"directory/attribute code hash function.\n"
"\n"
-" Usage: \"hash <string>\"\n"
+" Usage: \"hash [-d|-p parent_ino] <string>\"\n"
"\n"
));
}
+enum hash_what {
+ ATTR,
+ DIRECTORY,
+ PPTR,
+};
+
/* ARGSUSED */
static int
hash_f(
int argc,
char **argv)
{
+ xfs_ino_t p_ino = 0;
xfs_dahash_t hashval;
- bool use_dir2_hash = false;
+ enum hash_what what = ATTR;
int c;
- while ((c = getopt(argc, argv, "d")) != EOF) {
+ while ((c = getopt(argc, argv, "dp:")) != EOF) {
switch (c) {
case 'd':
- use_dir2_hash = true;
+ what = DIRECTORY;
+ break;
+ case 'p':
+ errno = 0;
+ p_ino = strtoull(optarg, NULL, 0);
+ if (errno) {
+ perror(optarg);
+ return 1;
+ }
+ what = PPTR;
break;
default:
exitcode = 1;
@@ -70,10 +86,18 @@ hash_f(
.len = strlen(argv[c]),
};
- if (use_dir2_hash)
+ switch (what) {
+ case DIRECTORY:
hashval = libxfs_dir2_hashname(mp, &xname);
- else
+ break;
+ case PPTR:
+ hashval = libxfs_parent_hashval(mp, xname.name,
+ xname.len, p_ino);
+ break;
+ case ATTR:
hashval = libxfs_attr_hashname(xname.name, xname.len);
+ break;
+ }
dbprintf("0x%x\n", hashval);
}
@@ -203,6 +203,7 @@
#define xfs_mkdir_space_res libxfs_mkdir_space_res
#define xfs_parent_addname libxfs_parent_addname
#define xfs_parent_finish libxfs_parent_finish
+#define xfs_parent_hashval libxfs_parent_hashval
#define xfs_parent_removename libxfs_parent_removename
#define xfs_parent_start libxfs_parent_start
#define xfs_parent_from_attr libxfs_parent_from_attr
@@ -822,7 +822,7 @@ Skip write verifiers but perform CRC recalculation; allows invalid data to be
written to disk to test detection of invalid data.
.RE
.TP
-.BI hash [-d]" strings
+.BI hash [-d|-p parent_ino]" strings
Prints the hash value of
.I string
using the hash function of the XFS directory and attribute implementation.
@@ -832,6 +832,13 @@ If the
option is specified, the directory-specific hash function is used.
This only makes a difference on filesystems with ascii case-insensitive
lookups enabled.
+
+If the
+.B \-p
+option is specified, the parent pointer-specific hash function is used.
+The parent directory inumber must be specified as an argument.
+This only makes a difference on filesystems with ascii case-insensitive
+lookups enabled.
.TP
.BI "hashcoll [-a] [-s seed] [-n " nr "] [-p " path "] -i | " names...
Create directory entries or extended attributes names that all have the same