- fdb_open = 0;
- }
-
- /* Write buffer to batch csums file */
-
- if (write(fdb, buff, bytes_to_write) == -1) {
- rprintf(FERROR, "Batch file %s write error: %s\n",
- filename, strerror(errno));
- close(fdb);
- exit_cleanup(1);
- }
-}
-
-void close_batch_csums_file(void)
-{
- close(fdb);
-}
-
-
-/**
- * Write csum info to batch file
- *
- * @todo This will break if s->count is ever larger than maxint. The
- * batch code should probably be changed to consistently use the
- * variable-length integer routines, which is probably a compatible
- * change.
- **/
-void write_batch_csum_info(int *flist_entry, int flist_count,
- struct sum_struct *s)
-{
- size_t i;
- int int_count;
- extern int csum_length;
-
- fdb_open = 1;
-
- write_batch_csums_file(flist_entry, sizeof(int));
- int_count = s ? (int) s->count : 0;
- write_batch_csums_file(&int_count, sizeof int_count);
-
- if (s) {
- for (i = 0; i < s->count; i++) {
- write_batch_csums_file(&s->sums[i].sum1, sizeof(uint32));
- if ((*flist_entry == flist_count - 1)
- && (i == s->count - 1)) {
- fdb_close = 1;
- }
- write_batch_csums_file(s->sums[i].sum2, csum_length);
- }
- }
-}
-
-int read_batch_csums_file(char *buff, int len)
-{
- static int fdb_open = 1;
- int bytes_read;
- char filename[MAXPATHLEN];
-
- if (fdb_open) {
- /* Set up file extension */
- strlcpy(filename, batch_prefix, sizeof(filename));
- strlcat(filename, rsync_csums_file, sizeof(filename));
-
- /* Open batch flist file for reading */
- fdb = do_open(filename, O_RDONLY, 0);
- if (fdb == -1) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, strerror(errno));
- close(fdb);
- exit_cleanup(1);