Subject: bug#29092: [bug-idutils] bug#29092: bug#29092: Bug related to 64-bit inodes

From: Jim Meyering <[email-masked]>
Date: Mon, 18 Dec 2017 20:36:55 -0800

On Mon, Dec 18, 2017 at 3:31 PM, Curt McDowell <[email-masked]> wrote:
> Jim,
>
> Thanks for getting to this. I applied the patch and was surprised to see it
> still has the same bug! There is another comparison function that needs
> fixing. I verified that 64-bit inodes work properly with this additional
> change:
>
> static int
> dev_ino_hash_compare (void const *x, void const *y)
> {
>   int result;
>   result = memcmp(&((struct dev_ino const *) x)->di_ino,
>                   &((struct dev_ino const *) y)->di_ino, sizeof (ino_t));
>   if (result)
>     return result;
>   result = memcmp(&((struct dev_ino const *) x)->di_dev,
>                   &((struct dev_ino const *) y)->di_dev, sizeof (ino_t));
>   return result;
> }

Thank you for the quick testing and patch.

I've simplified that but left it in your name. However, since it's
still in your name, yet modified, I'll wait for your ACK before
pushing (check both author-name+email and wording of the commit log as
well as the actual patch, since we treat master-pushed commits as
immutable):
From c12c2b6b3ede51cabf59092b3d09bd2171534ddb Mon Sep 17 00:00:00 2001
From: Curt McDowell <[email-masked]>
Date: Mon, 18 Dec 2017 20:32:18 -0800
Subject: [PATCH] compare full 8-byte inodes in one more place

* libidu/walker.c (dev_ino_hash_compare): Rewrite to compare both
device and full inode.
---
 libidu/walker.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libidu/walker.c b/libidu/walker.c
index 82a2392..a21e239 100644
--- a/libidu/walker.c
+++ b/libidu/walker.c
@@ -1139,16 +1139,11 @@ DEV_INO_HASH_DEFUN(dev_ino_hash_1, xform_NOP)
 DEV_INO_HASH_DEFUN(dev_ino_hash_2, xform_NOT)

 static int
-dev_ino_hash_compare (void const *x, void const *y)
+dev_ino_hash_compare (void const *xv, void const *yv)
 {
-  int result;
-  INTEGER_COMPARE (((struct dev_ino const *) x)->di_ino,
-		   ((struct dev_ino const *) y)->di_ino, result);
-  if (result)
-    return result;
-  INTEGER_COMPARE (((struct dev_ino const *) x)->di_dev,
-		   ((struct dev_ino const *) y)->di_dev, result);
-  return result;
+  struct dev_ino const *x = xv;
+  struct dev_ino const *y = yv;
+  return x->di_ino == y->di_ino && x->di_dev == y->di_dev;
 }

 #endif
-- 
2.15.1.354.g95ec6b1b3