Change sending/receiving/storing of the rdev value for special files.
[rsync/rsync.git] / generator.c
index 53ba16f..1ccb55a 100644 (file)
@@ -507,7 +507,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
                        if (iflags & ITEM_XNAME_FOLLOWS)
                                write_vstring(sock_f_out, xname, strlen(xname));
 #ifdef SUPPORT_XATTRS
-                       if (preserve_xattrs && !dry_run
+                       if (preserve_xattrs && do_xfers
                         && iflags & (ITEM_REPORT_XATTR|ITEM_TRANSFER)) {
                                send_xattr_request(NULL, file,
                                        iflags & ITEM_REPORT_XATTR ? sock_f_out : -1);
@@ -931,8 +931,8 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
                }
                switch (type) {
                case TYPE_DIR:
-                       break;
                case TYPE_SPECIAL:
+                       break;
                case TYPE_DEVICE:
                        devp = F_RDEV_P(file);
                        if (sxp->st.st_rdev != MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp)))
@@ -1429,8 +1429,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
 
        if ((am_root && preserve_devices && IS_DEVICE(file->mode))
         || (preserve_specials && IS_SPECIAL(file->mode))) {
-               uint32 *devp = F_RDEV_P(file);
-               dev_t rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
+               dev_t rdev;
+               if (IS_DEVICE(file->mode)) {
+                       uint32 *devp = F_RDEV_P(file);
+                       rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
+               } else
+                       rdev = 0;
                if (statret == 0) {
                        int del_for_flag;
                        if (IS_DEVICE(file->mode)) {
@@ -1444,7 +1448,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        }
                        if (statret == 0
                         && BITS_EQUAL(sx.st.st_mode, file->mode, _S_IFMT)
-                        && sx.st.st_rdev == rdev) {
+                        && (IS_SPECIAL(sx.st.st_mode) || sx.st.st_rdev == rdev)) {
                                /* The device or special file is identical. */
                                set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
                                if (itemizing)