From 92f566ff38daa3deb2586ce0b995da32b5c7ebee Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Fri, 30 Dec 2016 11:39:45 -0600 Subject: [PATCH] libpkgconf: path: check both device node and inode for dedup. pointed out by @plicease --- libpkgconf/libpkgconf.h | 3 ++- libpkgconf/path.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 61bdc23..9c1e80d 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -92,7 +92,8 @@ struct pkgconf_path_ { pkgconf_node_t lnode; char *path; - void *handle; + void *handle_path; + void *handle_device; }; #define PKGCONF_PKG_PROPF_NONE 0x0 diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 1c26013..a035431 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -35,7 +35,7 @@ path_list_contains_entry(const char *text, pkgconf_list_t *dirlist) pkgconf_path_t *pn = n->data; #ifdef PKGCONF_CACHE_INODES - if (((ino_t) pn->handle) == st->st_ino) + if (((dev_t) pn->handle_device) == st->st_dev && ((ino_t) pn->handle_path) == st->st_ino) return true; #endif @@ -89,7 +89,8 @@ pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter) node = calloc(sizeof(pkgconf_path_t), 1); node->path = strdup(text); #ifdef PKGCONF_CACHE_INODES - node->handle = (void *)(intptr_t) st.st_ino; + node->handle_path = (void *)(intptr_t) st.st_ino; + node->handle_device = (void *)(intptr_t) st.st_dev; #endif pkgconf_node_insert_tail(&node->lnode, node, dirlist);