From b2c7fa88469be2da57d989b536fc81392ada6baf Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Sun, 27 Mar 2016 04:35:59 +0200 Subject: [PATCH] bin/xbps-create: search for inode dublication using xbps_dictionary_t instead of linked list. --- bin/xbps-create/main.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c index d02e4fdc..8749e11b 100644 --- a/bin/xbps-create/main.c +++ b/bin/xbps-create/main.c @@ -412,6 +412,10 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u } else if (type == FTW_F) { struct xentry *xep; bool hlink = false; + xbps_object_iterator_t iter; + xbps_object_t obj; + xbps_dictionary_t linkinfo; + uint64_t inode = 0; /* * Regular files. First find out if it's a hardlink: * - st_nlink > 1 @@ -420,12 +424,31 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u TAILQ_FOREACH(xep, &xentry_list, entries) { if (sb->st_nlink > 1 && xep->inode == sb->st_ino) { /* matched */ + printf("%lu %lu\n", xep->inode, sb->st_ino); hlink = true; break; } } - if (!hlink) + + iter = xbps_dictionary_iterator(all_filesd); + assert(iter); + while ((obj = xbps_object_iterator_next(iter))) { + if (sb->st_nlink <= 1) + continue; + linkinfo = xbps_dictionary_get_keysym(all_filesd, obj); + xbps_dictionary_get_uint64(linkinfo, "inode", &inode); + if (inode == sb->st_ino) { + /* matched */ + printf("%lu %lu\n", inode, sb->st_ino); + break; + } + } + if (!hlink != (inode != sb->st_ino)) + die("Inconsistent results from xbps_dictionary_t and linked list!\n"); + + if (inode != sb->st_ino) instsize += sb->st_size; + xbps_object_iterator_release(iter); /* * Find out if it's a configuration file or not