diff options
author | Barry Naujok <bnaujok@sgi.com> | 2008-05-21 02:41:01 -0400 |
---|---|---|
committer | Niv Sardi <xaiki@debian.org> | 2008-07-28 02:58:36 -0400 |
commit | 5163f95a08cbf058ae16452c2242c5600fedc32e (patch) | |
tree | 5d6b905f7031144a62fb1fa17ba3106d99268003 /fs/xfs/xfs_da_btree.c | |
parent | 68f34d5107dbace3d14a1c2f060fc8941894879c (diff) |
[XFS] Name operation vector for hash and compare
Adds two pieces of functionality for the basis of case-insensitive support
in XFS:
1. A comparison result enumerated type: xfs_dacmp. It represents an
exact match, case-insensitive match or no match at all. This patch
only implements different and exact results.
2. xfs_nameops vector for specifying how to perform the hash generation
of filenames and comparision methods. In this patch the hash vector
points to the existing xfs_da_hashname function and the comparison
method does a length compare, and if the same, does a memcmp and
return the xfs_dacmp result.
All filename functions that use the hash (create, lookup remove, rename,
etc) now use the xfs_nameops.hashname function and all directory lookup
functions also use the xfs_nameops.compname function.
The lookup functions also handle case-insensitive results even though the
default comparison function cannot return that. And important aspect of
the lookup functions is that an exact match always has precedence over a
case-insensitive. So while a case-insensitive match is found, we have to
keep looking just in case there is an exact match. In the meantime, the
info for the first case-insensitive match is retained if no exact match is
found.
SGI-PV: 981519
SGI-Modid: xfs-linux-melb:xfs-kern:31205a
Signed-off-by: Barry Naujok <bnaujok@sgi.com>
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Diffstat (limited to 'fs/xfs/xfs_da_btree.c')
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 294780427abb..ae4b18c7726b 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -1530,6 +1530,28 @@ xfs_da_hashname(const uchar_t *name, int namelen) | |||
1530 | } | 1530 | } |
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | enum xfs_dacmp | ||
1534 | xfs_da_compname( | ||
1535 | struct xfs_da_args *args, | ||
1536 | const char *name, | ||
1537 | int len) | ||
1538 | { | ||
1539 | return (args->namelen == len && memcmp(args->name, name, len) == 0) ? | ||
1540 | XFS_CMP_EXACT : XFS_CMP_DIFFERENT; | ||
1541 | } | ||
1542 | |||
1543 | static xfs_dahash_t | ||
1544 | xfs_default_hashname( | ||
1545 | struct xfs_name *name) | ||
1546 | { | ||
1547 | return xfs_da_hashname(name->name, name->len); | ||
1548 | } | ||
1549 | |||
1550 | const struct xfs_nameops xfs_default_nameops = { | ||
1551 | .hashname = xfs_default_hashname, | ||
1552 | .compname = xfs_da_compname | ||
1553 | }; | ||
1554 | |||
1533 | /* | 1555 | /* |
1534 | * Add a block to the btree ahead of the file. | 1556 | * Add a block to the btree ahead of the file. |
1535 | * Return the new block number to the caller. | 1557 | * Return the new block number to the caller. |