X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/1c6e9dfabcb9fe09d1435b53b75a9bd563ce00cb..5f93b4d35ecadf57ddb87a11eda25e7d082137d7:/generator.c?ds=sidebyside diff --git a/generator.c b/generator.c index 518f49ea..3eef9e58 100644 --- a/generator.c +++ b/generator.c @@ -703,26 +703,38 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx, int itemizing, int maybe_ATTRS_REPORT, enum logcode code) { - char fnamebuf[MAXPATHLEN], lnk[MAXPATHLEN]; + char fnamebuf[MAXPATHLEN]; STRUCT_STAT st; - int len, i = 0; + int i = 0; do { pathjoin(fnamebuf, MAXPATHLEN, basis_dir[i], fname); if (link_stat(fnamebuf, &st, 0) < 0 || S_ISDIR(st.st_mode) || !unchanged_attrs(file, &st)) continue; - if (S_ISLNK(file->mode)) { + if (IS_DEVICE(file->mode)) { + if (!IS_DEVICE(st.st_mode) || st.st_rdev != file->u.rdev) + continue; + } else if (IS_SPECIAL(file->mode)) { + if (!IS_SPECIAL(st.st_mode) || st.st_rdev != file->u.rdev) + continue; +#ifdef CAN_HARDLINK_SYMLINK + } else if (S_ISLNK(file->mode)) { #ifdef SUPPORT_LINKS + char lnk[MAXPATHLEN]; + int len; if ((len = readlink(fnamebuf, lnk, MAXPATHLEN-1)) <= 0) continue; lnk[len] = '\0'; if (strcmp(lnk, file->u.link) != 0) #endif continue; +#endif } else { - if (!IS_DEVICE(st.st_mode) || st.st_rdev != file->u.rdev) - continue; + rprintf(FERROR, + "internal: try_dests_non() called with invalid mode (%o)\n", + file->mode); + exit_cleanup(RERR_UNSUPPORTED); } if (link_dest) { if (do_link(fnamebuf, fname) < 0) {