Subject: bug#19508: [bug-diffutils] bug#19508: bug#19508: [PATCH] diff: compare major, minor numbers of block/character special files

From: Ondřej Svoboda <[email-masked]>
Date: Sat, 12 Mar 2016 15:16:49 +0100

Please see the follow-up on testing below.

On 12.3.2016 14:55, Ondřej Svoboda wrote:
> Hi everybody,
>
> I rebased the patch on current master and tested it (as root) like this:
>
> # mkdir /tmp/a /tmp/b
> # mknod /tmp/a/block1 b 1 2; mknod /tmp/b/block1 b 1 2
> # mknod /tmp/a/block2 b 2 3; mknod /tmp/b/block2 b 2 4
> # mknod /tmp/a/block3 b 3 4; mknod /tmp/b/block3 b 5 4
> # mknod /tmp/a/char1 c 1 2; mknod /tmp/b/char1 c 1 2
> # mknod /tmp/a/char2 c 2 3; mknod /tmp/b/char2 c 2 4
> # mknod /tmp/a/char3 c 3 4; mknod /tmp/b/char3 c 5 4
>
> # LC_ALL=C ls -l /tmp/a
> total 0
> brw-r--r-- 1 root root 1, 2 Mar 12 14:51 block1
> brw-r--r-- 1 root root 2, 3 Mar 12 14:51 block2
> brw-r--r-- 1 root root 3, 4 Mar 12 14:51 block3
> crw-r--r-- 1 root root 1, 2 Mar 12 14:51 char1
> crw-r--r-- 1 root root 2, 3 Mar 12 14:51 char2
> crw-r--r-- 1 root root 3, 4 Mar 12 14:51 char3
>
> # LC_ALL=C ls -l /tmp/b
> total 0
> brw-r--r-- 1 root root 1, 2 Mar 12 14:51 block1
> brw-r--r-- 1 root root 2, 4 Mar 12 14:51 block2
> brw-r--r-- 1 root root 5, 4 Mar 12 14:51 block3
> crw-r--r-- 1 root root 1, 2 Mar 12 14:51 char1
> crw-r--r-- 1 root root 2, 4 Mar 12 14:51 char2
> crw-r--r-- 1 root root 5, 4 Mar 12 14:51 char3
>
> # LC_ALL=C diff -s -r /tmp/a /tmp/b
> Files /tmp/a/block1 and /tmp/b/block1 are identical
> File /tmp/a/block2 is a block special file while file /tmp/b/block2 is 
> a block special file
> File /tmp/a/block3 is a block special file while file /tmp/b/block3 is 
> a block special file
> Files /tmp/a/char1 and /tmp/b/char1 are identical
> File /tmp/a/char2 is a character special file while file /tmp/b/char2 
> is a character special file
> File /tmp/a/char3 is a character special file while file /tmp/b/char3 
> is a character special file
>
> # LC_ALL=C /usr/local/bin/diff -s -r /tmp/a /tmp/b
> Files /tmp/a/block1 and /tmp/b/block1 are identical
> Block special files /tmp/a/block2 and /tmp/b/block2 differ: 2,3 (2,4)
> Block special files /tmp/a/block3 and /tmp/b/block3 differ: 3,4 (5,4)
> Files /tmp/a/char1 and /tmp/b/char1 are identical
> Character special files /tmp/a/char2 and /tmp/b/char2 differ: 2,3 (2,4)
> Character special files /tmp/a/char3 and /tmp/b/char3 differ: 3,4 (5,4)
>
> The reason why diff compared block1 as identical perhaps because it 
> descended to diff_2_files, I would know if I stepped through the code 
> which I currently don't have much time to do.

# touch /tmp/b/*

# LC_ALL=C ls -l /tmp/b
total 0
brw-r--r-- 1 root root 1, 2 Mar 12 15:09 block1
brw-r--r-- 1 root root 2, 4 Mar 12 15:09 block2
brw-r--r-- 1 root root 5, 4 Mar 12 15:09 block3
crw-r--r-- 1 root root 1, 2 Mar 12 15:09 char1
crw-r--r-- 1 root root 2, 4 Mar 12 15:09 char2
crw-r--r-- 1 root root 5, 4 Mar 12 15:09 char3

# LC_ALL=C diff -s -r /tmp/a /tmp/b
File /tmp/a/block1 is a block special file while file /tmp/b/block1 is a 
block special file
File /tmp/a/block2 is a block special file while file /tmp/b/block2 is a 
block special file
File /tmp/a/block3 is a block special file while file /tmp/b/block3 is a 
block special file
File /tmp/a/char1 is a character special file while file /tmp/b/char1 is 
a character special file
File /tmp/a/char2 is a character special file while file /tmp/b/char2 is 
a character special file
File /tmp/a/char3 is a character special file while file /tmp/b/char3 is 
a character special file

# LC_ALL=C /usr/local/bin/diff -s -r /tmp/a /tmp/b :(
Files /tmp/a/block1 and /tmp/b/block1 are identical
Block special files /tmp/a/block2 and /tmp/b/block2 differ: 2,3 (2,4)
Block special files /tmp/a/block3 and /tmp/b/block3 differ: 3,4 (5,4)
Files /tmp/a/char1 and /tmp/b/char1 are identical
Character special files /tmp/a/char2 and /tmp/b/char2 differ: 2,3 (2,4)
Character special files /tmp/a/char3 and /tmp/b/char3 differ: 3,4 (5,4)

After changing the modification datetime, both block1 and char1 compared 
differently with diffutils 3.3-2 (on Arch Linux) while they were found 
to be the same with the patched diff from master.

> Please share your comments!
>
> Cheers,
> Ondra