GNU bug report logs -
#35713
/dev/stdin problem in cp on Solaris
Previous Next
Reported by: jakub.kulik <at> oracle.com
Date: Mon, 13 May 2019 14:21:02 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
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 35713 in the body.
You can then email your comments to 35713 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#35713
; Package
coreutils
.
(Mon, 13 May 2019 14:21:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
jakub.kulik <at> oracle.com
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Mon, 13 May 2019 14:21:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi,
We found out that the following simple command fails on Solaris with:
cat srcfile.txt | /usr/gnu/bin/cp /dev/stdin dstfile.txt
cp: skipping file '/dev/stdin', as it was replaced while being copied
I found that problem is with SAME_INODE macro. It accepts two
structures, one from stat and another from fstat function. On Solaris,
each of these can return a different thing. While stat returns
information about the /dev/fd/0 file itself (linked by /dev/stdin),
fstat knows much more from the file descriptor and returns info about
the pipe that is being used. That results in SAME_INODE failing.
This happens in both Coreutils 8.30 and 8.31 (both intel and sparc) but
it looks like it was seen first in 8.16.
The easiest fix to this issue I came up with is to disable SAME_INODE
validation for special devices and pipes (as they won't be moved
anyway). Patch is attached as well as small program that can show stat
and fstat differences on Solaris.
Thanks
Jakub
[copy.c.patch (text/x-patch, attachment)]
[stdin_test.c (text/x-csrc, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#35713
; Package
coreutils
.
(Sun, 26 May 2019 12:26:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 35713 <at> debbugs.gnu.org (full text, mbox):
On 13/05/19 11:24, jakub.kulik <at> oracle.com wrote:
> Hi,
>
> We found out that the following simple command fails on Solaris with:
>
> cat srcfile.txt | /usr/gnu/bin/cp /dev/stdin dstfile.txt
> cp: skipping file '/dev/stdin', as it was replaced while being copied
>
> I found that problem is with SAME_INODE macro. It accepts two
> structures, one from stat and another from fstat function. On Solaris,
> each of these can return a different thing. While stat returns
> information about the /dev/fd/0 file itself (linked by /dev/stdin),
> fstat knows much more from the file descriptor and returns info about
> the pipe that is being used. That results in SAME_INODE failing.
>
> This happens in both Coreutils 8.30 and 8.31 (both intel and sparc) but
> it looks like it was seen first in 8.16.
>
> The easiest fix to this issue I came up with is to disable SAME_INODE
> validation for special devices and pipes (as they won't be moved
> anyway)
But what if a file is replaced with a character special device for example?
How about doing something like the following before the SAME_INODE check?
#if _solaris
if (S_IFMT(source_desc) != S_IFMT(src_open_sb)
stat(src_name, &src_open_sb);
#endif
cheers,
Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#35713
; Package
coreutils
.
(Mon, 27 May 2019 14:32:03 GMT)
Full text and
rfc822 format available.
Message #11 received at 35713 <at> debbugs.gnu.org (full text, mbox):
Well, I guess that while improbable, that can happen. I am only thinking
whether is it possible that both stat and fstat return different devices
with same S_IFMT but I am not sure about that.
Anyway I tried it with your suggestion and for my use case it works as well.
regards,
Jakub
On 5/26/19 2:25 PM, Pádraig Brady wrote:
> On 13/05/19 11:24, jakub.kulik <at> oracle.com wrote:
>> Hi,
>>
>> We found out that the following simple command fails on Solaris with:
>>
>> cat srcfile.txt | /usr/gnu/bin/cp /dev/stdin dstfile.txt
>> cp: skipping file '/dev/stdin', as it was replaced while being copied
>>
>> I found that problem is with SAME_INODE macro. It accepts two
>> structures, one from stat and another from fstat function. On Solaris,
>> each of these can return a different thing. While stat returns
>> information about the /dev/fd/0 file itself (linked by /dev/stdin),
>> fstat knows much more from the file descriptor and returns info about
>> the pipe that is being used. That results in SAME_INODE failing.
>>
>> This happens in both Coreutils 8.30 and 8.31 (both intel and sparc) but
>> it looks like it was seen first in 8.16.
>>
>> The easiest fix to this issue I came up with is to disable SAME_INODE
>> validation for special devices and pipes (as they won't be moved
>> anyway)
> But what if a file is replaced with a character special device for example?
> How about doing something like the following before the SAME_INODE check?
>
> #if _solaris
> if (S_IFMT(source_desc) != S_IFMT(src_open_sb)
> stat(src_name, &src_open_sb);
> #endif
>
> cheers,
> Pádraig
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#35713
; Package
coreutils
.
(Tue, 28 May 2019 14:38:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 35713 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi,
I found a problem with your solution (even though maybe even more
improbable). If I call it like this: *cp /dev/stdin b.txt < somedevice*,
both stdin and the argument have the same type and copy still fails.
Possible solution might be to call stat when SAME_INODE fails and try it
again (regular files and folders can be excluded).
Jakub
On 5/27/19 12:59 PM, jakub.kulik <at> oracle.com wrote:
> Well, I guess that while improbable, that can happen. I am only
> thinking whether is it possible that both stat and fstat return
> different devices with same S_IFMT but I am not sure about that.
>
> Anyway I tried it with your suggestion and for my use case it works as
> well.
>
> regards,
> Jakub
>
> On 5/26/19 2:25 PM, Pádraig Brady wrote:
>> On 13/05/19 11:24, jakub.kulik <at> oracle.com wrote:
>>> Hi,
>>>
>>> We found out that the following simple command fails on Solaris with:
>>>
>>> cat srcfile.txt | /usr/gnu/bin/cp /dev/stdin dstfile.txt
>>> cp: skipping file '/dev/stdin', as it was replaced while being
>>> copied
>>>
>>> I found that problem is with SAME_INODE macro. It accepts two
>>> structures, one from stat and another from fstat function. On Solaris,
>>> each of these can return a different thing. While stat returns
>>> information about the /dev/fd/0 file itself (linked by /dev/stdin),
>>> fstat knows much more from the file descriptor and returns info about
>>> the pipe that is being used. That results in SAME_INODE failing.
>>>
>>> This happens in both Coreutils 8.30 and 8.31 (both intel and sparc) but
>>> it looks like it was seen first in 8.16.
>>>
>>> The easiest fix to this issue I came up with is to disable SAME_INODE
>>> validation for special devices and pipes (as they won't be moved
>>> anyway)
>> But what if a file is replaced with a character special device for
>> example?
>> How about doing something like the following before the SAME_INODE
>> check?
>>
>> #if _solaris
>> if (S_IFMT(source_desc) != S_IFMT(src_open_sb)
>> stat(src_name, &src_open_sb);
>> #endif
>>
>> cheers,
>> Pádraig
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#35713
; Package
coreutils
.
(Tue, 28 May 2019 20:47:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 35713 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks for reporting the problem. Please try the attached patch, which
I've installed in the development repository.
[0001-cp-fix-dev-stdin-problem-on-Solaris.patch (text/x-patch, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#35713
; Package
coreutils
.
(Wed, 29 May 2019 08:52:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 35713 <at> debbugs.gnu.org (full text, mbox):
Hi,
thanks for the patch - I tested it and all seems to work with both pipe
and <<, coreutils test suite is also happy.
Just a small correction on my part, somebody found this bug first at
8.16, but this might have been there for longer.
thanks
Jakub
On 5/28/19 10:46 PM, Paul Eggert wrote:
> Thanks for reporting the problem. Please try the attached patch, which
> I've installed in the development repository.
>
>
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#35713
; Package
coreutils
.
(Wed, 29 May 2019 23:47:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 35713 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 5/29/19 1:51 AM, jakub.kulik <at> oracle.com wrote:
> somebody found this bug first at 8.16, but this might have been there
> for longer.
I looked into the revision history and it seems to have been introduced
long ago. I installed the attached further patch.
[0001-maint-fix-version-number-in-NEWS.patch (text/x-patch, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#35713
; Package
coreutils
.
(Thu, 30 May 2019 13:42:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 35713 <at> debbugs.gnu.org (full text, mbox):
Thanks,
I tested the patch on both intel and sparc platform and all seems to
work without any problem.
So I guess this can be closed as solved.
best regards,
Jakub
On 5/30/19 1:46 AM, Paul Eggert wrote:
> On 5/29/19 1:51 AM, jakub.kulik <at> oracle.com wrote:
>> somebody found this bug first at 8.16, but this might have been there
>> for longer.
>
> I looked into the revision history and it seems to have been
> introduced long ago. I installed the attached further patch.
>
>
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Sun, 02 Jun 2019 06:01:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
jakub.kulik <at> oracle.com
:
bug acknowledged by developer.
(Sun, 02 Jun 2019 06:01:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 35713-done <at> debbugs.gnu.org (full text, mbox):
jakub.kulik <at> oracle.com wrote:
> I tested the patch on both intel and sparc platform and all seems to work
> without any problem.
>
> So I guess this can be closed as solved.
Thanks for checking; closing.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 30 Jun 2019 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 302 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.