X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/357406ecb202e40c7c7e68ce5fd3307b1dbb6fa2..d62bcc17f303f30d1e3df1051b1390202a21cf9c:/flist.c diff --git a/flist.c b/flist.c index 012e6f0f..41acca35 100644 --- a/flist.c +++ b/flist.c @@ -53,7 +53,6 @@ extern int preserve_perms; extern int preserve_devices; extern int preserve_uid; extern int preserve_gid; -extern int preserve_times; extern int relative_paths; extern int implied_dirs; extern int copy_links; @@ -64,9 +63,9 @@ extern int sanitize_paths; extern int read_batch; extern int write_batch; -extern struct exclude_struct **exclude_list; -extern struct exclude_struct **server_exclude_list; -extern struct exclude_struct **local_exclude_list; +extern struct exclude_list_struct exclude_list; +extern struct exclude_list_struct server_exclude_list; +extern struct exclude_list_struct local_exclude_list; int io_error; @@ -211,6 +210,8 @@ int link_stat(const char *path, STRUCT_STAT * buffer) */ static int check_exclude_file(char *fname, int is_dir, int exclude_level) { + int rc; + #if 0 /* This currently never happens, so avoid a useless compare. */ if (exclude_level == NO_EXCLUDES) return 0; @@ -226,15 +227,16 @@ static int check_exclude_file(char *fname, int is_dir, int exclude_level) return 0; } } - if (server_exclude_list - && check_exclude(server_exclude_list, fname, is_dir)) + if (server_exclude_list.head + && check_exclude(&server_exclude_list, fname, is_dir) < 0) return 1; if (exclude_level != ALL_EXCLUDES) return 0; - if (exclude_list && check_exclude(exclude_list, fname, is_dir)) - return 1; - if (local_exclude_list - && check_exclude(local_exclude_list, fname, is_dir)) + if (exclude_list.head + && (rc = check_exclude(&exclude_list, fname, is_dir)) != 0) + return rc < 0; + if (local_exclude_list.head + && check_exclude(&local_exclude_list, fname, is_dir) < 0) return 1; return 0; } @@ -324,7 +326,8 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) unsigned short flags; static time_t modtime; static mode_t mode; - static dev_t dev, rdev; + static uint64 dev; + static dev_t rdev; static uint32 rdev_major; static uid_t uid; static gid_t gid; @@ -338,7 +341,7 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) if (!file) { write_byte(f, 0); modtime = 0, mode = 0; - dev = rdev = makedev(0, 0); + dev = 0, rdev = makedev(0, 0); rdev_major = 0; uid = 0, gid = 0; *lastname = '\0'; @@ -475,20 +478,14 @@ void send_file_entry(struct file_struct *file, int f, unsigned short base_flags) #if SUPPORT_HARD_LINKS if (flags & XMIT_HAS_IDEV_DATA) { - if (protocol_version >= 28) { - /* major/minor dev_t and 64-bit ino_t */ - if (!(flags & XMIT_SAME_DEV)) { - write_int(f, major(dev)); - write_int(f, minor(dev)); - } - write_longint(f, file->F_INODE); - } else if (protocol_version < 26) { + if (protocol_version < 26) { /* 32-bit dev_t and ino_t */ write_int(f, dev); write_int(f, file->F_INODE); } else { /* 64-bit dev_t and ino_t */ - write_longint(f, dev); + if (!(flags & XMIT_SAME_DEV)) + write_longint(f, dev); write_longint(f, file->F_INODE); } } @@ -521,7 +518,8 @@ void receive_file_entry(struct file_struct **fptr, unsigned short flags, { static time_t modtime; static mode_t mode; - static dev_t dev, rdev; + static uint64 dev; + static dev_t rdev; static uint32 rdev_major; static uid_t uid; static gid_t gid; @@ -536,10 +534,11 @@ void receive_file_entry(struct file_struct **fptr, unsigned short flags, if (!fptr) { modtime = 0, mode = 0; - dev = rdev = makedev(0, 0); + dev = 0, rdev = makedev(0, 0); rdev_major = 0; uid = 0, gid = 0; *lastname = '\0'; + lastdir_len = -1; return; } @@ -674,19 +673,13 @@ void receive_file_entry(struct file_struct **fptr, unsigned short flags, if (preserve_hard_links && protocol_version < 28 && S_ISREG(mode)) flags |= XMIT_HAS_IDEV_DATA; if (flags & XMIT_HAS_IDEV_DATA) { - INO64_T inode; - if (protocol_version >= 28) { - if (!(flags & XMIT_SAME_DEV)) { - uint32 dev_major = read_int(f); - uint32 dev_minor = read_int(f); - dev = makedev(dev_major, dev_minor); - } - inode = read_longint(f); - } else if (protocol_version < 26) { - dev = (dev_t)read_int(f); + uint64 inode; + if (protocol_version < 26) { + dev = read_int(f); inode = read_int(f); } else { - dev = (dev_t)read_longint(f); + if (!(flags & XMIT_SAME_DEV)) + dev = read_longint(f); inode = read_longint(f); } if (flist->hlink_pool) { @@ -752,7 +745,7 @@ struct file_struct *make_file(char *fname, char *basename, *dirname, *bp; unsigned short flags = 0; - if (!flist) /* lastdir isn't valid if flist is NULL */ + if (!flist || !flist->count) /* Ignore lastdir when invalid. */ lastdir_len = -1; if (strlcpy(thisname, fname, sizeof thisname) @@ -785,8 +778,8 @@ struct file_struct *make_file(char *fname, } else { io_error |= IOERR_GENERAL; - rprintf(FERROR, "readlink %s failed: %s\n", - full_fname(thisname), strerror(save_errno)); + rsyserr(FERROR, save_errno, "readlink %s failed", + full_fname(thisname)); } return NULL; } @@ -953,10 +946,15 @@ void send_file_name(int f, struct file_list *flist, char *fname, if (recursive && S_ISDIR(file->mode) && !(file->flags & FLAG_MOUNT_POINT)) { - struct exclude_struct **last_exclude_list = local_exclude_list; + struct exclude_list_struct last_list = local_exclude_list; + local_exclude_list.head = local_exclude_list.tail = NULL; send_directory(f, flist, f_name_to(file, fbuf)); - local_exclude_list = last_exclude_list; - return; + if (verbose > 2) { + rprintf(FINFO, "[%s] popping %sexclude list\n", + who_am_i(), local_exclude_list.debug_type); + } + free_exclude_list(&local_exclude_list); + local_exclude_list = last_list; } } @@ -972,8 +970,7 @@ static void send_directory(int f, struct file_list *flist, char *dir) d = opendir(dir); if (!d) { io_error |= IOERR_GENERAL; - rprintf(FERROR, "opendir %s failed: %s\n", - full_fname(dir), strerror(errno)); + rsyserr(FERROR, errno, "opendir %s failed", full_fname(dir)); return; } @@ -991,13 +988,11 @@ static void send_directory(int f, struct file_list *flist, char *dir) offset++; } - local_exclude_list = NULL; - if (cvs_exclude) { if (strlcpy(p, ".cvsignore", MAXPATHLEN - offset) < MAXPATHLEN - offset) { add_exclude_file(&local_exclude_list, fname, - XFLG_WORD_SPLIT | XFLG_NO_PREFIXES); + XFLG_WORD_SPLIT | XFLG_WORDS_ONLY); } else { io_error |= IOERR_GENERAL; rprintf(FINFO, @@ -1022,13 +1017,9 @@ static void send_directory(int f, struct file_list *flist, char *dir) } if (errno) { io_error |= IOERR_GENERAL; - rprintf(FERROR, "readdir(%s): (%d) %s\n", - dir, errno, strerror(errno)); + rsyserr(FERROR, errno, "readdir(%s)", dir); } - if (local_exclude_list) - free_exclude_list(&local_exclude_list); /* Zeros pointer too */ - closedir(d); } @@ -1061,8 +1052,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) io_start_buffering_out(f); if (filesfrom_fd >= 0) { if (argv[0] && !push_dir(argv[0])) { - rprintf(FERROR, "push_dir %s failed: %s\n", - full_fname(argv[0]), strerror(errno)); + rsyserr(FERROR, errno, "push_dir %s failed", + full_fname(argv[0])); exit_cleanup(RERR_FILESELECT); } use_ff_fd = 1; @@ -1099,8 +1090,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) if (link_stat(fname, &st) != 0) { if (f != -1) { io_error |= IOERR_GENERAL; - rprintf(FERROR, "link_stat %s failed: %s\n", - full_fname(fname), strerror(errno)); + rsyserr(FERROR, errno, "link_stat %s failed", + full_fname(fname)); } continue; } @@ -1169,8 +1160,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) if (!push_dir(dir)) { io_error |= IOERR_GENERAL; - rprintf(FERROR, "push_dir %s failed: %s\n", - full_fname(dir), strerror(errno)); + rsyserr(FERROR, errno, "push_dir %s failed", + full_fname(dir)); continue; } @@ -1192,8 +1183,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) flist_dir = NULL; flist_dir_len = 0; if (!pop_dir(olddir)) { - rprintf(FERROR, "pop_dir %s failed: %s\n", - full_fname(dir), strerror(errno)); + rsyserr(FERROR, errno, "pop_dir %s failed", + full_fname(dir)); exit_cleanup(RERR_FILESELECT); } } @@ -1528,11 +1519,17 @@ int f_name_cmp(struct file_struct *f1, struct file_struct *f2) if (!(c1 = (uchar*)f1->dirname)) { state1 = fnc_BASE; c1 = (uchar*)f1->basename; + } else if (!*c1) { + state1 = fnc_SLASH; + c1 = (uchar*)"/"; } else state1 = fnc_DIR; if (!(c2 = (uchar*)f2->dirname)) { state2 = fnc_BASE; c2 = (uchar*)f2->basename; + } else if (!*c2) { + state2 = fnc_SLASH; + c2 = (uchar*)"/"; } else state2 = fnc_DIR;