Commit d9c07758 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: create a predicate to determine if two xfs_names are the same

Create a simple predicate to determine if two xfs_names are the same
objects or have the exact same name.  The comparison is always case
sensitive.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent e99bfc9e
...@@ -24,6 +24,18 @@ struct xfs_dir3_icleaf_hdr; ...@@ -24,6 +24,18 @@ struct xfs_dir3_icleaf_hdr;
extern const struct xfs_name xfs_name_dotdot; extern const struct xfs_name xfs_name_dotdot;
extern const struct xfs_name xfs_name_dot; extern const struct xfs_name xfs_name_dot;
static inline bool
xfs_dir2_samename(
const struct xfs_name *n1,
const struct xfs_name *n2)
{
if (n1 == n2)
return true;
if (n1->len != n2->len)
return false;
return !memcmp(n1->name, n2->name, n1->len);
}
/* /*
* Convert inode mode to directory entry filetype * Convert inode mode to directory entry filetype
*/ */
......
...@@ -93,11 +93,11 @@ xchk_dir_actor( ...@@ -93,11 +93,11 @@ xchk_dir_actor(
return -ECANCELED; return -ECANCELED;
} }
if (!strncmp(".", name->name, name->len)) { if (xfs_dir2_samename(name, &xfs_name_dot)) {
/* If this is "." then check that the inum matches the dir. */ /* If this is "." then check that the inum matches the dir. */
if (ino != dp->i_ino) if (ino != dp->i_ino)
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset);
} else if (!strncmp("..", name->name, name->len)) { } else if (xfs_dir2_samename(name, &xfs_name_dotdot)) {
/* /*
* If this is ".." in the root inode, check that the inum * If this is ".." in the root inode, check that the inum
* matches this dir. * matches this dir.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment