Here is a brief description of available options:
+Options:
-v, --verbose increase verbosity
-c, --checksum always checksum
-a, --archive archive mode (same as -rlptDog)
-b, --backup make backups (default ~ extension)
-u, --update update only (don't overwrite newer files)
-l, --links preserve soft links
+-L, --copy-links treat soft links like regular files
-H, --hard-links preserve hard links
-p, --perms preserve permissions
-o, --owner preserve owner (root only)
-t, --times preserve times
-S, --sparse handle sparse files efficiently
-n, --dry-run show what would have been transferred
+-W, --whole-file copy whole files, no incremental checks
-x, --one-file-system don't cross filesystem boundaries
-B, --block-size SIZE checksum blocking size
-e, --rsh COMMAND specify rsh replacement
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_UTIME_NULL
+AC_FUNC_SETPGRP
+AC_FUNC_GETPGRP
AC_CHECK_FUNCS(waitpid strtok pipe getcwd mkdir strdup strerror chown chmod mknod)
AC_CHECK_FUNCS(fchmod fstat strchr bcopy bzero readlink link utime utimes)
AC_CHECK_FUNCS(memmove getopt_long lchown setlinebuf)
extern int preserve_gid;
extern int preserve_times;
extern int relative_paths;
+extern int copy_links;
static char **local_exclude_list = NULL;
static void clean_fname(char *name);
+int link_stat(const char *Path, struct stat *Buffer)
+{
+#if SUPPORT_LINKS
+ if (copy_links) {
+ return stat(Path, Buffer);
+ } else {
+ return lstat(Path, Buffer);
+ }
+#else
+ return stat(Path, Buffer);
+#endif
+}
+
/*
This function is used to check if a file should be included/excluded
from the list of files based on its name and type etc
static void set_filesystem(char *fname)
{
struct stat st;
- if (lstat(fname,&st) != 0) return;
+ if (link_stat(fname,&st) != 0) return;
filesystem_dev = st.st_dev;
}
bzero(sum,SUM_LENGTH);
- if (lstat(fname,&st) != 0) {
+ if (link_stat(fname,&st) != 0) {
fprintf(FERROR,"%s: %s\n",
fname,strerror(errno));
return NULL;
strcat(fname,".");
}
- if (lstat(fname,&st) != 0) {
+ if (link_stat(fname,&st) != 0) {
fprintf(FERROR,"%s : %s\n",fname,strerror(errno));
continue;
}
hlink_list[i].inode == hlink_list[i-1].inode) {
struct stat st1,st2;
- if (lstat(hlink_list[i-1].name,&st1) != 0) continue;
- if (lstat(hlink_list[i].name,&st2) != 0) {
+ if (link_stat(hlink_list[i-1].name,&st1) != 0) continue;
+ if (link_stat(hlink_list[i].name,&st2) != 0) {
if (!dry_run && link(hlink_list[i-1].name,hlink_list[i].name) != 0) {
if (verbose > 0)
fprintf(FINFO,"link %s => %s : %s\n",
static char *rsync_path = RSYNC_NAME;
int make_backups = 0;
+int whole_file = 0;
+int copy_links = 0;
int preserve_links = 0;
int preserve_hard_links = 0;
int preserve_perms = 0;
argstr[x++] = 'n';
if (preserve_links)
argstr[x++] = 'l';
+ if (copy_links)
+ argstr[x++] = 'L';
+ if (whole_file)
+ argstr[x++] = 'W';
if (preserve_hard_links)
argstr[x++] = 'H';
if (preserve_uid)
int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out)
{
char *args[100];
- int i,argc=0;
- char *tok,*p;
+ int i,argc=0, ret;
+ char *tok,*p,*dir=NULL;
if (!local_server) {
if (!cmd)
server_options(args,&argc);
if (path && *path) {
- char *dir = strdup(path);
+ dir = strdup(path);
p = strrchr(dir,'/');
if (p && !relative_paths) {
*p = 0;
fprintf(FERROR,"\n");
}
- return piped_child(args,f_in,f_out);
+ ret = piped_child(args,f_in,f_out);
+ if (dir) free(dir);
+
+ return ret;
oom:
out_of_memory("do_cmd");
fprintf(f,"-b, --backup make backups (default ~ extension)\n");
fprintf(f,"-u, --update update only (don't overwrite newer files)\n");
fprintf(f,"-l, --links preserve soft links\n");
+ fprintf(f,"-L, --copy-links treat soft links like regular files\n");
fprintf(f,"-H, --hard-links preserve hard links\n");
fprintf(f,"-p, --perms preserve permissions\n");
fprintf(f,"-o, --owner preserve owner (root only)\n");
fprintf(f,"-t, --times preserve times\n");
fprintf(f,"-S, --sparse handle sparse files efficiently\n");
fprintf(f,"-n, --dry-run show what would have been transferred\n");
+ fprintf(f,"-W, --whole-file copy whole files, no incremental checks\n");
fprintf(f,"-x, --one-file-system don't cross filesystem boundaries\n");
fprintf(f,"-B, --block-size SIZE checksum blocking size\n");
fprintf(f,"-e, --rsh COMMAND specify rsh replacement\n");
enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
OPT_EXCLUDE_FROM,OPT_DELETE,OPT_RSYNC_PATH};
-static char *short_options = "oblHpguDCtcahvrRIxnSe:B:z";
+static char *short_options = "oblLWHpguDCtcahvrRIxnSe:B:z";
static struct option long_options[] = {
{"version", 0, 0, OPT_VERSION},
{"devices", 0, 0, 'D'},
{"perms", 0, 0, 'p'},
{"links", 0, 0, 'l'},
+ {"copy-links", 0, 0, 'L'},
+ {"whole-file", 0, 0, 'W'},
{"hard-links", 0, 0, 'H'},
{"owner", 0, 0, 'o'},
{"group", 0, 0, 'g'},
{"compress", 0, 0, 'z'},
{0,0,0,0}};
+RETSIGTYPE sigusr1_handler(int val) {
+ exit_cleanup(1);
+}
+
int main(int argc,char *argv[])
{
int pid, status = 0, status2 = 0;
struct file_list *flist;
char *local_name = NULL;
+#ifdef SETPGRP_VOID
+ setpgrp();
+#else
+ setpgrp(0,0);
+#endif
+ signal(SIGUSR1, sigusr1_handler);
+
starttime = time(NULL);
am_root = (getuid() == 0);
preserve_links=1;
break;
+ case 'L':
+ copy_links=1;
+ break;
+
+ case 'W':
+ whole_file=1;
+ break;
+
case 'H':
#if SUPPORT_HARD_LINKS
preserve_hard_links=1;
return status | status2;
}
+
extern char *backup_suffix;
+extern int whole_file;
extern int block_size;
extern int update_only;
extern int make_backups;
if (dry_run) return 0;
if (!st) {
- if (lstat(fname,&st2) != 0) {
+ if (link_stat(fname,&st2) != 0) {
fprintf(FERROR,"stat %s : %s\n",fname,strerror(errno));
return 0;
}
if (verbose > 2)
fprintf(FERROR,"recv_generator(%s,%d)\n",fname,i);
- statret = lstat(fname,&st);
+ statret = link_stat(fname,&st);
if (S_ISDIR(file->mode)) {
if (dry_run) return;
return;
}
+ if (whole_file) {
+ write_int(f_out,i);
+ send_sums(NULL,f_out);
+ return;
+ }
+
/* open the file */
fd = open(fname,O_RDONLY);
static void delete_files(struct file_list *flist)
{
struct file_list *local_file_list;
- char *dot=".";
int i, j;
char *last_name=NULL;
void exit_cleanup(int code)
{
- if (cleanup_fname)
- unlink(cleanup_fname);
- exit(code);
+ if (cleanup_fname)
+ unlink(cleanup_fname);
+ signal(SIGUSR1, SIG_IGN);
+ if (code) {
+#ifdef GETPGRP_VOID
+ kill(-getpgrp(), SIGUSR1);
+#else
+ kill(-getpgrp(getpid()), SIGUSR1);
+#endif
+ }
+ exit(code);
}
void sig_int(void)
#define SUPPORT_LINKS HAVE_READLINK
#define SUPPORT_HARD_LINKS HAVE_LINK
-#if !SUPPORT_LINKS
-#define lstat stat
-#endif
-
#ifndef HAVE_LCHOWN
#define lchown chown
#endif