Subject: bin/30779: diff fails to recognise identical special files
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <apb@cequrux.com>
List: netbsd-bugs
Date: 07/19/2005 11:56:00
>Number: 30779
>Category: bin
>Synopsis: diff fails to recognise identical special files
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 19 11:56:00 +0000 2005
>Originator: Alan Barrett
>Release: NetBSD 3.99.7
>Organization:
Not much
>Environment:
System: NetBSD 3.99.7
Architecture: i386
Machine: i386
>Description:
When diff(1) is asked to compare special files, it outputs
information like
/dev/null is a character special file while /altroot/dev/null is a character special file
I would prefer it to be silent when both files are identical.
>How-To-Repeat:
# mkdir /altroot
# cp -RPp /dev /altroot/dev
# diff -r -u3 /dev /altroot/dev | grep "special file while .* special file" | wc
2057 30855 207216
>Fix:
Apply the following patch.
Index: gnu/dist/diffutils/src/diff.c
===================================================================
RCS file: /usr/netbsd/anoncvs/main/src/gnu/dist/diffutils/src/diff.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 diff.c
--- src/diff.c 26 Jan 2003 00:43:16 -0000 1.1.1.1
+++ src/diff.c 19 Jul 2005 11:45:56 -0000
@@ -1208,9 +1208,10 @@
else if ((same_files
= (cmp.file[0].desc != NONEXISTENT
&& cmp.file[1].desc != NONEXISTENT
- && 0 < same_file (&cmp.file[0].stat, &cmp.file[1].stat)
- && same_file_attributes (&cmp.file[0].stat,
- &cmp.file[1].stat)))
+ && (same_special_file (&cmp.file[0].stat, &cmp.file[1].stat)
+ || (0 < same_file (&cmp.file[0].stat, &cmp.file[1].stat)
+ && same_file_attributes (&cmp.file[0].stat,
+ &cmp.file[1].stat)))))
&& no_diff_means_no_output)
{
/* The two named files are actually the same physical file.
Index: gnu/dist/diffutils/src/system.h
===================================================================
RCS file: /usr/netbsd/anoncvs/main/src/gnu/dist/diffutils/src/system.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 system.h
--- src/system.h 26 Jan 2003 00:43:16 -0000 1.1.1.1
+++ src/system.h 19 Jul 2005 11:45:56 -0000
@@ -349,7 +349,7 @@
/* Do struct stat *S, *T describe the same special file? */
#ifndef same_special_file
-# if HAVE_ST_RDEV && defined S_ISBLK && defined S_ISCHR
+# if HAVE_STRUCT_STAT_ST_RDEV && defined S_ISBLK && defined S_ISCHR
# define same_special_file(s, t) \
(((S_ISBLK ((s)->st_mode) && S_ISBLK ((t)->st_mode)) \
|| (S_ISCHR ((s)->st_mode) && S_ISCHR ((t)->st_mode))) \