(no subject)

Oliver Dewdney oliver.dewdney at aspectgroup.co.uk
Thu Jul 24 01:47:14 EST 2003


Here is a diff which should allow applying batch updates remotely ( as
apposed to copying the batch files to the remote server and running rsync
there ).

Eg

rsync --write-batch=test src dst1::dst

rsync --read-batch=test dst2::dst

Oli Dewdney



diff -E -B -c -r rsync-2.5.6/flist.c rsync-2.5.6-remotebatch/flist.c
*** rsync-2.5.6/flist.c	Sat Jan 18 18:00:23 2003
--- rsync-2.5.6-remotebatch/flist.c	Wed Jul 23 11:27:45 2003
***************
*** 1038,1043 ****
--- 1038,1058 ----
  	return flist;
  }
  
+ void send_batch_file_list( int f, struct file_list *flist )
+ {
+ 	int n;
+ 	for (n = 0; n < flist->count; n++ ) {
+ 		send_file_entry(flist->files[n], f, 0);
+ 	}
+ 	send_file_entry(NULL, f, 0);
+ 	if (f != -1 && remote_version >= 15) {
+ 		send_uid_list(f);
+ 	}
+ 	if (f != -1 && remote_version >= 17 && !read_batch) {	/* dw-added
readbatch */
+ 		extern int module_id;
+ 		write_int(f, lp_ignore_errors(module_id) ? 0 : io_error);
+ 	}
+ }
  
  struct file_list *recv_file_list(int f)
  {
diff -E -B -c -r rsync-2.5.6/main.c rsync-2.5.6-remotebatch/main.c
*** rsync-2.5.6/main.c	Tue Jan 28 05:05:53 2003
--- rsync-2.5.6-remotebatch/main.c	Wed Jul 23 15:55:18 2003
***************
*** 263,270 ****
  	}
  
  	if (local_server) {
- 		if (read_batch)
- 		    create_flist_from_batch(); /* sets batch_flist */
  		ret = local_child(argc, args, f_in, f_out, child_main);
  	} else {
  		ret = piped_child(args,f_in,f_out);
--- 263,268 ----
***************
*** 505,515 ****
  
  	if (delete_mode && !delete_excluded)
  		recv_exclude_list(f_in);
! 
! 	if (read_batch)
! 	    flist = batch_flist;
! 	else
! 	    flist = recv_file_list(f_in);
  	if (!flist) {
  		rprintf(FERROR,"server_recv: recv_file_list error\n");
  		exit_cleanup(RERR_FILESELECT);
--- 503,509 ----
  
  	if (delete_mode && !delete_excluded)
  		recv_exclude_list(f_in);
! 	flist = recv_file_list(f_in);
  	if (!flist) {
  		rprintf(FERROR,"server_recv: recv_file_list error\n");
  		exit_cleanup(RERR_FILESELECT);
***************
*** 602,607 ****
--- 597,610 ----
  			send_exclude_list(f_out);
  		if (!read_batch) /*  dw -- don't write to pipe */
  		    flist = send_file_list(f_out,argc,argv);
+ 		else {
+ 		    if (remote_version < 27) {
+ 			rprintf(FERROR,"Version Error for remote batch\n");
+ 			exit_cleanup(RERR_FILESELECT);
+ 		    }
+ 		    flist = create_flist_from_batch(); /* sets batch_flist
*/
+ 		    send_batch_file_list( f_out, flist );
+ 		}
  		if (verbose > 3) 
  			rprintf(FINFO,"file list sent\n");
  
***************
*** 712,717 ****
--- 715,721 ----
  	if ((rc = copy_argv(argv)))
  		return rc;
  
+ 	if (!read_batch) {
  	/* rsync:// always uses rsync server over direct socket connection
*/
  	if (strncasecmp(URL_PREFIX, argv[0], strlen(URL_PREFIX)) == 0) {
  		char *host, *path;
***************
*** 732,739 ****
  		return start_socket_client(host, path, argc-1, argv+1);
  	}
  
! 	if (!read_batch) {
! 		p = find_colon(argv[0]);
  
  	if (p) {
  		if (p[1] == ':') { /* double colon */
--- 736,742 ----
  		return start_socket_client(host, path, argc-1, argv+1);
  	}
  
! 	p = find_colon(argv[0]);
  
  	if (p) {
  		if (p[1] == ':') { /* double colon */
***************
*** 808,816 ****
  		}
  		argc--;
  	}
! 	} else {
  	    am_sender = 1;
! 	    local_server = 1;
  	    shell_path = argv[argc-1];
  	}
  
--- 811,857 ----
  		}
  		argc--;
  	}
! 	} else { /* read_batch */
  	    am_sender = 1;
! 
! 		if (argc > 1) {
! 			usage(FERROR);
! 			exit_cleanup(RERR_SYNTAX);
! 		}
! 
! 		if (strncasecmp(URL_PREFIX, argv[0], strlen(URL_PREFIX)) ==
0) {
! 			char *host, *path;
! 
! 			host = argv[0] + strlen(URL_PREFIX);
! 			p = strchr(host,'/');
! 			if (p) {
! 				*p = 0;
! 				path = p+1;
! 			} else {
! 				path = "";
! 			}
! 			p = strchr(host,':');
! 			if (p) {
! 				rsync_port = atoi(p+1);
! 				*p = 0;
! 			}
! 			return start_socket_client(host, path, argc-1,
argv+1);
! 		}
! 		p = find_colon(argv[0]);
! 
! 		if (p) {
! 			if (p[1] == ':') { /* double colon */
! 				*p = 0;
! 				if (!shell_cmd) {
! 				return start_socket_client(argv[0], p+2,
! 							   argc-1, argv+1);
! 				}
! 			}
! 			p++;
! 			daemon_over_rsh = 1;
! 		}
! 		else
! 		    local_server = 1;
  	    shell_path = argv[argc-1];
  	}
  
diff -E -B -c -r rsync-2.5.6/proto.h rsync-2.5.6-remotebatch/proto.h
*** rsync-2.5.6/proto.h	Mon Jan 27 03:35:09 2003
--- rsync-2.5.6-remotebatch/proto.h	Wed Jul 23 11:27:53 2003
***************
*** 31,37 ****
  void sum_init(void);
  void sum_update(char *p, int len);
  void sum_end(char *sum);
! void close_all(void);
  void _exit_cleanup(int code, const char *file, int line);
  void cleanup_disable(void);
  void cleanup_set(char *fnametmp, char *fname, struct file_struct *file,
--- 31,37 ----
  void sum_init(void);
  void sum_update(char *p, int len);
  void sum_end(char *sum);
! void close_all();
  void _exit_cleanup(int code, const char *file, int line);
  void cleanup_disable(void);
  void cleanup_set(char *fnametmp, char *fname, struct file_struct *file,
***************
*** 84,89 ****
--- 84,90 ----
  void send_file_name(int f, struct file_list *flist, char *fname,
  		    int recursive, unsigned base_flags);
  struct file_list *send_file_list(int f, int argc, char *argv[]);
+ void send_batch_file_list( int f, struct file_list *flist );
  struct file_list *recv_file_list(int f);
  int file_compare(struct file_struct **f1, struct file_struct **f2);
  int flist_find(struct file_list *flist, struct file_struct *f);
diff -E -B -c -r rsync-2.5.6/rsync.h rsync-2.5.6-remotebatch/rsync.h
*** rsync-2.5.6/rsync.h	Sun Jan 26 20:11:16 2003
--- rsync-2.5.6-remotebatch/rsync.h	Wed Jul 23 10:52:41 2003
***************
*** 50,56 ****
  #define SAME_TIME (1<<7)
  
  /* update this if you make incompatible changes */
! #define PROTOCOL_VERSION 26
  
  /* We refuse to interoperate with versions that are not in this range.
   * Note that we assume we'll work with later versions: the onus is on
--- 50,56 ----
  #define SAME_TIME (1<<7)
  
  /* update this if you make incompatible changes */
! #define PROTOCOL_VERSION 27
  
  /* We refuse to interoperate with versions that are not in this range.
   * Note that we assume we'll work with later versions: the onus is on



More information about the rsync mailing list