MCPcopy Index your code
hub / github.com/RsyncProject/rsync / match_gnums

Function match_gnums

hlink.c:113–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113static void match_gnums(int32 *ndx_list, int ndx_count)
114{
115 int32 from, prev;
116 struct file_struct *file, *file_next;
117 struct ht_int32_node *node = NULL;
118 int32 gnum, gnum_next;
119
120 qsort(ndx_list, ndx_count, sizeof ndx_list[0], (int (*)(const void*, const void*))hlink_compare_gnum);
121
122 for (from = 0; from < ndx_count; from++) {
123 file = hlink_flist->sorted[ndx_list[from]];
124 gnum = F_HL_GNUM(file);
125 if (inc_recurse) {
126 node = hashtable_find(prior_hlinks, gnum, data_when_new);
127 if (node->data == data_when_new) {
128 node->data = new_array0(char, 5);
129 assert(gnum >= hlink_flist->ndx_start);
130 file->flags |= FLAG_HLINK_FIRST;
131 prev = -1;
132 } else if (CVAL(node->data, 0) == 0) {
133 struct file_list *flist;
134 prev = IVAL(node->data, 1);
135 flist = flist_for_ndx(prev, NULL);
136 if (flist)
137 flist->files[prev - flist->ndx_start]->flags &= ~FLAG_HLINK_LAST;
138 else {
139 /* We skipped all prior files in this
140 * group, so mark this as a "first". */
141 file->flags |= FLAG_HLINK_FIRST;
142 prev = -1;
143 }
144 } else
145 prev = -1;
146 } else {
147 file->flags |= FLAG_HLINK_FIRST;
148 prev = -1;
149 }
150 for ( ; from < ndx_count-1; file = file_next, gnum = gnum_next, from++) { /*SHARED ITERATOR*/
151 file_next = hlink_flist->sorted[ndx_list[from+1]];
152 gnum_next = F_HL_GNUM(file_next);
153 if (gnum != gnum_next)
154 break;
155 F_HL_PREV(file) = prev;
156 /* The linked list uses over-the-wire ndx values. */
157 if (unsort_ndx)
158 prev = F_NDX(file);
159 else
160 prev = ndx_list[from] + hlink_flist->ndx_start;
161 }
162 if (prev < 0 && !inc_recurse) {
163 /* Disable hard-link bit and set DONE so that
164 * HLINK_BUMP()-dependent values are unaffected. */
165 file->flags &= ~(FLAG_HLINKED | FLAG_HLINK_FIRST);
166 file->flags |= FLAG_HLINK_DONE;
167 continue;
168 }
169
170 file->flags |= FLAG_HLINK_LAST;

Callers 1

match_hard_linksFunction · 0.85

Calls 4

hashtable_findFunction · 0.85
IVALFunction · 0.85
flist_for_ndxFunction · 0.85
SIVALFunction · 0.85

Tested by

no test coverage detected