[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35713: /dev/stdin problem in cp on Solaris

From: jakub . kulik
Subject: bug#35713: /dev/stdin problem in cp on Solaris
Date: Mon, 13 May 2019 12:24:17 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0


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.


Attachment: copy.c.patch
Description: Text Data

Attachment: stdin_test.c
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]