From: Wayne Davison Date: Sun, 26 Jul 2020 06:28:44 +0000 (-0700) Subject: Fix issue where rdev major could get out of sync X-Git-Tag: v3.2.3pre1~14 X-Git-Url: http://git.samba.org/rsync.git/?a=commitdiff_plain;h=2066024981a26f5c6b87a390b87524c4c3c9ce93;p=rsync.git Fix issue where rdev major could get out of sync If the receiving side read a hard-linked device, it needs to set the value of rdev_major to the value it snags from the hard-linked data because the sender set their rdev_major value for that file entry. --- diff --git a/NEWS.md b/NEWS.md index ff943af1..03c0e5cb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,13 +12,17 @@ - Fixed a bug in the xattr code that was not leaving room for the "rsync." prefix in some instances where it needed to be added. - - Restored the ability to use --bwlimit=0 to specify no bandwidth limit. (It + - Restored the ability to use `--bwlimit=0` to specify no bandwidth limit. (It was accidentally broken in 3.2.2.) - Fix a bug when combining `--delete-missing-args` with `--no-implied-dirs` & `-R` where rsync might create the destination path of a missing arg. The code also avoids some superfluous warnings for nested paths of removed args. + - Fixed an issue where hard-linked devices could cause the rdev_major value to + get out of sync between the sender and the receiver, which could cause a + device to get created with the wrong major value in its major,minor pair. + ### ENHANCEMENTS: - Allow `--max-alloc=0` to specify no limit to the alloc sanity check. @@ -98,7 +102,7 @@ - Apple requires the asm function name to begin with an underscore. - - Avoid a test failure in the daemon test when --atimes is disabled. + - Avoid a test failure in the daemon test when `--atimes` is disabled. ### ENHANCEMENTS: diff --git a/flist.c b/flist.c index feec96d4..5a1e4245 100644 --- a/flist.c +++ b/flist.c @@ -448,7 +448,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, if (protocol_version < 28) xflags |= XMIT_SAME_RDEV_pre28; else { - rdev = MAKEDEV(major(rdev), 0); + rdev = MAKEDEV(rdev_major, 0); xflags |= XMIT_SAME_RDEV_MAJOR; if (protocol_version < 30) xflags |= XMIT_RDEV_MINOR_8_pre30; @@ -804,7 +804,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x gid = F_GROUP(first); if (preserve_devices && IS_DEVICE(mode)) { uint32 *devp = F_RDEV_P(first); - rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp)); + rdev_major = DEV_MAJOR(devp); + rdev = MAKEDEV(rdev_major, DEV_MINOR(devp)); extra_len += DEV_EXTRA_CNT * EXTRA_LEN; } if (preserve_links && S_ISLNK(mode))