Email List: Xaustin-review-lX
[All Lists]

Defect in XCU diff (special files)

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Defect in XCU diff (special files)
From: yyyyyy@xxxxxxxxxxx
Date: Tue, 13 Jun 2006 07:10:43 +0100 (BST)
        Defect report from : Paul Eggert , UCLA

(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)

@ page 320 line 12367 section diff (special files) objection {20060612b}

Problem:

Edition of Specification (Year): 2004

Defect code :  1. Error

Suppose /dev is a directory that contains only /dev/null, /dev/tty,
and /dev/console, and these are all character special files.  Then
POSIX requires that in the POSIX locale the command "diff /dev /dev"
must output the following set of messages:

   File /dev/console is a character special file while file /dev/console is a 
character special file
   File /dev/null is a character special file while file /dev/null is a 
character special file
   File /dev/tty is a character special file while file /dev/tty is a character 
special file

But neither Solaris 10 diff nor GNU diff behave this way.  They both
output nothing, since they notice that the files in question have the
the same device and inode numbers, and therefore must be the same.

Furthermore, suppose we attempt to force the issue, as follows:

   mkdir dev1
   ln -s /dev/console dev1/null
   ln -s /dev/null dev1/console
   ln -s /dev/tty dev1/tty
   diff /dev dev1

Then POSIX requires the output to look like this:

   File /dev/console is a character special file while file dev1/console is a 
character special file
   File /dev/null is a character special file while file dev1/null is a 
character special file
   File /dev/tty is a character special file while file dev1/tty is a character 
special file

But neither Solaris 10 nor GNU diff behave that way.  Solaris 10 diff
outputs this:

  Special files /dev/console and dev1/console differ
  Special files /dev/null and dev1/null differ

which does not use the POSIX-required format even for the lines that
it does output.  GNU diff outputs this:

  File /dev/console is a character special file while file dev1/console is a 
character special file
  File /dev/null is a character special file while file dev1/null is a 
character special file

which does use the POSIX-required formats but omits the last line
required by POSIX.

The POSIX requirements here have been widely ignored for years without
anyone seeming to care much.  They require confusing output (as shown
by the examples above) which my users have often complained about.
The requirements should be revised to allow better 'diff'
implementations that might generate more-useful output.  For example,
if 'diff' observes two different character-special files with the same
major and minor device numbers, it should be allowed to output
nothing; if it observes two character-special files with differing
device numbers, it should be allowed to report the differences in
device numbers.


Action:

In XCU page 320 lines 12367-12371, change from:

  For each file common to the two directories if the two files are not
  to be compared, the following format shall be used in the POSIX
  locale:

  "File %s is a %s while file %s is a %s\n",
    <directory1 pathname>, <file type of directory1 pathname>,
    <directory2 pathname>, <file type of directory2 pathname>,

to:

  For each file common to the two directories if the two files are not
  to be compared: if the two files have the same device ID and file
  serial number, or are both block special files that refer to the
  same device, or are both character special files that refer to the
  same device, in the POSIX locale the output format is unspecified.
  Otherwise, in the POSIX locale an unspecified format shall be used
  that contains the pathnames of the two files.

In XCU page 325 lines 12543-12546 change from:

  The message specified here is already in use when a directory is
  being compared to a non-directory.  It is extended here to preclude
  the problems arising from running into FIFOs and other files that
  would cause 'diff' to hang waiting for input with no indication to
  the user that 'diff' was hung.

to:

  The specified behavior precludes
  the problems arising from running into FIFOs and other files that
  would cause 'diff' to hang waiting for input with no indication to
  the user that 'diff' was hung.
  A previous edition of this standard specified the output format more
  precisely, but in practice this requirement was widely ignored and
  the benefit of standardization seemed small, so it is now
  unspecified.

<Prev in Thread] Current Thread [Next in Thread>
  • Defect in XCU diff (special files), eggert <=