Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use Realloc instead of realloc
[rsync/rsync.git]
/
flist.c
diff --git
a/flist.c
b/flist.c
index
15c56c8
..
5b6dc60
100644
(file)
--- a/
flist.c
+++ b/
flist.c
@@
-46,7
+46,7
@@
extern int copy_links;
extern int remote_version;
extern int io_error;
extern int remote_version;
extern int io_error;
-static
char
**local_exclude_list;
+static
struct exclude_struct
**local_exclude_list;
int link_stat(const char *Path, STRUCT_STAT *Buffer)
{
int link_stat(const char *Path, STRUCT_STAT *Buffer)
{
@@
-67,7
+67,7
@@
int link_stat(const char *Path, STRUCT_STAT *Buffer)
*/
static int match_file_name(char *fname,STRUCT_STAT *st)
{
*/
static int match_file_name(char *fname,STRUCT_STAT *st)
{
- if (check_exclude(fname,local_exclude_list)) {
+ if (check_exclude(fname,local_exclude_list
,st
)) {
if (verbose > 2)
rprintf(FINFO,"excluding file %s\n",fname);
return 0;
if (verbose > 2)
rprintf(FINFO,"excluding file %s\n",fname);
return 0;
@@
-163,7
+163,7
@@
void send_file_entry(struct file_struct *file,int f,unsigned base_flags)
if (file->gid == last_gid) flags |= SAME_GID;
if (file->modtime == last_time) flags |= SAME_TIME;
if (file->gid == last_gid) flags |= SAME_GID;
if (file->modtime == last_time) flags |= SAME_TIME;
- for (l1=0;lastname[l1] &&
fname[l1] == lastname[l1];l1++) ;
+ for (l1=0;lastname[l1] &&
(fname[l1] == lastname[l1]) && (l1 < 255);l1++) ;
l2 = strlen(fname) - l1;
if (l1 > 0) flags |= SAME_NAME;
l2 = strlen(fname) - l1;
if (l1 > 0) flags |= SAME_NAME;
@@
-262,6
+262,12
@@
static void receive_file_entry(struct file_struct **fptr,
clean_fname(thisname);
clean_fname(thisname);
+ if (relative_paths && thisname[0] == '/') {
+ /* strip / off absolute paths in destination */
+ memmove(thisname, thisname+1, strlen(thisname));
+ if (!thisname[0]) strcpy(thisname,".");
+ }
+
if ((p = strrchr(thisname,'/'))) {
static char *lastdir;
*p = 0;
if ((p = strrchr(thisname,'/'))) {
static char *lastdir;
*p = 0;
@@
-487,10
+493,10
@@
static void send_file_name(int f,struct file_list *flist,char *fname,
}
if (S_ISDIR(file->mode) && recursive) {
}
if (S_ISDIR(file->mode) && recursive) {
-
char
**last_exclude_list = local_exclude_list;
- send_directory(f,flist,f_name(file));
- local_exclude_list = last_exclude_list;
- return;
+
struct exclude_struct
**last_exclude_list = local_exclude_list;
+
send_directory(f,flist,f_name(file));
+
local_exclude_list = last_exclude_list;
+
return;
}
}
}
}
@@
-507,7
+513,7
@@
static void send_directory(int f,struct file_list *flist,char *dir)
d = opendir(dir);
if (!d) {
io_error = 1;
d = opendir(dir);
if (!d) {
io_error = 1;
- rprintf(FERROR,"
%s
: %s\n",
+ rprintf(FERROR,"
opendir(%s)
: %s\n",
dir,strerror(errno));
return;
}
dir,strerror(errno));
return;
}
@@
-521,7
+527,7
@@
static void send_directory(int f,struct file_list *flist,char *dir)
closedir(d);
return;
}
closedir(d);
return;
}
- str
cat(fname,"/"
);
+ str
lcat(fname,"/", MAXPATHLEN-1
);
l++;
}
p = fname + strlen(fname);
l++;
}
p = fname + strlen(fname);
@@
-529,7
+535,7
@@
static void send_directory(int f,struct file_list *flist,char *dir)
if (cvs_exclude) {
if (strlen(fname) + strlen(".cvsignore") <= MAXPATHLEN-1) {
strcpy(p,".cvsignore");
if (cvs_exclude) {
if (strlen(fname) + strlen(".cvsignore") <= MAXPATHLEN-1) {
strcpy(p,".cvsignore");
- local_exclude_list = make_exclude_list(fname,NULL,0);
+ local_exclude_list = make_exclude_list(fname,NULL,0
,0
);
} else {
io_error = 1;
rprintf(FINFO,"cannot cvs-exclude in long-named directory %s\n",fname);
} else {
io_error = 1;
rprintf(FINFO,"cannot cvs-exclude in long-named directory %s\n",fname);
@@
-542,7
+548,7
@@
static void send_directory(int f,struct file_list *flist,char *dir)
strcmp(dname,"..")==0)
continue;
strlcpy(p,dname,MAXPATHLEN-(l+1));
strcmp(dname,"..")==0)
continue;
strlcpy(p,dname,MAXPATHLEN-(l+1));
- send_file_name(f,flist,fname,recurse,
FLAG_DELETE
);
+ send_file_name(f,flist,fname,recurse,
0
);
}
closedir(d);
}
closedir(d);
@@
-573,6
+579,10
@@
struct file_list *send_file_list(int f,int argc,char *argv[])
flist->malloced);
if (!flist->files) out_of_memory("send_file_list");
flist->malloced);
if (!flist->files) out_of_memory("send_file_list");
+ if (f != -1) {
+ io_start_buffering(f);
+ }
+
for (i=0;i<argc;i++) {
char fname2[MAXPATHLEN];
char *fname = fname2;
for (i=0;i<argc;i++) {
char fname2[MAXPATHLEN];
char *fname = fname2;
@@
-581,7
+591,7
@@
struct file_list *send_file_list(int f,int argc,char *argv[])
l = strlen(fname);
if (l != 1 && fname[l-1] == '/') {
l = strlen(fname);
if (l != 1 && fname[l-1] == '/') {
- str
cat(fname,"."
);
+ str
lcat(fname,".",MAXPATHLEN-1
);
}
if (link_stat(fname,&st) != 0) {
}
if (link_stat(fname,&st) != 0) {
@@
-612,11
+622,14
@@
struct file_list *send_file_list(int f,int argc,char *argv[])
thus getting their permissions right */
*p = 0;
if (strcmp(lastpath,fname)) {
thus getting their permissions right */
*p = 0;
if (strcmp(lastpath,fname)) {
- str
cpy(lastpath, fname
);
+ str
lcpy(lastpath, fname, sizeof(lastpath)-1
);
*p = '/';
for (p=fname+1; (p=strchr(p,'/')); p++) {
*p = '/';
for (p=fname+1; (p=strchr(p,'/')); p++) {
+ int copy_links_saved = copy_links;
*p = 0;
*p = 0;
+ copy_links = 0;
send_file_name(f, flist, fname, 0, 0);
send_file_name(f, flist, fname, 0, 0);
+ copy_links = copy_links_saved;
*p = '/';
}
} else {
*p = '/';
}
} else {
@@
-658,7
+671,6
@@
struct file_list *send_file_list(int f,int argc,char *argv[])
if (f != -1) {
send_file_entry(NULL,f,0);
if (f != -1) {
send_file_entry(NULL,f,0);
- write_flush(f);
}
if (verbose && recurse && !am_server && f != -1)
}
if (verbose && recurse && !am_server && f != -1)
@@
-677,6
+689,10
@@
struct file_list *send_file_list(int f,int argc,char *argv[])
write_int(f, io_error);
}
write_int(f, io_error);
}
+ if (f != -1) {
+ io_end_buffering(f);
+ }
+
if (verbose > 2)
rprintf(FINFO,"send_file_list done\n");
if (verbose > 2)
rprintf(FINFO,"send_file_list done\n");
@@
-870,9
+886,9
@@
char *f_name(struct file_struct *f)
n = (n+1)%10;
if (f->dirname) {
n = (n+1)%10;
if (f->dirname) {
- s
printf(p
, "%s/%s", f->dirname, f->basename);
+ s
lprintf(p, MAXPATHLEN-1
, "%s/%s", f->dirname, f->basename);
} else {
} else {
- str
cpy(p, f->basename
);
+ str
lcpy(p, f->basename, MAXPATHLEN-1
);
}
return p;
}
return p;