extern int do_progress;
extern int am_server;
extern int always_checksum;
+extern int module_id;
+extern int ignore_errors;
extern int cvs_exclude;
flags |= SAME_TIME;
else
modtime = file->modtime;
- if (file->flags & HAS_INODE_DATA) {
- if (file->dev == dev) {
+ if (file->link_u.idev) {
+ if (file->F_DEV == dev) {
if (protocol_version >= 28)
flags |= SAME_DEV;
} else
- dev = file->dev;
+ dev = file->F_DEV;
flags |= HAS_INODE_DATA;
}
for (l1 = 0;
lastname[l1] && (fname[l1] == lastname[l1]) && (l1 < 255);
l1++) {}
- l2 = strlen(fname) - l1;
+ l2 = strlen(fname+l1);
if (l1 > 0)
flags |= SAME_NAME;
if (protocol_version < 26) {
/* 32-bit dev_t and ino_t */
write_int(f, dev);
- write_int(f, file->inode);
+ write_int(f, file->F_INODE);
} else {
/* 64-bit dev_t and ino_t */
if (!(flags & SAME_DEV))
write_longint(f, dev);
- write_longint(f, file->inode);
+ write_longint(f, file->F_INODE);
}
}
#endif
sanitize_path(file->u.link, file->dirname);
}
#if SUPPORT_HARD_LINKS
- if (preserve_hard_links && protocol_version < 28
- && S_ISREG(mode))
- file->flags |= HAS_INODE_DATA;
- if (file->flags & HAS_INODE_DATA) {
+ if (preserve_hard_links && protocol_version < 28 && S_ISREG(mode))
+ flags |= HAS_INODE_DATA;
+ if (flags & HAS_INODE_DATA) {
+ if (!(file->link_u.idev = new(struct idev)))
+ out_of_memory("file inode data");
if (protocol_version < 26) {
dev = read_int(f);
- file->inode = read_int(f);
+ file->F_INODE = read_int(f);
} else {
if (!(flags & SAME_DEV))
dev = read_longint(f);
- file->inode = read_longint(f);
+ file->F_INODE = read_longint(f);
}
- file->dev = dev;
+ file->F_DEV = dev;
}
#endif
char *p;
char cleaned_name[MAXPATHLEN];
char linkbuf[MAXPATHLEN];
- extern int module_id;
strlcpy(cleaned_name, fname, MAXPATHLEN);
cleaned_name[MAXPATHLEN - 1] = 0;
file->uid = st.st_uid;
file->gid = st.st_gid;
if (preserve_hard_links) {
- if (protocol_version < 28? S_ISREG(st.st_mode)
+ if (protocol_version < 28 ? S_ISREG(st.st_mode)
: !S_ISDIR(st.st_mode) && st.st_nlink > 1) {
- file->dev = st.st_dev;
- file->inode = st.st_ino;
- file->flags |= HAS_INODE_DATA;
+ if (!(file->link_u.idev = new(struct idev)))
+ out_of_memory("file inode data");
+ file->F_DEV = st.st_dev;
+ file->F_INODE = st.st_ino;
}
}
#ifdef HAVE_STRUCT_STAT_ST_RDEV
DIR *d;
struct dirent *di;
char fname[MAXPATHLEN];
- int l;
+ unsigned int offset;
char *p;
d = opendir(dir);
return;
}
- strlcpy(fname, dir, MAXPATHLEN);
- l = strlen(fname);
- if (fname[l - 1] != '/') {
- if (l == MAXPATHLEN - 1) {
+ offset = strlcpy(fname, dir, MAXPATHLEN);
+ p = fname + offset;
+ if (offset >= MAXPATHLEN || p[-1] != '/') {
+ if (offset >= MAXPATHLEN - 1) {
io_error |= IOERR_GENERAL;
rprintf(FERROR, "skipping long-named directory: %s\n",
full_fname(fname));
closedir(d);
return;
}
- strlcat(fname, "/", MAXPATHLEN);
- l++;
+ *p++ = '/';
+ offset++;
}
- p = fname + strlen(fname);
local_exclude_list = NULL;
if (cvs_exclude) {
- if (strlen(fname) + strlen(".cvsignore") <= MAXPATHLEN - 1) {
- strcpy(p, ".cvsignore");
- add_exclude_file(&exclude_list,fname,MISSING_OK,ADD_EXCLUDE);
- } else {
+ if (strlcpy(p, ".cvsignore", MAXPATHLEN - offset)
+ < MAXPATHLEN - offset)
+ add_exclude_file(&local_exclude_list,fname,MISSING_OK,ADD_EXCLUDE);
+ else {
io_error |= IOERR_GENERAL;
rprintf(FINFO,
"cannot cvs-exclude in long-named directory %s\n",
if (dname[0] == '.' && (dname[1] == '\0'
|| (dname[1] == '.' && dname[2] == '\0')))
continue;
- strlcpy(p, dname, MAXPATHLEN - l);
- send_file_name(f, flist, fname, recurse, 0);
+ if (strlcpy(p, dname, MAXPATHLEN - offset) < MAXPATHLEN - offset)
+ send_file_name(f, flist, fname, recurse, 0);
+ else {
+ io_error |= IOERR_GENERAL;
+ rprintf(FINFO,
+ "cannot send long-named file %s\n",
+ full_fname(fname));
+ }
}
if (errno) {
io_error |= IOERR_GENERAL;
rprintf(FERROR, "readdir(%s): (%d) %s\n",
- dir, errno, strerror(errno));
+ dir, errno, strerror(errno));
}
if (local_exclude_list)
if (l == 2 && fname[0] == '.') {
/* Turn "./" into just "." rather than "./." */
fname[1] = '\0';
- } else {
- strlcat(fname, ".", MAXPATHLEN);
+ } else if (l < MAXPATHLEN) {
+ fname[l++] = '.';
+ fname[l] = '\0';
}
}
}
}
- if (f != -1)
+ if (f != -1) {
send_file_entry(NULL, f, 0);
- if (show_filelist_p() && f != -1)
- finish_filelist_progress(flist);
+ if (show_filelist_p())
+ finish_filelist_progress(flist);
+ }
clean_flist(flist, 0, 0);
- /* now send the uid/gid list. This was introduced in protocol
- version 15 */
- if (f != -1)
+ if (f != -1) {
+ /* Now send the uid/gid list. This was introduced in
+ * protocol version 15 */
send_uid_list(f);
- /* send the io_error flag */
- if (f != -1) {
- extern int module_id;
+ /* send the io_error flag */
write_int(f, lp_ignore_errors(module_id) ? 0 : io_error);
- }
- if (f != -1) {
io_end_buffering();
stats.flist_size = stats.total_written - start_write;
stats.num_files = flist->count;
if (verbose > 2)
rprintf(FINFO, "received %d names\n", flist->count);
- clean_flist(flist, relative_paths, 1);
-
if (show_filelist_p())
finish_filelist_progress(flist);
- /* now recv the uid/gid list. This was introduced in protocol version 15 */
- if (f != -1)
+ clean_flist(flist, relative_paths, 1);
+
+ if (f != -1) {
+ /* Now send the uid/gid list. This was introduced in
+ * protocol version 15 */
recv_uid_list(f, flist);
- /* recv the io_error flag */
- if (f != -1 && !read_batch) { /* dw-added readbatch */
- extern int module_id;
- extern int ignore_errors;
- if (lp_ignore_errors(module_id) || ignore_errors)
- read_int(f);
- else
- io_error |= read_int(f);
+ if (!read_batch) {
+ /* Recv the io_error flag */
+ if (lp_ignore_errors(module_id) || ignore_errors)
+ read_int(f);
+ else
+ io_error |= read_int(f);
+ }
}
if (list_only) {
list_file_entry(flist->files[i]);
}
-
if (verbose > 2)
rprintf(FINFO, "recv_file_list done\n");
free(file->basename);
if (!IS_DEVICE(file->mode) && file->u.link)
free(file->u.link); /* Handles u.sum too. */
+ if (file->link_u.idev)
+ free((char*)file->link_u.idev); /* Handles link_u.links too. */
*file = null_file;
}