X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/23a0d1e200c7f23c4d8ca236f807c253a666009a..75a1a04847beb40a6fb1ce684562c358843a56fb:/hlink.c diff --git a/hlink.c b/hlink.c index dc969e9a..0e61d5a9 100644 --- a/hlink.c +++ b/hlink.c @@ -57,7 +57,7 @@ static struct file_list *hlink_flist; void init_hard_links(void) { if (am_sender || protocol_version < 30) - dev_tbl = hashtable_create(16, SIZEOF_INT64 == 8); + dev_tbl = hashtable_create(16, 1); else if (inc_recurse) prior_hlinks = hashtable_create(1024, 0); } @@ -67,11 +67,12 @@ struct ht_int64_node *idev_find(int64 dev, int64 ino) static struct ht_int64_node *dev_node = NULL; struct hashtable *tbl; - if (!dev_node || dev_node->key != dev) { + /* Note that some OSes have a dev == 0, so increment to avoid storing a 0. */ + if (!dev_node || dev_node->key != dev+1) { /* We keep a separate hash table of inodes for every device. */ - dev_node = hashtable_find(dev_tbl, dev, 1); + dev_node = hashtable_find(dev_tbl, dev+1, 1); if (!(tbl = dev_node->data)) { - tbl = dev_node->data = hashtable_create(512, SIZEOF_INT64 == 8); + tbl = dev_node->data = hashtable_create(512, 1); if (DEBUG_GTE(HLINK, 3)) { rprintf(FINFO, "[%s] created hashtable for dev %s\n", @@ -543,8 +544,19 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx, if (inc_recurse) { int gnum = F_HL_GNUM(file); struct ht_int32_node *node = hashtable_find(prior_hlinks, gnum, 0); - assert(node != NULL && node->data != NULL); - assert(CVAL(node->data, 0) == 0); + if (node == NULL) { + rprintf(FERROR, "Unable to find a hlink node for %d (%s)\n", gnum, f_name(file, prev_name)); + exit_cleanup(RERR_MESSAGEIO); + } + if (node->data == NULL) { + rprintf(FERROR, "Hlink node data for %d is NULL (%s)\n", gnum, f_name(file, prev_name)); + exit_cleanup(RERR_MESSAGEIO); + } + if (CVAL(node->data, 0) != 0) { + rprintf(FERROR, "Hlink node data for %d already has path=%s (%s)\n", + gnum, (char*)node->data, f_name(file, prev_name)); + exit_cleanup(RERR_MESSAGEIO); + } free(node->data); if (!(node->data = strdup(our_name))) out_of_memory("finish_hard_link");