[patch] rsync over existing I/O connections (new feature)
jw schultz
jw at pegasys.ws
Sat Mar 8 10:39:19 EST 2003
On Fri, Mar 07, 2003 at 05:40:17PM -0500, Tony Clayton wrote:
> Hello,
>
> I wrote this patch that allows you to run rsync over an existing I/O
> connection, instead of creating a new rsh or socket connection.
>
> For example, I have a client and server that talk over ssh via a simple
> custom protocol. I want to use the existing ssh connection to transfer files,
> but I want the flexibility of rsync to do it.
>
> With this patch, I can do the following in my client (assuming input fd of 0
> and output fd of 1):
>
> - send the server a START_RSYNC request on stdout (my protocol)
> - receive a START_RSYNC_ACK reply on fd stdin (my protocol)
> - clear the close-on-exec flags for the input and output (ssh) descriptors if
> necessary using fcntl (probably not required if using stdin/stdout)
> - fork/exec: rsync --partial --quiet --fd-in 0 --fd-out 1 :. myfile
> - return to blocking I/O for stdin/stdout using fcntl (rsync uses non-blocking)
> - continue on with my protocol
>
> And on the server, I do the following:
>
> - receive START_RSYNC request from client (my protocol)
> - send START_RSYNC_REPLY from client (my protocol)
> - fork/exec: rsync -p --server --sender --quiet . /path/to/file/on/server
> - return to blocking I/O for stdin/stdout using fcntl (rsync uses non-blocking)
> - continue on with my protocol
>
>
> I find this extremely useful. Hopefully it's useful enough to others to get
> added to the rsync codebase in one form or another so I don't have to keep
> patching rsync.
>
> This patch was made against rsync 2.5.4.
Interesting idea. In terms of invoking rsync as part of a
larger communications tool it makes some sense.
The logic you put in really already exists under the
--server option. I think the only part missing in current
code is what to do with the log messages. Connection to
arbitrary file descriptors should not be necessary.
am_server is currently only tested for true and set to
either 1 or 0.
#define AM_SERVER 1
#define AM_CLIENT 2
and a --client option that sets am_server to AM_CLIENT, then
make a few changes in log.c so that instead of testing for
non-zero am_server is tested for AM_SERVER or AM_CLIENT
to direct the log messages where they should go.
That should allow you do do something like
rsync -p --client . myfile
--
________________________________________________________________
J.W. Schultz Pegasystems Technologies
email address: jw at pegasys.ws
Remember Cernan and Schmitt
More information about the rsync
mailing list