GNU bug report logs - #19509
[PATCH] diff: treat fifos as identical

Previous Next

Package: diffutils;

Reported by: Ondřej Svoboda <ondrej <at> svobodasoft.cz>

Date: Sun, 4 Jan 2015 21:24:03 UTC

Severity: normal

Tags: notabug, patch

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19509 in the body.
You can then email your comments to 19509 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-diffutils <at> gnu.org:
bug#19509; Package diffutils. (Sun, 04 Jan 2015 21:24:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ondřej Svoboda <ondrej <at> svobodasoft.cz>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Sun, 04 Jan 2015 21:24:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ondřej Svoboda <ondrej <at> svobodasoft.cz>
To: bug-diffutils <at> gnu.org
Subject: [PATCH] diff: treat fifos as identical
Date: Sun, 04 Jan 2015 22:05:17 +0100
(Continuation of the previous patch; may I ask the good people of the 
list to review both?)

This avoids unwanted "differences" like

  File dev1/fifo1 is a fifo while file dev2/fifo1 is a fifo
---
 src/diff.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/diff.c b/src/diff.c
index a3e1b6f..cf2c62a 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1299,6 +1299,11 @@ compare_files (struct comparison const *parent,
 	      status = EXIT_FAILURE;
 	    }
 	}
+      else if (S_ISFIFO (cmp.file[0].stat.st_mode)
+               && S_ISFIFO (cmp.file[0].stat.st_mode))
+	{
+	  /* Both are fifos.  */
+	}
       else
 	{
 	  /* We have two files that are not to be compared.  */
-- 
2.2.1





Information forwarded to bug-diffutils <at> gnu.org:
bug#19509; Package diffutils. (Wed, 11 Feb 2015 23:30:03 GMT) Full text and rfc822 format available.

Message #8 received at 19509 <at> debbugs.gnu.org (full text, mbox):

From: Ondřej Svoboda <ondrej <at> svobodasoft.cz>
To: 19509 <at> debbugs.gnu.org
Cc: eggert <at> cs.ucla.edu
Subject: Re: [bug-diffutils] bug#19509: [PATCH] diff: treat fifos as identical
Date: Thu, 12 Feb 2015 00:29:03 +0100
Hello Paul,

may I ask you to review this little patch (and its successor that I will 
be also bumping shortly)?

Thank you! :-)

Regards,
Ondra Svoboda

On 4.1.2015 22:05, Ondřej Svoboda wrote:
> (Continuation of the previous patch; may I ask the good people of the 
> list to review both?)
>
> This avoids unwanted "differences" like
>
>   File dev1/fifo1 is a fifo while file dev2/fifo1 is a fifo
> ---
>  src/diff.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/diff.c b/src/diff.c
> index a3e1b6f..cf2c62a 100644
> --- a/src/diff.c
> +++ b/src/diff.c
> @@ -1299,6 +1299,11 @@ compare_files (struct comparison const *parent,
>            status = EXIT_FAILURE;
>          }
>      }
> +      else if (S_ISFIFO (cmp.file[0].stat.st_mode)
> +               && S_ISFIFO (cmp.file[0].stat.st_mode))
> +    {
> +      /* Both are fifos.  */
> +    }
>        else
>      {
>        /* We have two files that are not to be compared.  */





Information forwarded to bug-diffutils <at> gnu.org:
bug#19509; Package diffutils. (Wed, 11 Feb 2015 23:32:02 GMT) Full text and rfc822 format available.

Message #11 received at 19509 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Ondřej Svoboda <ondrej <at> svobodasoft.cz>, 
 19509 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#19509: [PATCH] diff: treat fifos as identical
Date: Wed, 11 Feb 2015 15:30:49 -0800
Ondřej Svoboda wrote:
>       }
> +      else if (S_ISFIFO (cmp.file[0].stat.st_mode)
> +               && S_ISFIFO (cmp.file[0].stat.st_mode))
> +    {
> +      /* Both are fifos.  */
> +    }

If they're the *same* fifo, they should compare the same (and already do, if I'm 
not mistaken).  But if they're *different* fifos?




Information forwarded to bug-diffutils <at> gnu.org:
bug#19509; Package diffutils. (Wed, 11 Feb 2015 23:38:02 GMT) Full text and rfc822 format available.

Message #14 received at 19509 <at> debbugs.gnu.org (full text, mbox):

From: Ondřej Svoboda <ondrej <at> svobodasoft.cz>
To: Paul Eggert <eggert <at> cs.ucla.edu>, 19509 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#19509: [PATCH] diff: treat fifos as identical
Date: Thu, 12 Feb 2015 00:37:22 +0100
I also posed this question to myself -- how can we tell two fifos apart? 
Do they by any chance store e.g. a file descriptor when they are being used?

I am not aware of any comparison done to fifos but I may as well be wrong.

On 12.2.2015 00:30, Paul Eggert wrote:
> Ondřej Svoboda wrote:
>>       }
>> +      else if (S_ISFIFO (cmp.file[0].stat.st_mode)
>> +               && S_ISFIFO (cmp.file[0].stat.st_mode))
>> +    {
>> +      /* Both are fifos.  */
>> +    }
>
> If they're the *same* fifo, they should compare the same (and already 
> do, if I'm not mistaken).  But if they're *different* fifos?
>





Information forwarded to bug-diffutils <at> gnu.org:
bug#19509; Package diffutils. (Thu, 12 Feb 2015 00:26:01 GMT) Full text and rfc822 format available.

Message #17 received at 19509 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Ondřej Svoboda <ondrej <at> svobodasoft.cz>,
 Paul Eggert <eggert <at> cs.ucla.edu>, 19509 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#19509: bug#19509: [PATCH] diff: treat fifos
 as identical
Date: Wed, 11 Feb 2015 17:25:42 -0700
[Message part 1 (text/plain, inline)]
On 02/11/2015 04:37 PM, Ondřej Svoboda wrote:
> I also posed this question to myself -- how can we tell two fifos apart?
> Do they by any chance store e.g. a file descriptor when they are being
> used?
> 
> I am not aware of any comparison done to fifos but I may as well be wrong.

fstat() will tell you if two fds are the same fifo - their st_dev and
st_ino will be equal.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-diffutils <at> gnu.org:
bug#19509; Package diffutils. (Thu, 12 Feb 2015 04:23:02 GMT) Full text and rfc822 format available.

Message #20 received at 19509 <at> debbugs.gnu.org (full text, mbox):

From: Ondřej Svoboda <ondrej <at> svobodasoft.cz>
To: Eric Blake <eblake <at> redhat.com>, Paul Eggert <eggert <at> cs.ucla.edu>, 
 19509 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#19509: bug#19509: [PATCH] diff: treat fifos
 as identical
Date: Thu, 12 Feb 2015 05:22:11 +0100
Thank you, Eric!

I will try it out.

On 12.2.2015 01:25, Eric Blake wrote:
> On 02/11/2015 04:37 PM, Ondřej Svoboda wrote:
>> I also posed this question to myself -- how can we tell two fifos apart?
>> Do they by any chance store e.g. a file descriptor when they are being
>> used?
>>
>> I am not aware of any comparison done to fifos but I may as well be wrong.
> fstat() will tell you if two fds are the same fifo - their st_dev and
> st_ino will be equal.
>





Information forwarded to bug-diffutils <at> gnu.org:
bug#19509; Package diffutils. (Fri, 05 May 2017 16:41:02 GMT) Full text and rfc822 format available.

Message #23 received at 19509 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Ondřej Svoboda <ondrej <at> svobodasoft.cz>
Cc: Paul Eggert <eggert <at> cs.ucla.edu>, Eric Blake <eblake <at> redhat.com>,
 19509 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#19509: bug#19509: bug#19509: [PATCH] diff:
 treat fifos as identical
Date: Fri, 5 May 2017 09:40:12 -0700
close 19509
tags 19509 notabug
thanks

On Wed, Feb 11, 2015 at 8:22 PM, Ondřej Svoboda <ondrej <at> svobodasoft.cz> wrote:
> Thank you, Eric!
>
> I will try it out.
>
>
> On 12.2.2015 01:25, Eric Blake wrote:
>>
>> On 02/11/2015 04:37 PM, Ondřej Svoboda wrote:
>>>
>>> I also posed this question to myself -- how can we tell two fifos apart?
>>> Do they by any chance store e.g. a file descriptor when they are being
>>> used?
>>>
>>> I am not aware of any comparison done to fifos but I may as well be
>>> wrong.
>>
>> fstat() will tell you if two fds are the same fifo - their st_dev and
>> st_ino will be equal.

As far as I can see, diff already does the right thing: If the two
fifos are the same dev/ino, it doesn't even read them and exits 0.
Otherwise, it reads each and compares, just as for other types of files.

I'm marking this auto-created issue as "done", and "notabug", but feel
free to comment here.




bug closed, send any further explanations to 19509 <at> debbugs.gnu.org and Ondřej Svoboda <ondrej <at> svobodasoft.cz> Request was from Jim Meyering <jim <at> meyering.net> to control <at> debbugs.gnu.org. (Fri, 05 May 2017 16:41:02 GMT) Full text and rfc822 format available.

Added tag(s) notabug. Request was from Jim Meyering <jim <at> meyering.net> to control <at> debbugs.gnu.org. (Fri, 05 May 2017 16:41:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 03 Jun 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.