| 571 | } |
| 572 | |
| 573 | void setup_protocol(int f_out,int f_in) |
| 574 | { |
| 575 | assert(file_extra_cnt == 0); |
| 576 | assert(EXTRA64_CNT == 2 || EXTRA64_CNT == 1); |
| 577 | |
| 578 | /* All int64 values must be set first so that they are guaranteed to be |
| 579 | * aligned for direct int64-pointer memory access. */ |
| 580 | if (preserve_atimes) |
| 581 | atimes_ndx = (file_extra_cnt += EXTRA64_CNT); |
| 582 | if (preserve_crtimes) |
| 583 | crtimes_ndx = (file_extra_cnt += EXTRA64_CNT); |
| 584 | if (am_sender) /* This is most likely in the file_extras64 union as well. */ |
| 585 | pathname_ndx = (file_extra_cnt += PTR_EXTRA_CNT); |
| 586 | else |
| 587 | depth_ndx = ++file_extra_cnt; |
| 588 | if (preserve_uid) |
| 589 | uid_ndx = ++file_extra_cnt; |
| 590 | if (preserve_gid) |
| 591 | gid_ndx = ++file_extra_cnt; |
| 592 | if (preserve_acls && !am_sender) |
| 593 | acls_ndx = ++file_extra_cnt; |
| 594 | if (preserve_xattrs) |
| 595 | xattrs_ndx = ++file_extra_cnt; |
| 596 | |
| 597 | if (am_server) |
| 598 | set_allow_inc_recurse(); |
| 599 | |
| 600 | if (remote_protocol == 0) { |
| 601 | if (am_server && !local_server) |
| 602 | check_sub_protocol(); |
| 603 | if (!read_batch) |
| 604 | write_int(f_out, protocol_version); |
| 605 | remote_protocol = read_int(f_in); |
| 606 | if (protocol_version > remote_protocol) |
| 607 | protocol_version = remote_protocol; |
| 608 | } |
| 609 | if (read_batch && remote_protocol > protocol_version) { |
| 610 | rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n", |
| 611 | remote_protocol, protocol_version); |
| 612 | exit_cleanup(RERR_PROTOCOL); |
| 613 | } |
| 614 | |
| 615 | if (DEBUG_GTE(PROTO, 1)) { |
| 616 | rprintf(FINFO, "(%s) Protocol versions: remote=%d, negotiated=%d\n", |
| 617 | am_server? "Server" : "Client", remote_protocol, protocol_version); |
| 618 | } |
| 619 | if (remote_protocol < MIN_PROTOCOL_VERSION |
| 620 | || remote_protocol > MAX_PROTOCOL_VERSION) { |
| 621 | rprintf(FERROR,"protocol version mismatch -- is your shell clean?\n"); |
| 622 | rprintf(FERROR,"(see the rsync manpage for an explanation)\n"); |
| 623 | exit_cleanup(RERR_PROTOCOL); |
| 624 | } |
| 625 | if (remote_protocol < OLD_PROTOCOL_VERSION) { |
| 626 | rprintf(FINFO,"%s is very old version of rsync, upgrade recommended.\n", |
| 627 | am_server? "Client" : "Server"); |
| 628 | } |
| 629 | if (protocol_version < MIN_PROTOCOL_VERSION) { |
| 630 | rprintf(FERROR, "--protocol must be at least %d on the %s.\n", |
no test coverage detected