MCPcopy Create free account
hub / github.com/RsyncProject/rsync / read_ndx_and_attrs

Function read_ndx_and_attrs

rsync.c:322–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr, char *buf, int *len_ptr)
323{
324 int len, iflags = 0;
325 struct file_list *flist;
326 uchar fnamecmp_type = FNAMECMP_FNAME;
327 int ndx;
328
329 read_loop:
330 while (1) {
331 ndx = read_ndx(f_in);
332
333 if (ndx >= 0)
334 break;
335 if (ndx == NDX_DONE)
336 return ndx;
337 if (ndx == NDX_DEL_STATS) {
338 read_del_stats(f_in);
339 if (am_sender && am_server)
340 write_del_stats(f_out);
341 continue;
342 }
343 if (!inc_recurse || am_sender) {
344 int last;
345 if (first_flist)
346 last = first_flist->prev->ndx_start + first_flist->prev->used - 1;
347 else
348 last = -1;
349 rprintf(FERROR,
350 "Invalid file index: %d (%d - %d) [%s]\n",
351 ndx, NDX_DONE, last, who_am_i());
352 exit_cleanup(RERR_PROTOCOL);
353 }
354 if (ndx == NDX_FLIST_EOF) {
355 flist_eof = 1;
356 if (DEBUG_GTE(FLIST, 3))
357 rprintf(FINFO, "[%s] flist_eof=1\n", who_am_i());
358 write_int(f_out, NDX_FLIST_EOF);
359 continue;
360 }
361 ndx = NDX_FLIST_OFFSET - ndx;
362 if (ndx < 0 || ndx >= dir_flist->used) {
363 ndx = NDX_FLIST_OFFSET - ndx;
364 rprintf(FERROR,
365 "Invalid dir index: %d (%d - %d) [%s]\n",
366 ndx, NDX_FLIST_OFFSET,
367 NDX_FLIST_OFFSET - dir_flist->used + 1,
368 who_am_i());
369 exit_cleanup(RERR_PROTOCOL);
370 }
371
372 if (DEBUG_GTE(FLIST, 2)) {
373 rprintf(FINFO, "[%s] receiving flist for dir %d\n",
374 who_am_i(), ndx);
375 }
376 /* Send all the data we read for this flist to the generator. */
377 start_flist_forward(ndx);
378 flist = recv_file_list(f_in, ndx);
379 flist->parent_ndx = ndx;

Callers 3

send_filesFunction · 0.85
read_final_goodbyeFunction · 0.85
recv_filesFunction · 0.85

Calls 15

read_ndxFunction · 0.85
read_del_statsFunction · 0.85
write_del_statsFunction · 0.85
write_intFunction · 0.85
start_flist_forwardFunction · 0.85
recv_file_listFunction · 0.85
stop_flist_forwardFunction · 0.85
read_shortintFunction · 0.85
maybe_send_keepaliveFunction · 0.85
flist_for_ndxFunction · 0.85
read_byteFunction · 0.85
read_vstringFunction · 0.85

Tested by

no test coverage detected