mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-05-26 15:55:42 -04:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d8810c928 | ||
|
|
d153974ee2 | ||
|
|
5b56cc19fb | ||
|
|
c48b22c858 | ||
|
|
65d0a49f5c | ||
|
|
6a48ca56eb | ||
|
|
a20aa42ac4 | ||
|
|
e92ee12893 | ||
|
|
5c66303ad6 | ||
|
|
27e3e9c906 | ||
|
|
f0b36a48c8 | ||
|
|
25cf88936f | ||
|
|
ae682c3e11 | ||
|
|
99994aef3e | ||
|
|
78043d1969 | ||
|
|
43e46b4cf6 | ||
|
|
9ec16c83be | ||
|
|
a24c687094 | ||
|
|
60cb2f9016 | ||
|
|
ac1a0994b6 | ||
|
|
f2cbf44ba5 | ||
|
|
dab552237e | ||
|
|
2201ba580e | ||
|
|
b7c33e3bde | ||
|
|
82980a2384 | ||
|
|
b6a30afc98 | ||
|
|
ed91f3e418 | ||
|
|
60c8d7bc7f |
@@ -9,6 +9,7 @@ mandir=@mandir@
|
||||
LIBS=@LIBS@
|
||||
CC=@CC@
|
||||
CFLAGS=@CFLAGS@
|
||||
LDFLAGS=@LDFLAGS@
|
||||
|
||||
INSTALLCMD=@INSTALL@
|
||||
|
||||
@@ -20,8 +21,6 @@ SHELL=/bin/sh
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
HEADS=byteorder.h config.h errcode.h proto.h rsync.h version.h \
|
||||
lib/fnmatch.h lib/getopt.h lib/mdfour.h
|
||||
LIBOBJ=lib/getopt.o lib/fnmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o
|
||||
ZLIBOBJ=zlib/deflate.o zlib/infblock.o zlib/infcodes.o zlib/inffast.o \
|
||||
zlib/inflate.o zlib/inftrees.o zlib/infutil.o zlib/trees.o \
|
||||
@@ -55,8 +54,6 @@ install-strip:
|
||||
rsync: $(OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o rsync $(OBJS) $(LIBS)
|
||||
|
||||
$(OBJS): $(HEADS)
|
||||
|
||||
rsync.1: rsync.yo
|
||||
yodl2man -o rsync.1 rsync.yo
|
||||
|
||||
|
||||
3
README
3
README
@@ -125,8 +125,7 @@ There is a mailing list for the discussion of rsync and its
|
||||
applications. It is open to anyone to join. I will announce new
|
||||
versions on this list.
|
||||
|
||||
To join the mailing list send mail to listproc@samba.org with
|
||||
no subject and a body of "subscribe rsync Your Name".
|
||||
To join the mailing list see the web page at http://lists.samba.org/
|
||||
|
||||
To send mail to everyone on the list send it to rsync@samba.org
|
||||
|
||||
|
||||
1
access.c
1
access.c
@@ -68,6 +68,7 @@ static int match_address(char *addr, char *tok)
|
||||
mask = ntohl(mask);
|
||||
} else {
|
||||
int bits = atoi(p+1);
|
||||
if (bits == 0) return 1;
|
||||
if (bits <= 0 || bits > 32) {
|
||||
rprintf(FERROR,"malformed mask in %s\n", tok);
|
||||
return 0;
|
||||
|
||||
@@ -135,7 +135,6 @@ static int get_secret(int module, char *user, char *secret, int len)
|
||||
static char *getpassf(char *filename)
|
||||
{
|
||||
char buffer[100];
|
||||
int len=0;
|
||||
int fd=0;
|
||||
STRUCT_STAT st;
|
||||
int ok = 1;
|
||||
@@ -170,7 +169,7 @@ static char *getpassf(char *filename)
|
||||
if (envpw) rprintf(FERROR,"RSYNC_PASSWORD environment variable ignored\n");
|
||||
|
||||
buffer[sizeof(buffer)-1]='\0';
|
||||
if ( (len=read(fd,buffer,sizeof(buffer)-1)) > 0)
|
||||
if (read(fd,buffer,sizeof(buffer)-1) > 0)
|
||||
{
|
||||
char *p = strtok(buffer,"\n\r");
|
||||
close(fd);
|
||||
|
||||
5
backup.c
5
backup.c
@@ -197,7 +197,10 @@ static int keep_backup(char *fname)
|
||||
if (do_stat (fname, &st)) return 1;
|
||||
#endif
|
||||
|
||||
file = make_file (0, fname, 0);
|
||||
file = make_file(-1, fname, NULL, 1);
|
||||
|
||||
/* the file could have disappeared */
|
||||
if (!file) return 1;
|
||||
|
||||
/* make a complete pathname for backup file */
|
||||
if (strlen(backup_dir) + strlen(fname) > (MAXPATHLEN - 1)) {
|
||||
|
||||
@@ -38,6 +38,11 @@ int start_socket_client(char *host, char *path, int argc, char *argv[])
|
||||
extern int am_sender;
|
||||
extern struct in_addr socket_address;
|
||||
|
||||
if (argc == 0 && !am_sender) {
|
||||
extern int list_only;
|
||||
list_only = 1;
|
||||
}
|
||||
|
||||
if (*path == '/') {
|
||||
rprintf(FERROR,"ERROR: The remote path must start with a module name\n");
|
||||
return -1;
|
||||
|
||||
3
config.guess
vendored
3
config.guess
vendored
@@ -977,6 +977,9 @@ EOF
|
||||
*:QNX:*:4*)
|
||||
echo i386-qnx-qnx${UNAME_VERSION}
|
||||
exit 0 ;;
|
||||
*:"Mac OS":*:*)
|
||||
echo `uname -p`-apple-macos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
|
||||
@@ -4,15 +4,24 @@ AC_CONFIG_HEADER(config.h)
|
||||
|
||||
# compile with optimisation and without debugging by default
|
||||
CFLAGS=${CFLAGS-"-O"}
|
||||
LDFLAGS=${LDFLAGS-""}
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_VALIDATE_CACHE_SYSTEM_TYPE
|
||||
|
||||
# look for getconf early as this affects just about everything
|
||||
AC_CHECK_PROG(HAVE_GETCONF, getconf, 1, 0)
|
||||
if test $HAVE_GETCONF = 1; then
|
||||
CFLAGS=$CFLAGS" "`getconf LFS_CFLAGS`
|
||||
LDFLAGS=$LDFLAGS" "`getconf LFS_LDFLAGS`
|
||||
fi
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_SUBST(SHELL)
|
||||
|
||||
|
||||
AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
|
||||
AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH)
|
||||
|
||||
|
||||
@@ -222,6 +222,12 @@ void send_exclude_list(int f)
|
||||
{
|
||||
int i;
|
||||
extern int remote_version;
|
||||
extern int list_only, recurse;
|
||||
|
||||
/* this is a complete hack - blame Rusty */
|
||||
if (list_only && !recurse) {
|
||||
add_exclude("/*/*", 0);
|
||||
}
|
||||
|
||||
if (!exclude_list) {
|
||||
write_int(f,0);
|
||||
|
||||
33
flist.c
33
flist.c
@@ -55,7 +55,7 @@ static struct file_struct null_file;
|
||||
|
||||
static void clean_flist(struct file_list *flist, int strip_root);
|
||||
|
||||
struct string_area *string_area_new(int size)
|
||||
static struct string_area *string_area_new(int size)
|
||||
{
|
||||
struct string_area *a;
|
||||
|
||||
@@ -65,12 +65,12 @@ struct string_area *string_area_new(int size)
|
||||
a->current = a->base = malloc(size);
|
||||
if (!a->current) out_of_memory("string_area_new buffer");
|
||||
a->end = a->base + size;
|
||||
a->next = 0;
|
||||
a->next = NULL;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
void string_area_free(struct string_area *a)
|
||||
static void string_area_free(struct string_area *a)
|
||||
{
|
||||
struct string_area *next;
|
||||
|
||||
@@ -80,7 +80,7 @@ void string_area_free(struct string_area *a)
|
||||
}
|
||||
}
|
||||
|
||||
char *string_area_malloc(struct string_area **ap, int size)
|
||||
static char *string_area_malloc(struct string_area **ap, int size)
|
||||
{
|
||||
char *p;
|
||||
struct string_area *a;
|
||||
@@ -100,7 +100,7 @@ char *string_area_malloc(struct string_area **ap, int size)
|
||||
return p;
|
||||
}
|
||||
|
||||
char *string_area_strdup(struct string_area **ap, const char *src)
|
||||
static char *string_area_strdup(struct string_area **ap, const char *src)
|
||||
{
|
||||
char* dest = string_area_malloc(ap, strlen(src) + 1);
|
||||
return strcpy(dest, src);
|
||||
@@ -469,7 +469,8 @@ static int skip_filesystem(char *fname, STRUCT_STAT *st)
|
||||
#define MALLOC(ap, i) (ap ? string_area_malloc(ap, i) : malloc(i))
|
||||
|
||||
/* create a file_struct for a named file */
|
||||
struct file_struct *make_file(int f, char *fname, struct string_area **ap)
|
||||
struct file_struct *make_file(int f, char *fname, struct string_area **ap,
|
||||
int noexcludes)
|
||||
{
|
||||
struct file_struct *file;
|
||||
STRUCT_STAT st;
|
||||
@@ -478,6 +479,7 @@ struct file_struct *make_file(int f, char *fname, struct string_area **ap)
|
||||
char cleaned_name[MAXPATHLEN];
|
||||
char linkbuf[MAXPATHLEN];
|
||||
extern int delete_excluded;
|
||||
extern int module_id;
|
||||
|
||||
strlcpy(cleaned_name, fname, MAXPATHLEN);
|
||||
cleaned_name[MAXPATHLEN-1] = 0;
|
||||
@@ -496,6 +498,9 @@ struct file_struct *make_file(int f, char *fname, struct string_area **ap)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* we use noexcludes from backup.c */
|
||||
if (noexcludes) goto skip_excludes;
|
||||
|
||||
if (S_ISDIR(st.st_mode) && !recurse) {
|
||||
rprintf(FINFO,"skipping directory %s\n",fname);
|
||||
return NULL;
|
||||
@@ -509,7 +514,13 @@ struct file_struct *make_file(int f, char *fname, struct string_area **ap)
|
||||
/* f is set to -1 when calculating deletion file list */
|
||||
if (((f != -1) || !delete_excluded) && !match_file_name(fname,&st))
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
if (lp_ignore_nonreadable(module_id) && access(fname, R_OK) != 0)
|
||||
return NULL;
|
||||
|
||||
skip_excludes:
|
||||
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO,"make_file(%d,%s)\n",f,fname);
|
||||
|
||||
@@ -523,7 +534,7 @@ struct file_struct *make_file(int f, char *fname, struct string_area **ap)
|
||||
if (lastdir && strcmp(fname, lastdir)==0) {
|
||||
file->dirname = lastdir;
|
||||
} else {
|
||||
file->dirname = STRDUP(ap, fname);
|
||||
file->dirname = strdup(fname);
|
||||
lastdir = file->dirname;
|
||||
}
|
||||
file->basename = STRDUP(ap, p+1);
|
||||
@@ -568,7 +579,7 @@ struct file_struct *make_file(int f, char *fname, struct string_area **ap)
|
||||
if (lastdir && strcmp(lastdir, flist_dir)==0) {
|
||||
file->basedir = lastdir;
|
||||
} else {
|
||||
file->basedir = STRDUP(ap, flist_dir);
|
||||
file->basedir = strdup(flist_dir);
|
||||
lastdir = file->basedir;
|
||||
}
|
||||
} else {
|
||||
@@ -588,7 +599,7 @@ void send_file_name(int f,struct file_list *flist,char *fname,
|
||||
{
|
||||
struct file_struct *file;
|
||||
|
||||
file = make_file(f,fname, &flist->string_area);
|
||||
file = make_file(f,fname, &flist->string_area, 0);
|
||||
|
||||
if (!file) return;
|
||||
|
||||
@@ -1004,7 +1015,7 @@ struct file_list *flist_new()
|
||||
#if ARENA_SIZE > 0
|
||||
flist->string_area = string_area_new(0);
|
||||
#else
|
||||
flist->string_area = 0;
|
||||
flist->string_area = NULL;
|
||||
#endif
|
||||
return flist;
|
||||
}
|
||||
|
||||
15
generator.c
15
generator.c
@@ -35,6 +35,8 @@ extern int size_only;
|
||||
extern int io_timeout;
|
||||
extern int remote_version;
|
||||
extern int always_checksum;
|
||||
extern int modify_window;
|
||||
extern char *compare_dest;
|
||||
|
||||
|
||||
/* choose whether to skip a particular file */
|
||||
@@ -49,6 +51,15 @@ static int skip_file(char *fname,
|
||||
of the file time to determine whether to sync */
|
||||
if (always_checksum && S_ISREG(st->st_mode)) {
|
||||
char sum[MD4_SUM_LENGTH];
|
||||
char fnamecmpdest[MAXPATHLEN];
|
||||
|
||||
if (compare_dest != NULL) {
|
||||
if (access(fname, 0) != 0) {
|
||||
slprintf(fnamecmpdest,MAXPATHLEN,"%s/%s",
|
||||
compare_dest,fname);
|
||||
fname = fnamecmpdest;
|
||||
}
|
||||
}
|
||||
file_checksum(fname,sum,st->st_size);
|
||||
if (remote_version < 21) {
|
||||
return (memcmp(sum,file->sum,2) == 0);
|
||||
@@ -65,7 +76,7 @@ static int skip_file(char *fname,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (st->st_mtime == file->modtime);
|
||||
return (cmp_modtime(st->st_mtime,file->modtime) == 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +344,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
|
||||
return;
|
||||
}
|
||||
|
||||
if (update_only && st.st_mtime > file->modtime && fnamecmp == fname) {
|
||||
if (update_only && cmp_modtime(st.st_mtime,file->modtime)>0 && fnamecmp == fname) {
|
||||
if (verbose > 1)
|
||||
rprintf(FINFO,"%s is newer\n",fname);
|
||||
return;
|
||||
|
||||
29
io.c
29
io.c
@@ -39,16 +39,10 @@ extern int verbose;
|
||||
extern int io_timeout;
|
||||
extern struct stats stats;
|
||||
|
||||
static int buffer_f_in = -1;
|
||||
static int io_error_fd = -1;
|
||||
|
||||
static void read_loop(int fd, char *buf, int len);
|
||||
|
||||
void setup_readbuffer(int f_in)
|
||||
{
|
||||
buffer_f_in = f_in;
|
||||
}
|
||||
|
||||
static void check_timeout(void)
|
||||
{
|
||||
extern int am_server, am_daemon;
|
||||
@@ -323,11 +317,7 @@ unsigned char read_byte(int f)
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* write len bytes to fd, possibly reading from buffer_f_in if set
|
||||
in order to unclog the pipe. don't return until all len
|
||||
bytes have been written */
|
||||
/* write len bytes to fd */
|
||||
static void writefd_unbuffered(int fd,char *buf,int len)
|
||||
{
|
||||
int total = 0;
|
||||
@@ -382,6 +372,7 @@ static void writefd_unbuffered(int fd,char *buf,int len)
|
||||
|
||||
if (ret == -1 &&
|
||||
(errno == EWOULDBLOCK || errno == EAGAIN)) {
|
||||
msleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -473,6 +464,17 @@ void io_end_buffering(int fd)
|
||||
}
|
||||
}
|
||||
|
||||
/* some OSes have a bug where an exit causes the pending writes on
|
||||
a socket to be flushed. Do an explicit shutdown to try to prevent this */
|
||||
void io_shutdown(void)
|
||||
{
|
||||
if (multiplex_out_fd != -1) close(multiplex_out_fd);
|
||||
if (io_error_fd != -1) close(io_error_fd);
|
||||
multiplex_out_fd = -1;
|
||||
io_error_fd = -1;
|
||||
}
|
||||
|
||||
|
||||
static void writefd(int fd,char *buf,int len)
|
||||
{
|
||||
stats.total_written += len;
|
||||
@@ -623,8 +625,3 @@ void io_multiplexing_close(void)
|
||||
io_multiplexing_out = 0;
|
||||
}
|
||||
|
||||
void io_close_input(int fd)
|
||||
{
|
||||
buffer_f_in = -1;
|
||||
}
|
||||
|
||||
|
||||
10
loadparm.c
10
loadparm.c
@@ -77,8 +77,6 @@ struct parm_struct
|
||||
unsigned flags;
|
||||
};
|
||||
|
||||
static BOOL bLoaded = False;
|
||||
|
||||
#ifndef GLOBAL_NAME
|
||||
#define GLOBAL_NAME "global"
|
||||
#endif
|
||||
@@ -134,6 +132,7 @@ typedef struct
|
||||
char *dont_compress;
|
||||
int timeout;
|
||||
int max_connections;
|
||||
BOOL ignore_nonreadable;
|
||||
} service;
|
||||
|
||||
|
||||
@@ -164,7 +163,8 @@ static service sDefault =
|
||||
NULL, /* refuse options */
|
||||
"*.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz", /* dont compress */
|
||||
0, /* timeout */
|
||||
0 /* max connections */
|
||||
0, /* max connections */
|
||||
False /* ignore nonreadable */
|
||||
};
|
||||
|
||||
|
||||
@@ -262,6 +262,7 @@ static struct parm_struct parm_table[] =
|
||||
{"read only", P_BOOL, P_LOCAL, &sDefault.read_only, NULL, 0},
|
||||
{"list", P_BOOL, P_LOCAL, &sDefault.list, NULL, 0},
|
||||
{"use chroot", P_BOOL, P_LOCAL, &sDefault.use_chroot, NULL, 0},
|
||||
{"ignore nonreadable",P_BOOL, P_LOCAL, &sDefault.ignore_nonreadable, NULL, 0},
|
||||
{"uid", P_STRING, P_LOCAL, &sDefault.uid, NULL, 0},
|
||||
{"gid", P_STRING, P_LOCAL, &sDefault.gid, NULL, 0},
|
||||
{"hosts allow", P_STRING, P_LOCAL, &sDefault.hosts_allow, NULL, 0},
|
||||
@@ -340,6 +341,7 @@ FN_LOCAL_BOOL(lp_list, list)
|
||||
FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
|
||||
FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
|
||||
FN_LOCAL_BOOL(lp_ignore_errors, ignore_errors)
|
||||
FN_LOCAL_BOOL(lp_ignore_nonreadable, ignore_nonreadable)
|
||||
FN_LOCAL_STRING(lp_uid, uid)
|
||||
FN_LOCAL_STRING(lp_gid, gid)
|
||||
FN_LOCAL_STRING(lp_hosts_allow, hosts_allow)
|
||||
@@ -730,8 +732,6 @@ BOOL lp_load(char *pszFname, int globals_only)
|
||||
iServiceIndex = -1;
|
||||
bRetval = pm_process(n2, globals_only?NULL:do_section, do_parameter);
|
||||
|
||||
bLoaded = True;
|
||||
|
||||
return (bRetval);
|
||||
}
|
||||
|
||||
|
||||
29
main.c
29
main.c
@@ -25,6 +25,19 @@ struct stats stats;
|
||||
|
||||
extern int verbose;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
wait for a process to exit, calling io_flush while waiting
|
||||
****************************************************************************/
|
||||
void wait_process(pid_t pid, int *status)
|
||||
{
|
||||
while (waitpid(pid, status, WNOHANG) == 0) {
|
||||
msleep(20);
|
||||
io_flush();
|
||||
}
|
||||
*status = WEXITSTATUS(*status);
|
||||
}
|
||||
|
||||
static void report(int f)
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
@@ -336,14 +349,13 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
|
||||
close(recv_pipe[1]);
|
||||
io_flush();
|
||||
/* finally we go to sleep until our parent kills us
|
||||
with a USR2 signal. We sleepp for a short time as on
|
||||
with a USR2 signal. We sleep for a short time as on
|
||||
some OSes a signal won't interrupt a sleep! */
|
||||
while (1) sleep(1);
|
||||
while (1) msleep(20);
|
||||
}
|
||||
|
||||
close(recv_pipe[1]);
|
||||
close(error_pipe[1]);
|
||||
io_close_input(f_in);
|
||||
if (f_in != f_out) close(f_in);
|
||||
|
||||
io_start_buffering(f_out);
|
||||
@@ -452,7 +464,6 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
|
||||
int status = 0, status2 = 0;
|
||||
char *local_name = NULL;
|
||||
extern int am_sender;
|
||||
extern int list_only;
|
||||
extern int remote_version;
|
||||
|
||||
set_nonblocking(f_in);
|
||||
@@ -490,7 +501,10 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
|
||||
exit_cleanup(status);
|
||||
}
|
||||
|
||||
if (argc == 0) list_only = 1;
|
||||
if (argc == 0) {
|
||||
extern int list_only;
|
||||
list_only = 1;
|
||||
}
|
||||
|
||||
send_exclude_list(f_out);
|
||||
|
||||
@@ -628,6 +642,11 @@ static int start_client(int argc, char *argv[])
|
||||
usage(FERROR);
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
}
|
||||
|
||||
if (argc == 0 && !am_sender) {
|
||||
extern int list_only;
|
||||
list_only = 1;
|
||||
}
|
||||
|
||||
pid = do_cmd(shell_cmd,shell_machine,shell_user,shell_path,&f_in,&f_out);
|
||||
|
||||
|
||||
34
options.c
34
options.c
@@ -67,6 +67,11 @@ int delete_after=0;
|
||||
int only_existing=0;
|
||||
int max_delete=0;
|
||||
int ignore_errors=0;
|
||||
#ifdef _WIN32
|
||||
int modify_window=2;
|
||||
#else
|
||||
int modify_window=0;
|
||||
#endif
|
||||
int blocking_io=0;
|
||||
|
||||
char *backup_suffix = BACKUP_SUFFIX;
|
||||
@@ -85,6 +90,9 @@ int quiet = 0;
|
||||
int always_checksum = 0;
|
||||
int list_only = 0;
|
||||
|
||||
static int modify_window_set;
|
||||
|
||||
|
||||
struct in_addr socket_address = {INADDR_ANY};
|
||||
|
||||
void usage(enum logcode F)
|
||||
@@ -144,6 +152,7 @@ void usage(enum logcode F)
|
||||
rprintf(F," --timeout=TIME set IO timeout in seconds\n");
|
||||
rprintf(F," -I, --ignore-times don't exclude files that match length and time\n");
|
||||
rprintf(F," --size-only only use file size when determining if a file should be transferred\n");
|
||||
rprintf(F," --modify-window=NUM Timestamp window (seconds) for file match (default=%d)\n",modify_window);
|
||||
rprintf(F," -T --temp-dir=DIR create temporary files in directory DIR\n");
|
||||
rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n");
|
||||
rprintf(F," -P equivalent to --partial --progress\n");
|
||||
@@ -178,7 +187,8 @@ enum {OPT_VERSION, OPT_SUFFIX, OPT_SENDER, OPT_SERVER, OPT_EXCLUDE,
|
||||
OPT_COPY_UNSAFE_LINKS, OPT_SAFE_LINKS, OPT_COMPARE_DEST,
|
||||
OPT_LOG_FORMAT, OPT_PASSWORD_FILE, OPT_SIZE_ONLY, OPT_ADDRESS,
|
||||
OPT_DELETE_AFTER, OPT_EXISTING, OPT_MAX_DELETE, OPT_BACKUP_DIR,
|
||||
OPT_IGNORE_ERRORS, OPT_BWLIMIT, OPT_BLOCKING_IO};
|
||||
OPT_IGNORE_ERRORS, OPT_BWLIMIT, OPT_BLOCKING_IO,
|
||||
OPT_MODIFY_WINDOW};
|
||||
|
||||
static char *short_options = "oblLWHpguDCtcahvqrRIxnSe:B:T:zP";
|
||||
|
||||
@@ -200,6 +210,7 @@ static struct option long_options[] = {
|
||||
{"one-file-system",0, 0, 'x'},
|
||||
{"ignore-times",0, 0, 'I'},
|
||||
{"size-only", 0, 0, OPT_SIZE_ONLY},
|
||||
{"modify-window",1, 0, OPT_MODIFY_WINDOW},
|
||||
{"help", 0, 0, 'h'},
|
||||
{"dry-run", 0, 0, 'n'},
|
||||
{"sparse", 0, 0, 'S'},
|
||||
@@ -331,6 +342,11 @@ int parse_arguments(int argc, char *argv[], int frommain)
|
||||
size_only = 1;
|
||||
break;
|
||||
|
||||
case OPT_MODIFY_WINDOW:
|
||||
modify_window = atoi(optarg);
|
||||
modify_window_set = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
one_file_system=1;
|
||||
break;
|
||||
@@ -598,6 +614,7 @@ void server_options(char **args,int *argc)
|
||||
static char bsize[30];
|
||||
static char iotime[30];
|
||||
static char mdelete[30];
|
||||
static char mwindow[30];
|
||||
static char bw[50];
|
||||
|
||||
int i, x;
|
||||
@@ -611,6 +628,7 @@ void server_options(char **args,int *argc)
|
||||
argstr[0] = '-';
|
||||
for (i=0;i<verbose;i++)
|
||||
argstr[x++] = 'v';
|
||||
|
||||
/* the -q option is intentionally left out */
|
||||
if (make_backups)
|
||||
argstr[x++] = 'b';
|
||||
@@ -652,6 +670,14 @@ void server_options(char **args,int *argc)
|
||||
argstr[x++] = 'S';
|
||||
if (do_compression)
|
||||
argstr[x++] = 'z';
|
||||
|
||||
/* this is a complete hack - blame Rusty
|
||||
|
||||
this is a hack to make the list_only (remote file list)
|
||||
more useful */
|
||||
if (list_only && !recurse)
|
||||
argstr[x++] = 'r';
|
||||
|
||||
argstr[x] = 0;
|
||||
|
||||
if (x != 1) args[ac++] = argstr;
|
||||
@@ -690,6 +716,12 @@ void server_options(char **args,int *argc)
|
||||
if (size_only)
|
||||
args[ac++] = "--size-only";
|
||||
|
||||
if (modify_window_set) {
|
||||
slprintf(mwindow,sizeof(mwindow),"--modify-window=%d",
|
||||
modify_window);
|
||||
args[ac++] = mwindow;
|
||||
}
|
||||
|
||||
if (keep_partial)
|
||||
args[ac++] = "--partial";
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
Summary: Program for efficient remote updates of files.
|
||||
Name: rsync
|
||||
Version: 2.4.4
|
||||
Version: 2.4.6
|
||||
Release: 1
|
||||
Copyright: GPL
|
||||
Group: Applications/Networking
|
||||
Source: ftp://samba.anu.edu.au/pub/rsync/rsync-2.4.4.tar.gz
|
||||
Source: ftp://samba.anu.edu.au/pub/rsync/rsync-2.4.6.tar.gz
|
||||
URL: http://samba.anu.edu.au/rsync/
|
||||
Packager: Andrew Tridgell <tridge@samba.anu.edu.au>
|
||||
BuildRoot: /tmp/rsync
|
||||
|
||||
5
rsync.c
5
rsync.c
@@ -43,7 +43,7 @@ void free_sums(struct sum_struct *s)
|
||||
|
||||
|
||||
/*
|
||||
* delete a file or directory. If force_delet is set then delete
|
||||
* delete a file or directory. If force_delete is set then delete
|
||||
* recursively
|
||||
*/
|
||||
int delete_file(char *fname)
|
||||
@@ -62,7 +62,6 @@ int delete_file(char *fname)
|
||||
ret = do_stat(fname, &st);
|
||||
#endif
|
||||
if (ret) {
|
||||
rprintf(FERROR,"stat(%s) : %s\n", fname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -163,7 +162,7 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
|
||||
}
|
||||
|
||||
if (preserve_times && !S_ISLNK(st->st_mode) &&
|
||||
st->st_mtime != file->modtime) {
|
||||
cmp_modtime(st->st_mtime, file->modtime) != 0) {
|
||||
/* don't complain about not setting times on directories
|
||||
because some filesystems can't do it */
|
||||
if (set_modtime(fname,file->modtime) != 0 &&
|
||||
|
||||
4
rsync.h
4
rsync.h
@@ -510,4 +510,8 @@ size_t strlcpy(char *d, const char *s, size_t bufsize);
|
||||
size_t strlcat(char *d, const char *s, size_t bufsize);
|
||||
#endif
|
||||
|
||||
#ifndef WEXITSTATUS
|
||||
#define WEXITSTATUS(stat) ((int)(((stat)>>8)&0xFF))
|
||||
#endif
|
||||
|
||||
#define exit_cleanup(code) _exit_cleanup(code, __FILE__, __LINE__)
|
||||
|
||||
16
rsync.yo
16
rsync.yo
@@ -223,7 +223,7 @@ verb(
|
||||
-r, --recursive recurse into directories
|
||||
-R, --relative use relative path names
|
||||
-b, --backup make backups (default ~ suffix)
|
||||
--backup-dir=DIR put backups in the specified directory
|
||||
--backup-dir make backups into this directory
|
||||
--suffix=SUFFIX override backup suffix
|
||||
-u, --update update only (don't overwrite newer files)
|
||||
-l, --links preserve soft links
|
||||
@@ -256,6 +256,7 @@ verb(
|
||||
--timeout=TIME set IO timeout in seconds
|
||||
-I, --ignore-times don't exclude files that match length and time
|
||||
--size-only only use file size when determining if a file should be transferred
|
||||
--modify-window=NUM Timestamp window (seconds) for file match (default=0)
|
||||
-T --temp-dir=DIR create temporary files in directory DIR
|
||||
--compare-dest=DIR also compare destination files relative to DIR
|
||||
-P equivalent to --partial --progress
|
||||
@@ -316,6 +317,13 @@ regardless of timestamp. This is useful when starting to use rsync
|
||||
after using another mirroring system which may not preserve timestamps
|
||||
exactly.
|
||||
|
||||
dit(bf(--modify-window)) When comparing two timestamps rsync treats
|
||||
the timestamps as being equal if they are within the value of
|
||||
modify_window. This is normally zero, but you may find it useful to
|
||||
set this to a larger value in some situations. In particular, when
|
||||
transferring to/from FAT filesystems which cannot represent times with
|
||||
a 1 second resolution this option is useful.
|
||||
|
||||
dit(bf(-c, --checksum)) This forces the sender to checksum all files using
|
||||
a 128-bit MD4 checksum before transfer. The checksum is then
|
||||
explicitly checked on the receiver and any files of the same name
|
||||
@@ -497,9 +505,9 @@ See the section on exclude patterns for information on the syntax of
|
||||
this option.
|
||||
|
||||
dit(bf(--exclude-from=FILE)) This option is similar to the --exclude
|
||||
option, but instead it adds all filenames listed in the file FILE to
|
||||
the exclude list. Blank lines in FILE and lines starting with ';' or '#'
|
||||
are ignored.
|
||||
option, but instead it adds all exclude patterns listed in the file
|
||||
FILE to the exclude list. Blank lines in FILE and lines starting with
|
||||
';' or '#' are ignored.
|
||||
|
||||
dit(bf(--include=PATTERN)) This option tells rsync to not exclude the
|
||||
specified pattern of filenames. This is useful as it allows you to
|
||||
|
||||
@@ -285,6 +285,11 @@ to a temporary resource shortage or other IO error. In some cases this
|
||||
test is counter productive so you can use this option to turn off this
|
||||
behaviour.
|
||||
|
||||
dit(bf(ignore nonreadable)) This tells the rsync server to completely
|
||||
ignore files that are not readable by the user. This is useful for
|
||||
public archives that may have some non-readable files among the
|
||||
directories, and the sysadmin doesn't want those files to be seen at all.
|
||||
|
||||
dit(bf(transfer logging)) The "transfer logging" option enables per-file
|
||||
logging of downloads and uploads in a format somewhat similar to that
|
||||
used by ftp daemons. If you want to customize the log formats look at
|
||||
|
||||
2
sender.c
2
sender.c
@@ -97,8 +97,6 @@ void send_files(struct file_list *flist,int f_out,int f_in)
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO,"send_files starting\n");
|
||||
|
||||
setup_readbuffer(f_in);
|
||||
|
||||
while (1) {
|
||||
int offset=0;
|
||||
|
||||
|
||||
52
util.c
52
util.c
@@ -930,20 +930,52 @@ char *timestring(time_t t)
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
like waitpid but does the WEXITSTATUS
|
||||
****************************************************************************/
|
||||
#ifndef WEXITSTATUS
|
||||
#define WEXITSTATUS(stat) ((int)(((stat)>>8)&0xFF))
|
||||
#endif
|
||||
void wait_process(pid_t pid, int *status)
|
||||
/*******************************************************************
|
||||
sleep for a specified number of milliseconds
|
||||
********************************************************************/
|
||||
void msleep(int t)
|
||||
{
|
||||
waitpid(pid, status, 0);
|
||||
*status = WEXITSTATUS(*status);
|
||||
int tdiff=0;
|
||||
struct timeval tval,t1,t2;
|
||||
|
||||
gettimeofday(&t1, NULL);
|
||||
gettimeofday(&t2, NULL);
|
||||
|
||||
while (tdiff < t) {
|
||||
tval.tv_sec = (t-tdiff)/1000;
|
||||
tval.tv_usec = 1000*((t-tdiff)%1000);
|
||||
|
||||
errno = 0;
|
||||
select(0,NULL,NULL, NULL, &tval);
|
||||
|
||||
gettimeofday(&t2, NULL);
|
||||
tdiff = (t2.tv_sec - t1.tv_sec)*1000 +
|
||||
(t2.tv_usec - t1.tv_usec)/1000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef __INSURE__
|
||||
/*******************************************************************
|
||||
Determine if two file modification times are equivalent (either exact
|
||||
or in the modification timestamp window established by --modify-window)
|
||||
Returns 0 if the times should be treated as the same, 1 if the
|
||||
first is later and -1 if the 2nd is later
|
||||
*******************************************************************/
|
||||
int cmp_modtime(time_t file1, time_t file2)
|
||||
{
|
||||
time_t diff;
|
||||
extern int modify_window;
|
||||
|
||||
if (file2 > file1) {
|
||||
if (file2 - file1 <= modify_window) return 0;
|
||||
return -1;
|
||||
}
|
||||
if (file1 - file2 <= modify_window) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __INSURE__XX
|
||||
#include <dlfcn.h>
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
Reference in New Issue
Block a user