Package: rsync
Version: 2.5.6-0.1
Severity: wishlist
Hi,
As far a I know, there is no other program other than rsync that can
access rsync servers.
Making it easier to use the existing rsync program programaticaly to
access rsync servers from other applications would be quite useful.
There are two approaches that I can think of:
1) Allow specifying the temp file's name for single file transfers. If
that was possible, hacking around it to get the desired effect would
be even easy.
2) Adding --stream-to-fd parameter, so all file data gets also written
to the specified fd. That would allow the streaming while letting
rsync work normally.
For instance, this is an LD_PRELOADable library that did the trick for
me while coding apt-proxy v2:
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <stdlib.h>
static int fd_err = -1;
static FILE *debug;
void _init(void)
{
debug=stderr;
/* Make sure that nothing gets spit to stdout */
stdout = stderr;
/* save a file descriptor for stderr because rsync seams to close it
* at the and I want to write some debuging messages */
fd_err = dup(2);
fprintf(debug, "starting\n");
}
void _fini(void)
{
fprintf(debug, "ending\n");
}
int mkstemp(char *template)
{
fprintf(debug, "file_template: %s\n", template);
open(template, O_RDWR|O_CREAT, 0600);
return 1;
}
int mkstemp64(char *template)
{
return mkstemp(template);
}
int rename(const char *oldpath, const char *newpath)
{
dup2(fd_err, 2);
fprintf(debug, "newpath: %s\n", newpath);
if(strstr(oldpath, "XXXXXX")) {
char command[300] = "touch -r ";
fprintf(debug, "removeing %s\n", oldpath);
/* rsync changes the mtime on the temporal file, so use that
* to touch owr file */
snprintf(command, sizeof(command), "touch -r %s %s",
oldpath, newpath);
system(command);
return unlink(oldpath);
} else{
fprintf(debug, "renaiming %s\n\n", oldpath);
return syscall(SYS_rename, oldpath, newpath);
}
}
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
Thanks for maintaining rsync
Manuel
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux hell 2.4.21-dm-debian #3 Sun Aug 17 03:33:36 CEST 2003 i686
Locale: LANG=C, LC_CTYPE=es_ES
Versions of packages rsync depends on:
ii libc6 2.3.2-8 GNU C Library: Shared libraries an
ii libpopt0 1.7-2 lib for parsing cmdline parameters
-- no debconf information
--
--- Manuel Estrada Sainz <[email protected]>
<[email protected]>
<[email protected]>
------------------------ <[email protected]> -------------------
Let us have the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.
Debbugs is free software and licensed under the terms of the GNU General
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.