]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: create a predicate to determine if two xfs_names are the same
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:00:52 +0000 (10:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:36 +0000 (11:37 -0700)
Source kernel commit: d9c0775897147bab54410611ac2659a7477c770c

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: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
libxfs/xfs_dir2.h

index 7d7cd8d808e4dbc7134536a6d5fe3ef7e3dd9544..8497d041f3163b1de31e0262fd0d2941a8be611c 100644 (file)
@@ -24,6 +24,18 @@ struct xfs_dir3_icleaf_hdr;
 extern const struct xfs_name   xfs_name_dotdot;
 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
  */