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
The ITEM_NO_DEST_AND_NO_UPDATE define is no longer needed.
[rsync/rsync.git]
/
flist.c
diff --git
a/flist.c
b/flist.c
index
11473dc
..
8f26f03
100644
(file)
--- a/
flist.c
+++ b/
flist.c
@@
-62,10
+62,13
@@
extern struct file_list *the_file_list;
extern char curr_dir[MAXPATHLEN];
extern char curr_dir[MAXPATHLEN];
+extern struct chmod_mode_struct *chmod_modes;
+
extern struct filter_list_struct filter_list;
extern struct filter_list_struct server_filter_list;
int io_error;
extern struct filter_list_struct filter_list;
extern struct filter_list_struct server_filter_list;
int io_error;
+int checksum_len;
dev_t filesystem_dev; /* used to implement -x */
static char empty_sum[MD4_SUM_LENGTH];
dev_t filesystem_dev; /* used to implement -x */
static char empty_sum[MD4_SUM_LENGTH];
@@
-82,6
+85,7
@@
void init_flist(void)
/* Figure out how big the file_struct is without trailing padding */
file_struct_len = offsetof(struct file_struct, flags) + sizeof f.flags;
/* Figure out how big the file_struct is without trailing padding */
file_struct_len = offsetof(struct file_struct, flags) + sizeof f.flags;
+ checksum_len = protocol_version < 21 ? 2 : MD4_SUM_LENGTH;
}
static int show_filelist_p(void)
}
static int show_filelist_p(void)
@@
-473,14
+477,13
@@
void send_file_entry(struct file_struct *file, int f, unsigned short base_flags)
if (always_checksum && (S_ISREG(mode) || protocol_version < 28)) {
char *sum;
if (always_checksum && (S_ISREG(mode) || protocol_version < 28)) {
char *sum;
- int slen = protocol_version < 21 ? 2 : MD4_SUM_LENGTH;
if (S_ISREG(mode))
sum = file->u.sum;
else {
/* Prior to 28, we sent a useless set of nulls. */
sum = empty_sum;
}
if (S_ISREG(mode))
sum = file->u.sum;
else {
/* Prior to 28, we sent a useless set of nulls. */
sum = empty_sum;
}
- write_buf(f, sum,
s
len);
+ write_buf(f, sum,
checksum_
len);
}
strlcpy(lastname, fname, MAXPATHLEN);
}
strlcpy(lastname, fname, MAXPATHLEN);
@@
-696,7
+699,6
@@
static struct file_struct *receive_file_entry(struct file_list *flist,
if (always_checksum && (sum_len || protocol_version < 28)) {
char *sum;
if (always_checksum && (sum_len || protocol_version < 28)) {
char *sum;
- int slen = protocol_version < 21 ? 2 : MD4_SUM_LENGTH;
if (sum_len) {
file->u.sum = sum = bp;
/*bp += sum_len;*/
if (sum_len) {
file->u.sum = sum = bp;
/*bp += sum_len;*/
@@
-704,7
+706,7
@@
static struct file_struct *receive_file_entry(struct file_list *flist,
/* Prior to 28, we get a useless set of nulls. */
sum = empty_sum;
}
/* Prior to 28, we get a useless set of nulls. */
sum = empty_sum;
}
- read_buf(f, sum,
s
len);
+ read_buf(f, sum,
checksum_
len);
}
if (!preserve_perms) {
}
if (!preserve_perms) {
@@
-818,7
+820,7
@@
struct file_struct *make_file(char *fname, struct file_list *flist,
return NULL;
}
return NULL;
}
-skip_filters:
+
skip_filters:
if (verbose > 2) {
rprintf(FINFO, "[%s] make_file(%s,*,%d)\n",
if (verbose > 2) {
rprintf(FINFO, "[%s] make_file(%s,*,%d)\n",
@@
-846,7
+848,8
@@
skip_filters:
linkname_len = 0;
#endif
linkname_len = 0;
#endif
- sum_len = always_checksum && S_ISREG(st.st_mode) ? MD4_SUM_LENGTH : 0;
+ sum_len = always_checksum && am_sender && S_ISREG(st.st_mode)
+ ? MD4_SUM_LENGTH : 0;
alloc_len = file_struct_len + dirname_len + basename_len
+ linkname_len + sum_len;
alloc_len = file_struct_len + dirname_len + basename_len
+ linkname_len + sum_len;
@@
-865,7
+868,10
@@
skip_filters:
file->flags = flags;
file->modtime = st.st_mtime;
file->length = st.st_size;
file->flags = flags;
file->modtime = st.st_mtime;
file->length = st.st_size;
- file->mode = st.st_mode;
+ if (chmod_modes && am_sender && (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)))
+ file->mode = tweak_mode(st.st_mode, chmod_modes);
+ else
+ file->mode = st.st_mode;
file->uid = st.st_uid;
file->gid = st.st_gid;
file->uid = st.st_uid;
file->gid = st.st_gid;
@@
-968,9
+974,10
@@
static struct file_struct *send_file_name(int f, struct file_list *flist,
}
static void send_if_directory(int f, struct file_list *flist,
}
static void send_if_directory(int f, struct file_list *flist,
- struct file_struct *file)
+ struct file_struct *file,
+ char *fbuf, unsigned int ol)
{
{
- char
fbuf[MAXPATHLEN]
;
+ char
is_dot_dir = fbuf[ol-1] == '.' && (ol == 1 || fbuf[ol-2] == '/')
;
if (S_ISDIR(file->mode)
&& !(file->flags & FLAG_MOUNT_POINT) && f_name_to(file, fbuf)) {
if (S_ISDIR(file->mode)
&& !(file->flags & FLAG_MOUNT_POINT) && f_name_to(file, fbuf)) {
@@
-987,6
+994,9
@@
static void send_if_directory(int f, struct file_list *flist,
save_filters = push_local_filters(fbuf, len);
send_directory(f, flist, fbuf, len);
pop_local_filters(save_filters);
save_filters = push_local_filters(fbuf, len);
send_directory(f, flist, fbuf, len);
pop_local_filters(save_filters);
+ fbuf[ol] = '\0';
+ if (is_dot_dir)
+ fbuf[ol-1] = '.';
}
}
}
}
@@
-1043,13
+1053,13
@@
static void send_directory(int f, struct file_list *flist,
if (recurse) {
int i, end = flist->count - 1;
for (i = start; i <= end; i++)
if (recurse) {
int i, end = flist->count - 1;
for (i = start; i <= end; i++)
- send_if_directory(f, flist, flist->files[i]);
+ send_if_directory(f, flist, flist->files[i]
, fbuf, len
);
}
}
struct file_list *send_file_list(int f, int argc, char *argv[])
{
}
}
struct file_list *send_file_list(int f, int argc, char *argv[])
{
- int l;
+ int l
en
;
STRUCT_STAT st;
char *p, *dir, olddir[sizeof curr_dir];
char lastpath[MAXPATHLEN] = "";
STRUCT_STAT st;
char *p, *dir, olddir[sizeof curr_dir];
char lastpath[MAXPATHLEN] = "";
@@
-1077,57
+1087,57
@@
struct file_list *send_file_list(int f, int argc, char *argv[])
}
while (1) {
}
while (1) {
- char f
name2
[MAXPATHLEN];
- char *fn
ame = fname2
;
+ char f
buf
[MAXPATHLEN];
+ char *fn;
int is_dot_dir;
if (use_ff_fd) {
int is_dot_dir;
if (use_ff_fd) {
- if (read_filesfrom_line(filesfrom_fd, f
name
) == 0)
+ if (read_filesfrom_line(filesfrom_fd, f
buf
) == 0)
break;
break;
- sanitize_path(f
name, fname
, "", 0);
+ sanitize_path(f
buf, fbuf
, "", 0);
} else {
if (argc-- == 0)
break;
} else {
if (argc-- == 0)
break;
- strlcpy(f
name
, *argv++, MAXPATHLEN);
+ strlcpy(f
buf
, *argv++, MAXPATHLEN);
if (sanitize_paths)
if (sanitize_paths)
- sanitize_path(f
name, fname
, "", 0);
+ sanitize_path(f
buf, fbuf
, "", 0);
}
}
- l
= strlen(fname
);
- if (!l
|| fname[l
- 1] == '/') {
- if (l
== 2 && fname
[0] == '.') {
+ l
en = strlen(fbuf
);
+ if (!l
en || fbuf[len
- 1] == '/') {
+ if (l
en == 2 && fbuf
[0] == '.') {
/* Turn "./" into just "." rather than "./." */
/* Turn "./" into just "." rather than "./." */
- f
name
[1] = '\0';
+ f
buf
[1] = '\0';
} else {
} else {
- if (l + 1 >= MAXPATHLEN)
+ if (l
en
+ 1 >= MAXPATHLEN)
overflow_exit("send_file_list");
overflow_exit("send_file_list");
- f
name[l
++] = '.';
- f
name[l
] = '\0';
+ f
buf[len
++] = '.';
+ f
buf[len
] = '\0';
}
is_dot_dir = 1;
}
is_dot_dir = 1;
- } else if (l
> 1 && fname[l-1] == '.' && fname[l
-2] == '.'
- && (l
== 2 || fname[l
-3] == '/')) {
- if (l + 2 >= MAXPATHLEN)
+ } else if (l
en > 1 && fbuf[len-1] == '.' && fbuf[len
-2] == '.'
+ && (l
en == 2 || fbuf[len
-3] == '/')) {
+ if (l
en
+ 2 >= MAXPATHLEN)
overflow_exit("send_file_list");
overflow_exit("send_file_list");
- f
name[l
++] = '/';
- f
name[l
++] = '.';
- f
name[l
] = '\0';
+ f
buf[len
++] = '/';
+ f
buf[len
++] = '.';
+ f
buf[len
] = '\0';
is_dot_dir = 1;
} else {
is_dot_dir = 1;
} else {
- is_dot_dir = f
name[l
-1] == '.'
- && (l
== 1 || fname[l
-2] == '/');
+ is_dot_dir = f
buf[len
-1] == '.'
+ && (l
en == 1 || fbuf[len
-2] == '/');
}
}
- if (link_stat(f
name
, &st, keep_dirlinks) != 0) {
+ if (link_stat(f
buf
, &st, keep_dirlinks) != 0) {
io_error |= IOERR_GENERAL;
rsyserr(FERROR, errno, "link_stat %s failed",
io_error |= IOERR_GENERAL;
rsyserr(FERROR, errno, "link_stat %s failed",
- full_fname(f
name
));
+ full_fname(f
buf
));
continue;
}
if (S_ISDIR(st.st_mode) && !xfer_dirs) {
rprintf(FINFO, "skipping directory %s\n",
continue;
}
if (S_ISDIR(st.st_mode) && !xfer_dirs) {
rprintf(FINFO, "skipping directory %s\n",
- safe_fname(f
name
));
+ safe_fname(f
buf
));
continue;
}
continue;
}
@@
-1135,26
+1145,32
@@
struct file_list *send_file_list(int f, int argc, char *argv[])
olddir[0] = '\0';
if (!relative_paths) {
olddir[0] = '\0';
if (!relative_paths) {
- p = strrchr(f
name
, '/');
+ p = strrchr(f
buf
, '/');
if (p) {
*p = '\0';
if (p) {
*p = '\0';
- if (p == f
name
)
+ if (p == f
buf
)
dir = "/";
else
dir = "/";
else
- dir = fname;
- fname = p + 1;
- }
- } else if ((p = strstr(fname, "/./")) != NULL) {
+ dir = fbuf;
+ len -= p - fbuf + 1;
+ fn = p + 1;
+ } else
+ fn = fbuf;
+ } else if ((p = strstr(fbuf, "/./")) != NULL) {
*p = '\0';
*p = '\0';
- if (p == f
name
)
+ if (p == f
buf
)
dir = "/";
else
dir = "/";
else
- dir = fname;
- fname = p + 3;
- }
+ dir = fbuf;
+ len -= p - fbuf + 3;
+ fn = p + 3;
+ } else
+ fn = fbuf;
- if (!*fname)
- fname = ".";
+ if (!*fn) {
+ len = 1;
+ fn = ".";
+ }
if (dir && *dir) {
static char *lastdir;
if (dir && *dir) {
static char *lastdir;
@@
-1178,17
+1194,19
@@
struct file_list *send_file_list(int f, int argc, char *argv[])
}
}
}
}
- if (implied_dirs && (p=strrchr(fname,'/')) && p != fname) {
+ if (fn != fbuf)
+ memmove(fbuf, fn, len + 1);
+
+ if (implied_dirs && (p=strrchr(fbuf,'/')) && p != fbuf) {
/* Send the implied directories at the start of the
* source spec, so we get their permissions right. */
/* Send the implied directories at the start of the
* source spec, so we get their permissions right. */
- char *lp = lastpath, *
fn = fname, *slash = fname
;
+ char *lp = lastpath, *
slash = fbuf
;
*p = '\0';
/* Skip any initial directories in our path that we
* have in common with lastpath. */
*p = '\0';
/* Skip any initial directories in our path that we
* have in common with lastpath. */
-
while (*fn && *lp == *fn
) {
+
for (fn = fbuf; *fn && *lp == *fn; lp++, fn++
) {
if (*fn == '/')
slash = fn;
if (*fn == '/')
slash = fn;
- lp++, fn++;
}
*p = '/';
if (fn != p || (*lp && *lp != '/')) {
}
*p = '/';
if (fn != p || (*lp && *lp != '/')) {
@@
-1198,13
+1216,13
@@
struct file_list *send_file_list(int f, int argc, char *argv[])
xfer_dirs = 1;
while ((slash = strchr(slash+1, '/')) != 0) {
*slash = '\0';
xfer_dirs = 1;
while ((slash = strchr(slash+1, '/')) != 0) {
*slash = '\0';
- send_file_name(f, flist, f
name
, 0);
+ send_file_name(f, flist, f
buf
, 0);
*slash = '/';
}
copy_links = save_copy_links;
xfer_dirs = save_xfer_dirs;
*p = '\0';
*slash = '/';
}
copy_links = save_copy_links;
xfer_dirs = save_xfer_dirs;
*p = '\0';
- strlcpy(lastpath, f
name
, sizeof lastpath);
+ strlcpy(lastpath, f
buf
, sizeof lastpath);
*p = '/';
}
}
*p = '/';
}
}
@@
-1214,10
+1232,10
@@
struct file_list *send_file_list(int f, int argc, char *argv[])
if (recurse || (xfer_dirs && is_dot_dir)) {
struct file_struct *file;
if (recurse || (xfer_dirs && is_dot_dir)) {
struct file_struct *file;
- if ((file = send_file_name(f, flist, f
name
, XMIT_TOP_DIR)))
- send_if_directory(f, flist, file);
+ if ((file = send_file_name(f, flist, f
buf
, XMIT_TOP_DIR)))
+ send_if_directory(f, flist, file
, fbuf, len
);
} else
} else
- send_file_name(f, flist, f
name
, 0);
+ send_file_name(f, flist, f
buf
, 0);
if (olddir[0]) {
flist_dir = NULL;
if (olddir[0]) {
flist_dir = NULL;
@@
-1296,7
+1314,6
@@
struct file_list *recv_file_list(int f)
if (!flist->files)
goto oom;
if (!flist->files)
goto oom;
-
while ((flags = read_byte(f)) != 0) {
struct file_struct *file;
while ((flags = read_byte(f)) != 0) {
struct file_struct *file;
@@
-1357,7
+1374,7
@@
struct file_list *recv_file_list(int f)
return flist;
return flist;
-oom:
+
oom:
out_of_memory("recv_file_list");
return NULL; /* not reached */
}
out_of_memory("recv_file_list");
return NULL; /* not reached */
}