Compare commits

...

10 Commits

Author SHA1 Message Date
rsync-bugs
b73c59a2c4 preparing for release of 1.6.8 1997-12-28 22:28:21 +00:00
Andrew Tridgell
f3644f1f2d - added a debug message
- rebuilt prototypes
1997-12-28 22:26:51 +00:00
Andrew Tridgell
e3cd198f8e - fixed spelling errors in man page
- fixed bug in hard link handling that could lead to spurious hard
links.
- fixed bug in the string handling in flist.c
1997-12-28 22:13:40 +00:00
Andrew Tridgell
5c36219d40 following a report of problems with Linux/alpha I've changed zlib.c to
use uint32 instead of "long" in several places. Apparently this fixes
things on the alpha. The strange thing is that my own tests on a
OSF/alpha box and a 64 bit IRIX box showed no problems. I wonder what
was actually going wrong? I'll email the zlib maintainers and let them
know.
1997-12-18 11:18:32 +00:00
Andrew Tridgell
f0e5517fb8 added a new mirror site to the README 1997-12-18 11:13:27 +00:00
rsync-bugs
18463a5a5a preparing for release of 1.6.7 1997-12-17 11:19:01 +00:00
Andrew Tridgell
82306bf6d6 *** empty log message *** 1997-12-17 11:07:17 +00:00
Andrew Tridgell
cbbe489208 handle things more grecefully when one machine supports hard links and
the other doesn't or one machine supports soft links and the other
doesn't.
1997-12-16 23:09:22 +00:00
Andrew Tridgell
6dd1782c42 - check for setlinebuf() in autoconf. Apparently HPUX doesn't have it
- use @exec_prefix@ and @prefix@ in more useful ways in Makefile.in
1997-12-16 22:39:55 +00:00
Andrew Tridgell
fee64929a3 fixed a bug in the handling of the new --relative option. The file was
being opened twice but closed once. The process eventually died with
an out of file descriptors error.
1997-12-16 20:29:35 +00:00
11 changed files with 132 additions and 57 deletions

View File

@@ -1,8 +1,10 @@
# Makefile for rsync. This is processed by configure to produce the final
# Makefile
INSTALL_BIN=@prefix@/bin
INSTALL_MAN=@prefix@/man
prefix=@prefix@
exec_prefix=@exec_prefix@
INSTALL_BIN=$(exec_prefix)/bin
INSTALL_MAN=$(prefix)/man
LIBS=@LIBS@
CC=@CC@

4
README
View File

@@ -22,6 +22,7 @@ Basically you use rsync just like rcp, but rsync has many additional options.
Here is a brief description of available options:
Options:
-v, --verbose increase verbosity
-c, --checksum always checksum
-a, --archive archive mode (same as -rlptDog)
@@ -30,6 +31,7 @@ Here is a brief description of available options:
-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)
@@ -38,6 +40,7 @@ Here is a brief description of available options:
-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
@@ -131,3 +134,4 @@ Mirrors are available at:
ftp://sunsite.auc.dk/pub/unix/rsync
ftp://ftp.sunet.se/pub/unix/admin/rsync
ftp://ftp.fu-berlin.de/pub/unix/network/rsync/

View File

@@ -40,9 +40,11 @@ echo no)
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)
AC_CHECK_FUNCS(memmove getopt_long lchown setlinebuf)
echo $ac_n "checking for working fnmatch... $ac_c"
AC_TRY_RUN([#include <fnmatch.h>

31
flist.c
View File

@@ -42,12 +42,26 @@ extern int preserve_uid;
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
@@ -68,7 +82,7 @@ static dev_t filesystem_dev;
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;
}
@@ -187,7 +201,7 @@ void receive_file_entry_v11(struct file_struct *file,
bzero((char *)file,sizeof(*file));
file->name = (char *)malloc(l1+l2+1);
if (!file->name) out_of_memory("receive_file_entry");
if (!file->name) out_of_memory("receive_file_entry 1");
strncpy(file->name,lastname,l1);
read_buf(f,file->name+l1,l2);
@@ -203,15 +217,13 @@ void receive_file_entry_v11(struct file_struct *file,
if (preserve_devices && IS_DEVICE(file->mode))
file->rdev = (flags & SAME_RDEV) ? last_rdev : (dev_t)read_int(f);
#if SUPPORT_LINKS
if (preserve_links && S_ISLNK(file->mode)) {
int l = read_int(f);
file->link = (char *)malloc(l+1);
if (!file->link) out_of_memory("receive_file_entry");
if (!file->link) out_of_memory("receive_file_entry 2");
read_buf(f,file->link,l);
file->link[l] = 0;
}
#endif
#if SUPPORT_HARD_LINKS
if (preserve_hard_links && S_ISREG(file->mode)) {
@@ -243,7 +255,7 @@ static struct file_struct *make_file(char *fname)
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;
@@ -418,7 +430,7 @@ struct file_list *send_file_list(int f,int argc,char *argv[])
strcat(fname,".");
}
if (lstat(fname,&st) != 0) {
if (link_stat(fname,&st) != 0) {
fprintf(FERROR,"%s : %s\n",fname,strerror(errno));
continue;
}
@@ -622,10 +634,9 @@ static void clean_fname(char *name)
if (strncmp(p=name,"./",2) == 0) {
modified = 1;
while (*p) {
do {
p[0] = p[2];
p++;
}
} while (*p++);
}
l = strlen(p=name);

18
hlink.c
View File

@@ -73,12 +73,12 @@ int check_hard_link(struct file_struct *file)
{
#if SUPPORT_HARD_LINKS
int low=0,high=hlink_count-1;
int mid=0,ret=0;
int ret=0;
if (!hlink_list || !S_ISREG(file->mode)) return 0;
while (low != high) {
mid = (low+high)/2;
int mid = (low+high)/2;
ret = hlink_compare(&hlink_list[mid],file);
if (ret == 0) break;
if (ret > 0)
@@ -87,12 +87,12 @@ int check_hard_link(struct file_struct *file)
low=mid+1;
}
if (hlink_compare(&hlink_list[mid],file) != 0) return 0;
if (hlink_compare(&hlink_list[low],file) != 0) return 0;
if (mid > 0 &&
S_ISREG(hlink_list[mid-1].mode) &&
file->dev == hlink_list[mid-1].dev &&
file->inode == hlink_list[mid-1].inode)
if (low > 0 &&
S_ISREG(hlink_list[low-1].mode) &&
file->dev == hlink_list[low-1].dev &&
file->inode == hlink_list[low-1].inode)
return 1;
#endif
@@ -116,8 +116,8 @@ void do_hard_links(struct file_list *flist)
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",

View File

@@ -252,7 +252,7 @@ typedef struct deflate_state {
* hash_shift * MIN_MATCH >= hash_bits
*/
long block_start;
Long block_start;
/* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards.
*/
@@ -1122,7 +1122,7 @@ local void fill_window(s)
s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) wsize;
s->block_start -= (Long) wsize;
/* Slide the hash table (could be avoided with 32 bit values
at the expense of memory usage):
@@ -1187,7 +1187,7 @@ local void fill_window(s)
#define FLUSH_BLOCK_ONLY(s, flush) { \
ct_flush_block(s, (s->block_start >= 0L ? \
(charf *)&s->window[(unsigned)s->block_start] : \
(charf *)Z_NULL), (long)s->strstart - s->block_start, (flush)); \
(charf *)Z_NULL), (Long)s->strstart - s->block_start, (flush)); \
s->block_start = s->strstart; \
flush_pending(s->strm); \
Tracev((stderr,"[FLUSH]")); \
@@ -1907,8 +1907,8 @@ local void gen_bitlen(s, desc)
if (m > max_code) continue;
if (tree[m].Len != (unsigned) bits) {
Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
s->opt_len += ((long)bits - (long)tree[m].Len)
*(long)tree[m].Freq;
s->opt_len += ((Long)bits - (Long)tree[m].Len)
*(Long)tree[m].Freq;
tree[m].Len = (ush)bits;
}
n--;
@@ -4578,8 +4578,8 @@ uLong adler32(adler, buf, len)
Bytef *buf;
uInt len;
{
unsigned long s1 = adler & 0xffff;
unsigned long s2 = (adler >> 16) & 0xffff;
uLong s1 = adler & 0xffff;
uLong s2 = (adler >> 16) & 0xffff;
int k;
if (buf == Z_NULL) return 1L;

View File

@@ -112,7 +112,8 @@
typedef unsigned char Byte; /* 8 bits */
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
typedef int32 Long; /* 32 bits or more */
typedef uint32 uLong; /* 32 bits or more */
typedef Byte FAR Bytef;
typedef char FAR charf;

59
main.c
View File

@@ -30,6 +30,8 @@ char *backup_suffix = BACKUP_SUFFIX;
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;
@@ -115,6 +117,10 @@ static void server_options(char **args,int *argc)
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)
@@ -160,11 +166,11 @@ static void server_options(char **args,int *argc)
int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out)
static 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)
@@ -200,7 +206,7 @@ int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out)
server_options(args,&argc);
if (path && *path) {
char *dir = strdup(path);
dir = strdup(path);
p = strrchr(dir,'/');
if (p && !relative_paths) {
*p = 0;
@@ -226,7 +232,10 @@ int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out)
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");
@@ -404,6 +413,7 @@ static void usage(FILE *f)
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");
@@ -412,6 +422,7 @@ static void usage(FILE *f)
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");
@@ -433,7 +444,7 @@ static void usage(FILE *f)
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},
@@ -459,6 +470,8 @@ static struct option long_options[] = {
{"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'},
@@ -469,6 +482,10 @@ static struct option long_options[] = {
{"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;
@@ -483,6 +500,13 @@ int main(int argc,char *argv[])
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);
@@ -553,14 +577,23 @@ int main(int argc,char *argv[])
break;
case 'l':
#if SUPPORT_LINKS
preserve_links=1;
#endif
break;
case 'L':
copy_links=1;
break;
case 'W':
whole_file=1;
break;
case 'H':
#if SUPPORT_HARD_LINKS
preserve_hard_links=1;
#else
fprintf(FERROR,"ERROR: hard links not supported on this platform\n");
exit_cleanup(1);
#endif
break;
@@ -657,6 +690,13 @@ int main(int argc,char *argv[])
if (dry_run)
verbose = MAX(verbose,1);
#ifndef SUPPORT_LINKS
if (!am_server && preserve_links) {
fprintf(FERROR,"ERROR: symbolic links not supported\n");
exit_cleanup(1);
}
#endif
if (am_server) {
setup_protocol(STDOUT_FILENO,STDIN_FILENO);
@@ -730,8 +770,10 @@ int main(int argc,char *argv[])
setup_protocol(f_out,f_in);
#if HAVE_SETLINEBUF
setlinebuf(FINFO);
setlinebuf(FERROR);
#endif
if (verbose > 3)
fprintf(FERROR,"parent=%d child=%d sender=%d recurse=%d\n",
@@ -771,3 +813,4 @@ int main(int argc,char *argv[])
return status | status2;
}

35
rsync.c
View File

@@ -30,6 +30,7 @@ extern int remote_version;
extern char *backup_suffix;
extern int whole_file;
extern int block_size;
extern int update_only;
extern int make_backups;
@@ -200,7 +201,7 @@ static int set_perms(char *fname,struct file_struct *file,struct stat *st,
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;
}
@@ -264,7 +265,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
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;
@@ -288,8 +289,8 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
return;
}
#if SUPPORT_LINKS
if (preserve_links && S_ISLNK(file->mode)) {
#if SUPPORT_LINKS
char lnk[MAXPATHLEN];
int l;
if (statret == 0) {
@@ -312,9 +313,9 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
fprintf(FINFO,"%s -> %s\n",
fname,file->link);
}
#endif
return;
}
#endif
#ifdef HAVE_MKNOD
if (am_root && preserve_devices && IS_DEVICE(file->mode)) {
@@ -404,11 +405,18 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
return;
}
if (whole_file) {
write_int(f_out,i);
send_sums(NULL,f_out);
return;
}
/* open the file */
fd = open(fname,O_RDONLY);
if (fd == -1) {
fprintf(FERROR,"failed to open %s : %s\n",fname,strerror(errno));
fprintf(FERROR,"skipping %s\n",fname);
return;
}
@@ -533,7 +541,6 @@ static void delete_one(struct file_struct *f)
static void delete_files(struct file_list *flist)
{
struct file_list *local_file_list;
char *dot=".";
int i, j;
char *last_name=NULL;
@@ -566,9 +573,17 @@ static char *cleanup_fname = 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)
@@ -656,6 +671,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
/* open tmp file */
if (strlen(fname) > (MAXPATHLEN-8)) {
fprintf(FERROR,"filename too long\n");
close(fd1);
continue;
}
sprintf(fnametmp,"%s.XXXXXX",fname);
@@ -667,7 +683,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
continue;
}
fd2 = open(fnametmp,O_WRONLY|O_CREAT,file->mode);
if (relative_paths && errno == ENOENT &&
if (fd2 == -1 && relative_paths && errno == ENOENT &&
create_directory_path(fnametmp) == 0) {
fd2 = open(fnametmp,O_WRONLY|O_CREAT,file->mode);
}
@@ -817,6 +833,7 @@ off_t send_files(struct file_list *flist,int f_out,int f_in)
/* map the local file */
if (fstat(fd,&st) != 0) {
fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
close(fd);
return -1;
}

13
rsync.h
View File

@@ -163,6 +163,9 @@
#include "lib/getopt.h"
#endif
#ifndef S_IFLNK
#define S_IFLNK 0120000
#endif
#ifndef S_ISLNK
#define S_ISLNK(mode) (((mode) & S_IFLNK) == S_IFLNK)
@@ -287,17 +290,9 @@ extern int errno;
#define bzero(buf,n) memset(buf,0,n)
#endif
#define SUPPORT_LINKS (HAVE_READLINK && defined(S_ISLNK))
#define SUPPORT_LINKS HAVE_READLINK
#define SUPPORT_HARD_LINKS HAVE_LINK
#ifndef S_ISLNK
#define S_ISLNK(x) 0
#endif
#if !SUPPORT_LINKS
#define lstat stat
#endif
#ifndef HAVE_LCHOWN
#define lchown chown
#endif

View File

@@ -1 +1 @@
#define VERSION "1.6.6"
#define VERSION "1.6.8"