From unknown Sat Aug 09 20:51:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35713: /dev/stdin problem in cp on Solaris Resent-From: jakub.kulik@oracle.com Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 13 May 2019 14:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35713 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 35713@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155775724812942 (code B ref -1); Mon, 13 May 2019 14:21:02 +0000 Received: (at submit) by debbugs.gnu.org; 13 May 2019 14:20:48 +0000 Received: from localhost ([127.0.0.1]:45839 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQBor-0003Mc-SK for submit@debbugs.gnu.org; Mon, 13 May 2019 10:20:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37625) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQ884-0001vn-ES for submit@debbugs.gnu.org; Mon, 13 May 2019 06:24:21 -0400 Received: from lists.gnu.org ([209.51.188.17]:44675) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ87z-00020x-6q for submit@debbugs.gnu.org; Mon, 13 May 2019 06:24:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ87y-0001WK-2r for bug-coreutils@gnu.org; Mon, 13 May 2019 06:24:15 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_40,RCVD_IN_DNSWL_MED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ87x-0001zz-38 for bug-coreutils@gnu.org; Mon, 13 May 2019 06:24:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59984) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ87w-0001yf-OL for bug-coreutils@gnu.org; Mon, 13 May 2019 06:24:13 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4DANaf1166111 for ; Mon, 13 May 2019 10:24:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=p/gULuffRJVkJKcYX+jXTZGUbJUd3gMWmpJJx12nN8Y=; b=o+UpUy0m0mVl477mwCQmWmDAdSFV7g/Q6un2mYK83VOx7uOesaSeI/yz9JpzaWkvt6tT ZjxtTF3OkACXukoK7CpdP0SXgUj0TwqPFaN2/i03xhNxftY8PYABn8xtT5a/CCHgTOwF tF+AxXIMg2CZRQ/Iaif1dhNf1+vDaTGAOo5fldm1JGB/Ik4W8CNjojXu2K+VqbeBWawi ruNvT3YZYMclfICjCToRX/CYBdlj7q8nPMKE8QkpoyIezHH3+/RaDgTbXda6lJc2HOqs VuXvPh0XDyVw6c6ak44/VuD3AuQXjBNs6twnHvMk+9MlI/rEx2vGaXcg7yGsBjzy6xyU lw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2sdq1q5ujb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 13 May 2019 10:24:08 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4DAO8Qg185615 for ; Mon, 13 May 2019 10:24:08 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2sf3cmjyd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 13 May 2019 10:24:08 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4DAO5Ke004781 for ; Mon, 13 May 2019 10:24:06 GMT Received: from [10.163.46.162] (/10.163.46.162) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 May 2019 10:24:05 +0000 From: jakub.kulik@oracle.com Organization: Oracle Corporation Message-ID: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> 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 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------200898F4048188F26FCAF9FD" Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9255 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905130075 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9255 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905130075 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: -1.3 (-) X-Mailman-Approved-At: Mon, 13 May 2019 10:20:44 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------200898F4048188F26FCAF9FD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id x4DANaf1166111 Hi, We found out that the following simple command fails on Solaris with: =C2=A0cat srcfile.txt | /usr/gnu/bin/cp /dev/stdin dstfile.txt =C2=A0cp: skipping file '/dev/stdin', as it was replaced while being cop= ied I found that problem is with SAME_INODE macro. It accepts two=20 structures, one from stat and another from fstat function. On Solaris,=20 each of these can return a different thing. While stat returns=20 information about the /dev/fd/0 file itself (linked by /dev/stdin),=20 fstat knows much more from the file descriptor and returns info about=20 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=20 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=20 validation for special devices and pipes (as they won't be moved=20 anyway). Patch is attached as well as small program that can show stat=20 and fstat differences on Solaris. Thanks Jakub --------------200898F4048188F26FCAF9FD Content-Type: text/x-patch; name="copy.c.patch" Content-Disposition: attachment; filename="copy.c.patch" Content-Transfer-Encoding: 7bit --- src/copy.c +++ src/copy.c @@ -1050,11 +1050,18 @@ copy_reg (char const *src_name, char con saved ones obtained via a previous call to stat. */ if (! SAME_INODE (*src_sb, src_open_sb)) { - error (0, 0, - _("skipping file %s, as it was replaced while being copied"), - quoteaf (src_name)); - return_val = false; - goto close_src_desc; + /* Stat and fstat returns different results on Solaris for devices + like /dev/stdin. Confirm that this is not the case. */ + mode_t file_type = src_open_sb.st_mode & S_IFMT; + if (!(file_type == S_IFBLK || file_type == S_IFCHR || + file_type == S_IFIFO || file_type == S_IFSOCK)) + { + error (0, 0, + _("skipping file %s, as it was replaced while being copied"), + quoteaf (src_name)); + return_val = false; + goto close_src_desc; + } } /* The semantics of the following open calls are mandated --------------200898F4048188F26FCAF9FD Content-Type: text/x-csrc; name="stdin_test.c" Content-Disposition: attachment; filename="stdin_test.c" Content-Transfer-Encoding: 7bit #include #include #include #include #include #include int main() { int source_desc; struct stat sb; char* src_name = "/dev/stdin"; source_desc = open(src_name, (O_RDONLY)); if (source_desc < 0) { printf("cannot open %s for reading\n", src_name); return 1; } if (fstat (source_desc, &sb) != 0) { printf("cannot fstat %s\n", src_name); return 2; } printf("fstat results:\n"); printf("fd: %d\n", source_desc); printf("ino: %lu, dev: %lu\n", sb.st_ino, sb.st_dev); /* Get the same info from stat */ if (stat(src_name, &sb) != 0) { printf("cannot fstat %s\n", src_name); return 3; } printf("Stat results:\n"); printf("ino: %lu, dev: %lu\n", sb.st_ino, sb.st_dev); return 0; } --------------200898F4048188F26FCAF9FD-- From unknown Sat Aug 09 20:51:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35713: /dev/stdin problem in cp on Solaris Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sun, 26 May 2019 12:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35713 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: jakub.kulik@oracle.com, 35713@debbugs.gnu.org Received: via spool by 35713-submit@debbugs.gnu.org id=B35713.155887352512305 (code B ref 35713); Sun, 26 May 2019 12:26:02 +0000 Received: (at 35713) by debbugs.gnu.org; 26 May 2019 12:25:25 +0000 Received: from localhost ([127.0.0.1]:50482 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUsDM-0003CP-OH for submit@debbugs.gnu.org; Sun, 26 May 2019 08:25:25 -0400 Received: from mail.magicbluesmoke.com ([82.195.144.49]:47616) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUsDL-0003CE-18 for 35713@debbugs.gnu.org; Sun, 26 May 2019 08:25:23 -0400 Received: from localhost.localdomain (unknown [109.76.219.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 94ACEA366; Sun, 26 May 2019 13:25:21 +0100 (IST) References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> Date: Sun, 26 May 2019 13:25:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 13/05/19 11:24, jakub.kulik@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 From unknown Sat Aug 09 20:51:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35713: /dev/stdin problem in cp on Solaris Resent-From: jakub.kulik@oracle.com Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 27 May 2019 14:32:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35713 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , 35713@debbugs.gnu.org Received: via spool by 35713-submit@debbugs.gnu.org id=B35713.155896748625860 (code B ref 35713); Mon, 27 May 2019 14:32:03 +0000 Received: (at 35713) by debbugs.gnu.org; 27 May 2019 14:31:26 +0000 Received: from localhost ([127.0.0.1]:53727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVGes-0006ic-9H for submit@debbugs.gnu.org; Mon, 27 May 2019 10:31:26 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60938) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVDMC-0003iI-CE for 35713@debbugs.gnu.org; Mon, 27 May 2019 06:59:56 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4RAwa0H005311; Mon, 27 May 2019 10:59:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=Z8v2WBOu4JUDS6K0odTgUI6Obmu0Qas8WAhYTbOjVZA=; b=2jxLSU1Va/1cN6Ihe5g3qUl/3WYPheNquZtJ9EI13s0GYi0NvXoH+RGDC1XSvbrdwuhY 7IVoGhU7kTMmTuBWkh5qV9JECO+WUmp/ifzSIVomQqFclvW+iJaXhtAG7L3SNfM/u4q6 7qy3+CC6+puSydxIE6AMGrKPy5ltJ4KOlra3D8/wK0EkSbqj49WZ2RoV9CHO8ikb4eQf GYY0EJRoGU6QoIRKT2Z0VKsFG0DpzBc0/EXlIf0XhKhDLXCoOKVoQKMm6oNd+iBvSD4J yJJfW3EhhU+hvq70EIbh0UIvZ0wZQ0KtfGW84ZHHnokEEhb1HxDo16a/cb/T+QCWFsFt vg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2spw4t5rk2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 May 2019 10:59:49 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4RAxju2049061; Mon, 27 May 2019 10:59:49 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2srbdwakb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 May 2019 10:59:49 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4RAxkqP000461; Mon, 27 May 2019 10:59:47 GMT Received: from [10.163.45.13] (/10.163.45.13) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 27 May 2019 03:59:46 -0700 References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> From: jakub.kulik@oracle.com Organization: Oracle Corporation Message-ID: <00c465e9-cea0-29c7-1546-ee0d2412e31a@oracle.com> Date: Mon, 27 May 2019 12:59:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9269 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905270078 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9269 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905270078 X-Spam-Score: -2.3 (--) X-Mailman-Approved-At: Mon, 27 May 2019 10:31:24 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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@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 From unknown Sat Aug 09 20:51:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35713: /dev/stdin problem in cp on Solaris Resent-From: jakub.kulik@oracle.com Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 28 May 2019 14:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35713 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , 35713@debbugs.gnu.org Received: via spool by 35713-submit@debbugs.gnu.org id=B35713.15590542415904 (code B ref 35713); Tue, 28 May 2019 14:38:02 +0000 Received: (at 35713) by debbugs.gnu.org; 28 May 2019 14:37:21 +0000 Received: from localhost ([127.0.0.1]:56737 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVdE8-0001XA-Jv for submit@debbugs.gnu.org; Tue, 28 May 2019 10:37:20 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:34480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVdE5-0001Wt-AH for 35713@debbugs.gnu.org; Tue, 28 May 2019 10:37:18 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4SEY2aH070984; Tue, 28 May 2019 14:37:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : references : message-id : date : mime-version : in-reply-to : content-type; s=corp-2018-07-02; bh=qv36luAu345da9Uu+ivpiciguUEU0gcB5jAScbnks50=; b=Fh7G2DXQIfHQST/KgW+vQxBaMWeemeOHnDtsiQxYlVi8e+LyMkvy4Q3PN/W9oI5bLFDX bfa4L1wlNqawFF4iXXcsmOnk45oFDxvh4mcdxehxddmIEBGoLznkTNI4gXH5s1EU+k/3 WqIyPVPo3sP7LUcD51pR6XK3mAY4EruakcSBgjTicmd2xqeDdnDgkSKZiATnErdDyeXd C4nKDjcAMYvqSjBnHcAdTFt8PzFgmb1PHw02yYiIgvBVjFCS7YUgcWV7LVxEnOrUgbst p5qpAl8D5qQwM4T94tk0WjSkInqqwvhdveFbFnPopdHlUKeDWcRNsSiDNLOLJwbY6JFu rQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 2spu7dbuan-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 May 2019 14:37:11 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4SEZmGg177047; Tue, 28 May 2019 14:37:10 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2srbdwtte9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 May 2019 14:37:10 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4SEb83P022493; Tue, 28 May 2019 14:37:09 GMT Received: from [10.163.45.13] (/10.163.45.13) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 28 May 2019 07:37:08 -0700 From: jakub.kulik@oracle.com References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> <00c465e9-cea0-29c7-1546-ee0d2412e31a@oracle.com> Organization: Oracle Corporation Message-ID: Date: Tue, 28 May 2019 16:37:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <00c465e9-cea0-29c7-1546-ee0d2412e31a@oracle.com> Content-Type: multipart/alternative; boundary="------------B394F550578417F4FAC64FB4" Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9270 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905280094 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9270 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905280095 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------B394F550578417F4FAC64FB4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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@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@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 --------------B394F550578417F4FAC64FB4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

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@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@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
--------------B394F550578417F4FAC64FB4-- From unknown Sat Aug 09 20:51:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35713: /dev/stdin problem in cp on Solaris Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 28 May 2019 20:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35713 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: jakub.kulik@oracle.com Cc: 35713@debbugs.gnu.org, =?UTF-8?Q?P=C3=A1draig?= Brady Received: via spool by 35713-submit@debbugs.gnu.org id=B35713.155907638624000 (code B ref 35713); Tue, 28 May 2019 20:47:02 +0000 Received: (at 35713) by debbugs.gnu.org; 28 May 2019 20:46:26 +0000 Received: from localhost ([127.0.0.1]:57307 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVizK-0006F2-1o for submit@debbugs.gnu.org; Tue, 28 May 2019 16:46:26 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:52888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVizF-0006Ek-GC for 35713@debbugs.gnu.org; Tue, 28 May 2019 16:46:25 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8039A161C08; Tue, 28 May 2019 13:46:15 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id OxRwbkcedh6e; Tue, 28 May 2019 13:46:11 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C76AB161BE7; Tue, 28 May 2019 13:46:11 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1XwLQ4sIFi3D; Tue, 28 May 2019 13:46:11 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4BD41161C08; Tue, 28 May 2019 13:46:09 -0700 (PDT) References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> <00c465e9-cea0-29c7-1546-ee0d2412e31a@oracle.com> From: Paul Eggert Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTY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OGX4O0GA6VOEryO7QRCCYah3oxSG38IAnNeiwJXgU9Bzkk85UGbPEd7HGF /VSeHCQwWou6jqUDTSDvn9YhNTdG0KXPM74aC+xr2Zow1O2mhXihgWKD0Dw+0LYPnUOsQ0KO FxHXXYHmRrS1OZPU59BLvc+TRhIhafSHKLwbXK+6ckkxBx6h8z5ccpG0Qs4bFhdFYnFrEieD LoGmnE2YLhdV6swJ9VNCS6pLiEohT3fm7aXm15tZOIyzMZhHRSAPblXxQ0ZSWjq8oRrcYNFx c4W1URpAkBCOYJoXvQfD5L3lqAl8TCqDUzYxhH/tJhbDdHrqHH767jaDaTB1+Talp/2AMKwc XNOdiklGxbmHVG6YGl6g8Lrbsu9NZEI4yLlHzuikthJWgz+3vZhVGyNlt+HNIoF6CjDL2omu 5cEq4RDHM44QqPk6l7O0pUvN1mT4B+S1b08RKpqm/ff015E37HNV/piIvJlxGAYz8PSfuGCB 1thMYqlmgdhd9/BabGFbGGYHA6U4/T5zqU+f6xHy1SsAQZ1MSKlLwekBIT+4/cLRGqCHjnV0 q5H/T6a7t5mPkbzSrOLSo4puj+IToNjYyYIDBWzhlA19avOa+rvUjmHtD3sFN7cXWtkGoi8b uNcby4U= Organization: UCLA Computer Science Department Message-ID: <3503bb40-3694-f526-6dfd-5601807e0347@cs.ucla.edu> Date: Tue, 28 May 2019 13:46:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------E51850A95D91AC87EB710C86" Content-Language: en-US X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------E51850A95D91AC87EB710C86 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for reporting the problem. Please try the attached patch, which I've installed in the development repository. --------------E51850A95D91AC87EB710C86 Content-Type: text/x-patch; name="0001-cp-fix-dev-stdin-problem-on-Solaris.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-cp-fix-dev-stdin-problem-on-Solaris.patch" >From fe913993d0e93ce98f0b8b77a866144dbb8bbada Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 28 May 2019 12:42:24 -0700 Subject: [PATCH] cp: fix /dev/stdin problem on Solaris Problem reported by Jakub Kulik (Bug#35713). * NEWS: Mention this. * configure.ac (DEV_FD_MIGHT_BE_CHR): New macro. * src/copy.c (DEV_FD_MIGHT_BE_CHR): Default to false. (follow_fstatat): New function. (copy_internal): Use it. * src/copy.h (XSTAT): Remove; no longer used. --- NEWS | 4 ++++ configure.ac | 9 +++++++++ src/copy.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- src/copy.h | 5 ----- 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 12c864dcc..c9f2eff57 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,10 @@ GNU coreutils NEWS -*- outline -*- ** Bug fixes + cp now copies /dev/fd/N correctly on platforms like Solaris where + it is a character-special file whose minor device number is N. + [bug introduced in coreutils-8.16] + df now correctly parses the /proc/self/mountinfo file for unusual entries like ones with '\r' in a field value ("mount -t tmpfs tmpfs /foo$'\r'bar"), when the source field is empty ('mount -t tmpfs "" /mnt'), and when the diff --git a/configure.ac b/configure.ac index 781a305e2..d90c710e3 100644 --- a/configure.ac +++ b/configure.ac @@ -353,6 +353,15 @@ case $utils_cv_func_setpriority,$ac_cv_func_nice in gl_ADD_PROG([optional_bin_progs], [nice]) esac +if test "$cross_compiling" = yes || test -c /dev/stdin <.; then + AC_DEFINE([DEV_FD_MIGHT_BE_CHR], [1], + [Define to 1 if /dev/std{in,out,err} and /dev/fd/N, if they exist, might be + character-special devices whose minor device number is the file + descriptor number, such as on Solaris. Leave undefined if they are + definitely the actual files. This determination should be done after any + symbolic links are followed.]) +fi + AC_DEFUN([coreutils_DUMMY_1], [ AC_REQUIRE([gl_READUTMP]) diff --git a/src/copy.c b/src/copy.c index dc1f6d0fa..65cf65895 100644 --- a/src/copy.c +++ b/src/copy.c @@ -147,6 +147,42 @@ static bool owner_failure_ok (struct cp_options const *x); static char const *top_level_src_name; static char const *top_level_dst_name; +#ifndef DEV_FD_MIGHT_BE_CHR +# define DEV_FD_MIGHT_BE_CHR false +#endif + +/* Act like fstat (DIRFD, FILENAME, ST, FLAGS), except when following + symbolic links on Solaris-like systems, treat any character-special + device like /dev/fd/0 as if it were the file it is open on. */ +static int +follow_fstatat (int dirfd, char const *filename, struct stat *st, int flags) +{ + int result = fstatat (dirfd, filename, st, flags); + + if (DEV_FD_MIGHT_BE_CHR && result == 0 && !(flags & AT_SYMLINK_NOFOLLOW) + && S_ISCHR (st->st_mode)) + { + static dev_t stdin_rdev; + static signed char stdin_rdev_status; + if (stdin_rdev_status == 0) + { + struct stat stdin_st; + if (stat ("/dev/stdin", &stdin_st) == 0 && S_ISCHR (stdin_st.st_mode) + && minor (stdin_st.st_rdev) == STDIN_FILENO) + { + stdin_rdev = stdin_st.st_rdev; + stdin_rdev_status = 1; + } + else + stdin_rdev_status = -1; + } + if (0 < stdin_rdev_status && major (stdin_rdev) == major (st->st_rdev)) + result = fstat (minor (st->st_rdev), st); + } + + return result; +} + /* Set the timestamp of symlink, FILE, to TIMESPEC. If this system lacks support for that, simply return 0. */ static inline int @@ -1010,7 +1046,7 @@ is_probably_sparse (struct stat const *sb) X provides many option settings. Return true if successful. *NEW_DST is as in copy_internal. - SRC_SB is the result of calling XSTAT (aka stat) on SRC_NAME. */ + SRC_SB is the result of calling follow_fstatat on SRC_NAME. */ static bool copy_reg (char const *src_name, char const *dst_name, @@ -1886,7 +1922,9 @@ copy_internal (char const *src_name, char const *dst_name, : rename_errno != EEXIST || x->interactive != I_ALWAYS_NO) { char const *name = rename_errno == 0 ? dst_name : src_name; - if (XSTAT (x, name, &src_sb) != 0) + int fstatat_flags + = x->dereference == DEREF_NEVER ? AT_SYMLINK_NOFOLLOW : 0; + if (follow_fstatat (AT_FDCWD, name, &src_sb, fstatat_flags) != 0) { error (0, errno, _("cannot stat %s"), quoteaf (name)); return false; @@ -1949,7 +1987,7 @@ copy_internal (char const *src_name, char const *dst_name, || x->backup_type != no_backups || x->unlink_dest_before_opening); int fstatat_flags = use_lstat ? AT_SYMLINK_NOFOLLOW : 0; - if (fstatat (AT_FDCWD, dst_name, &dst_sb, fstatat_flags) == 0) + if (follow_fstatat (AT_FDCWD, dst_name, &dst_sb, fstatat_flags) == 0) { have_dst_lstat = use_lstat; rename_errno = EEXIST; @@ -2430,7 +2468,7 @@ copy_internal (char const *src_name, char const *dst_name, if (rename_errno != EXDEV) { /* There are many ways this can happen due to a race condition. - When something happens between the initial XSTAT and the + When something happens between the initial follow_fstatat and the subsequent rename, we can get many different types of errors. For example, if the destination is initially a non-directory or non-existent, but it is created as a directory, the rename diff --git a/src/copy.h b/src/copy.h index 7d2303c54..102516c68 100644 --- a/src/copy.h +++ b/src/copy.h @@ -276,11 +276,6 @@ struct cp_options Hash_table *src_info; }; -# define XSTAT(X, Src_name, Src_sb) \ - ((X)->dereference == DEREF_NEVER \ - ? lstat (Src_name, Src_sb) \ - : stat (Src_name, Src_sb)) - /* Arrange to make rename calls go through the wrapper function on systems with a rename function that fails for a source file name specified with a trailing slash. */ -- 2.21.0 --------------E51850A95D91AC87EB710C86-- From unknown Sat Aug 09 20:51:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35713: /dev/stdin problem in cp on Solaris Resent-From: jakub.kulik@oracle.com Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 29 May 2019 08:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35713 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: 35713@debbugs.gnu.org, =?UTF-8?Q?P=C3=A1draig?= Brady Received: via spool by 35713-submit@debbugs.gnu.org id=B35713.155911987812655 (code B ref 35713); Wed, 29 May 2019 08:52:02 +0000 Received: (at 35713) by debbugs.gnu.org; 29 May 2019 08:51:18 +0000 Received: from localhost ([127.0.0.1]:58058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVuIo-0003I3-Ea for submit@debbugs.gnu.org; Wed, 29 May 2019 04:51:18 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:38374) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hVuIm-0003Hn-B6 for 35713@debbugs.gnu.org; Wed, 29 May 2019 04:51:17 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4T8hwmi130595; Wed, 29 May 2019 08:51:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=5jsOj0fJpn9Y6ymH+/kBuyEgZ7EcEtAi9i+UEWYtQCo=; b=exBhA/x91gZrTvIoy6ocQPlXRQ4CDDVqs4d8iWUe5umg8/t6S+b1ijz2PL5zojj9NryD 9BRSYGSCgovG0EHsxf+ypsr6KvZBrLSD/n2sB7yMpX8IiD08tyuuqif5Sp4a+vbOTgmX 0CheEVqgHFZsalj9ZOCVJAL6Y5bntvTeDod4/7DcdcUvi2xJhbmKWzdO97BXWAcwWCIy n9ucHYNYZvCDGPX3XQzkrtRXbRDp4wFPovoqFguptwMuJizDWKdp4FRi6+IfgXhdUFjN L9D4IS8yrX7BPcAvB8SOaLvLHBX8Oy70S7kdqe7wComRNAsSl27woc2dK60yChKb8oxR 6Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 2spu7dgg0t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 May 2019 08:51:07 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4T8nTcp002795; Wed, 29 May 2019 08:51:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2ss1fnb4w9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 May 2019 08:51:06 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4T8p22C029859; Wed, 29 May 2019 08:51:04 GMT Received: from [10.163.45.13] (/10.163.45.13) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 29 May 2019 01:51:02 -0700 References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> <00c465e9-cea0-29c7-1546-ee0d2412e31a@oracle.com> <3503bb40-3694-f526-6dfd-5601807e0347@cs.ucla.edu> From: jakub.kulik@oracle.com Organization: Oracle Corporation Message-ID: <473e4faf-c770-f201-b1e0-e980bc17396d@oracle.com> Date: Wed, 29 May 2019 10:51:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <3503bb40-3694-f526-6dfd-5601807e0347@cs.ucla.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9271 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905290059 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9271 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905290059 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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. > > From unknown Sat Aug 09 20:51:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35713: /dev/stdin problem in cp on Solaris Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 29 May 2019 23:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35713 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: jakub.kulik@oracle.com Cc: 35713@debbugs.gnu.org, =?UTF-8?Q?P=C3=A1draig?= Brady Received: via spool by 35713-submit@debbugs.gnu.org id=B35713.155917359426681 (code B ref 35713); Wed, 29 May 2019 23:47:01 +0000 Received: (at 35713) by debbugs.gnu.org; 29 May 2019 23:46:34 +0000 Received: from localhost ([127.0.0.1]:60333 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hW8HB-0006wF-34 for submit@debbugs.gnu.org; Wed, 29 May 2019 19:46:34 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39262) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hW8H8-0006vw-SC for 35713@debbugs.gnu.org; Wed, 29 May 2019 19:46:31 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 12886161A3C; Wed, 29 May 2019 16:46:24 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id oSjzq-lyrBNo; Wed, 29 May 2019 16:46:23 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 165F1161A73; Wed, 29 May 2019 16:46:23 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UHcu9rwFCwVG; Wed, 29 May 2019 16:46:22 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E84D2161A3C; Wed, 29 May 2019 16:46:22 -0700 (PDT) References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> <00c465e9-cea0-29c7-1546-ee0d2412e31a@oracle.com> <3503bb40-3694-f526-6dfd-5601807e0347@cs.ucla.edu> <473e4faf-c770-f201-b1e0-e980bc17396d@oracle.com> From: Paul Eggert Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQB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cISVr0G IPplLz6YhjrbHrPRF1CN5UuL9DBGjxuN35RLNVEfta6RUFlR6NctTjvrABEBAAHCwWUEGAEC AA8FAkyAcmQCGwwFCRLMAwAACgkQ7ZfpDmKqfjSrHA/+KzAKvTxRhA9MWNLxIyJ7S5uJ16gs T3oCjZrBKGEhKMOGX4O0GA6VOEryO7QRCCYah3oxSG38IAnNeiwJXgU9Bzkk85UGbPEd7HGF /VSeHCQwWou6jqUDTSDvn9YhNTdG0KXPM74aC+xr2Zow1O2mhXihgWKD0Dw+0LYPnUOsQ0KO FxHXXYHmRrS1OZPU59BLvc+TRhIhafSHKLwbXK+6ckkxBx6h8z5ccpG0Qs4bFhdFYnFrEieD LoGmnE2YLhdV6swJ9VNCS6pLiEohT3fm7aXm15tZOIyzMZhHRSAPblXxQ0ZSWjq8oRrcYNFx c4W1URpAkBCOYJoXvQfD5L3lqAl8TCqDUzYxhH/tJhbDdHrqHH767jaDaTB1+Talp/2AMKwc XNOdiklGxbmHVG6YGl6g8Lrbsu9NZEI4yLlHzuikthJWgz+3vZhVGyNlt+HNIoF6CjDL2omu 5cEq4RDHM44QqPk6l7O0pUvN1mT4B+S1b08RKpqm/ff015E37HNV/piIvJlxGAYz8PSfuGCB 1thMYqlmgdhd9/BabGFbGGYHA6U4/T5zqU+f6xHy1SsAQZ1MSKlLwekBIT+4/cLRGqCHjnV0 q5H/T6a7t5mPkbzSrOLSo4puj+IToNjYyYIDBWzhlA19avOa+rvUjmHtD3sFN7cXWtkGoi8b uNcby4U= Organization: UCLA Computer Science Department Message-ID: Date: Wed, 29 May 2019 16:46:22 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <473e4faf-c770-f201-b1e0-e980bc17396d@oracle.com> Content-Type: multipart/mixed; boundary="------------F2E98C818E5BC328B5AEF512" Content-Language: en-US X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------F2E98C818E5BC328B5AEF512 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 5/29/19 1:51 AM, jakub.kulik@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. --------------F2E98C818E5BC328B5AEF512 Content-Type: text/x-patch; name="0001-maint-fix-version-number-in-NEWS.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-maint-fix-version-number-in-NEWS.patch" >From e7461441325a6edca01b6d6b48a73a2445d9803b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 29 May 2019 16:44:52 -0700 Subject: [PATCH] maint: fix version number in NEWS --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c9f2eff57..5db95b1c4 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,7 @@ GNU coreutils NEWS -*- outline -*- cp now copies /dev/fd/N correctly on platforms like Solaris where it is a character-special file whose minor device number is N. - [bug introduced in coreutils-8.16] + [bug introduced in fileutils-4.1.6] df now correctly parses the /proc/self/mountinfo file for unusual entries like ones with '\r' in a field value ("mount -t tmpfs tmpfs /foo$'\r'bar"), -- 2.21.0 --------------F2E98C818E5BC328B5AEF512-- From unknown Sat Aug 09 20:51:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#35713: /dev/stdin problem in cp on Solaris Resent-From: jakub.kulik@oracle.com Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 30 May 2019 13:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35713 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: 35713@debbugs.gnu.org, =?UTF-8?Q?P=C3=A1draig?= Brady Received: via spool by 35713-submit@debbugs.gnu.org id=B35713.155922371613119 (code B ref 35713); Thu, 30 May 2019 13:42:02 +0000 Received: (at 35713) by debbugs.gnu.org; 30 May 2019 13:41:56 +0000 Received: from localhost ([127.0.0.1]:60994 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWLJc-0003PW-BV for submit@debbugs.gnu.org; Thu, 30 May 2019 09:41:56 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hWLJa-0003PG-Ai for 35713@debbugs.gnu.org; Thu, 30 May 2019 09:41:55 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4UDY4tD123228; Thu, 30 May 2019 13:41:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=Kvhkn/2dVcoWmv0/CfPYvL1/+UsFDgvq5yXNJffzMrI=; b=QfnF7q4C4V2QTMdsDQSLmt/3rLOgrKUswIXo+IZ0vVdIiQFv+vr+tA9aJZtAo/hPRCW5 w1B1HxFiznc2L42vPQF0O8FTHUjWkTCTjLbwJSG1W6ZrcGaBsj6KEnZdMlIm7mpwl7KG VUNkyO5Yuxi5sRXakm/tpbJrV/hqS10rg4tTDalDQTq3gw0lKBOKn6l6rP4d5Lkd1LBt I0CCTxHapkTR3NQnYLRayGWka+9oQy0GtlITNV2fzzg+GeqR3EeEhBNPpEt1flDDh8Vf mXhas+ghzGrTpPcjJx0ZpgEsdlc+Yj2wiDtWgDoNwPImoHZ2VDSrWNPF3EBrYUuJnLql mg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2spxbqg186-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 May 2019 13:41:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4UDfPil079776; Thu, 30 May 2019 13:41:40 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2ss1fp2pse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 May 2019 13:41:39 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4UDfa2Y004975; Thu, 30 May 2019 13:41:37 GMT Received: from [10.163.45.13] (/10.163.45.13) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 May 2019 06:41:36 -0700 References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> <00c465e9-cea0-29c7-1546-ee0d2412e31a@oracle.com> <3503bb40-3694-f526-6dfd-5601807e0347@cs.ucla.edu> <473e4faf-c770-f201-b1e0-e980bc17396d@oracle.com> From: jakub.kulik@oracle.com Organization: Oracle Corporation Message-ID: Date: Thu, 30 May 2019 15:41:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9272 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905300100 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9272 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905300100 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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@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. > > From unknown Sat Aug 09 20:51:01 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: jakub.kulik@oracle.com Subject: bug#35713: closed (Re: bug#35713: /dev/stdin problem in cp on Solaris) Message-ID: References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> X-Gnu-PR-Message: they-closed 35713 X-Gnu-PR-Package: coreutils Reply-To: 35713@debbugs.gnu.org Date: Sun, 02 Jun 2019 06:01:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1559455262-11119-1" This is a multi-part message in MIME format... ------------=_1559455262-11119-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #35713: /dev/stdin problem in cp on Solaris which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 35713@debbugs.gnu.org. --=20 35713: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D35713 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1559455262-11119-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 35713-done) by debbugs.gnu.org; 2 Jun 2019 06:00:57 +0000 Received: from localhost ([127.0.0.1]:39238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hXJY8-0002sx-HR for submit@debbugs.gnu.org; Sun, 02 Jun 2019 02:00:56 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hXJY6-0002sf-Ev for 35713-done@debbugs.gnu.org; Sun, 02 Jun 2019 02:00:55 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 627A2160989; Sat, 1 Jun 2019 23:00:47 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id iiMc0dvfnVi3; Sat, 1 Jun 2019 23:00:46 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id ADC1C160A2C; Sat, 1 Jun 2019 23:00:46 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id aassHfFYUJ2Y; Sat, 1 Jun 2019 23:00:46 -0700 (PDT) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 79DAE1608FE; Sat, 1 Jun 2019 23:00:46 -0700 (PDT) Subject: Re: bug#35713: /dev/stdin problem in cp on Solaris To: jakub.kulik@oracle.com References: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> <66bf3955-c821-9513-2a64-d1e0364f0024@draigBrady.com> <00c465e9-cea0-29c7-1546-ee0d2412e31a@oracle.com> <3503bb40-3694-f526-6dfd-5601807e0347@cs.ucla.edu> <473e4faf-c770-f201-b1e0-e980bc17396d@oracle.com> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sat, 1 Jun 2019 23:00:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 35713-done Cc: 35713-done@debbugs.gnu.org, =?UTF-8?Q?P=c3=a1draig_Brady?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) jakub.kulik@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. ------------=_1559455262-11119-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 13 May 2019 14:20:48 +0000 Received: from localhost ([127.0.0.1]:45839 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQBor-0003Mc-SK for submit@debbugs.gnu.org; Mon, 13 May 2019 10:20:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37625) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQ884-0001vn-ES for submit@debbugs.gnu.org; Mon, 13 May 2019 06:24:21 -0400 Received: from lists.gnu.org ([209.51.188.17]:44675) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ87z-00020x-6q for submit@debbugs.gnu.org; Mon, 13 May 2019 06:24:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ87y-0001WK-2r for bug-coreutils@gnu.org; Mon, 13 May 2019 06:24:15 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_40,RCVD_IN_DNSWL_MED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ87x-0001zz-38 for bug-coreutils@gnu.org; Mon, 13 May 2019 06:24:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59984) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ87w-0001yf-OL for bug-coreutils@gnu.org; Mon, 13 May 2019 06:24:13 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4DANaf1166111 for ; Mon, 13 May 2019 10:24:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=p/gULuffRJVkJKcYX+jXTZGUbJUd3gMWmpJJx12nN8Y=; b=o+UpUy0m0mVl477mwCQmWmDAdSFV7g/Q6un2mYK83VOx7uOesaSeI/yz9JpzaWkvt6tT ZjxtTF3OkACXukoK7CpdP0SXgUj0TwqPFaN2/i03xhNxftY8PYABn8xtT5a/CCHgTOwF tF+AxXIMg2CZRQ/Iaif1dhNf1+vDaTGAOo5fldm1JGB/Ik4W8CNjojXu2K+VqbeBWawi ruNvT3YZYMclfICjCToRX/CYBdlj7q8nPMKE8QkpoyIezHH3+/RaDgTbXda6lJc2HOqs VuXvPh0XDyVw6c6ak44/VuD3AuQXjBNs6twnHvMk+9MlI/rEx2vGaXcg7yGsBjzy6xyU lw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2sdq1q5ujb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 13 May 2019 10:24:08 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4DAO8Qg185615 for ; Mon, 13 May 2019 10:24:08 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2sf3cmjyd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 13 May 2019 10:24:08 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x4DAO5Ke004781 for ; Mon, 13 May 2019 10:24:06 GMT Received: from [10.163.46.162] (/10.163.46.162) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 May 2019 10:24:05 +0000 To: bug-coreutils@gnu.org From: jakub.kulik@oracle.com Subject: /dev/stdin problem in cp on Solaris Organization: Oracle Corporation Message-ID: <0f9daf59-c2d2-82a4-a9a6-f258fb6fa8ca@oracle.com> 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 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------200898F4048188F26FCAF9FD" Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9255 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905130075 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9255 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905130075 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 13 May 2019 10:20:44 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------200898F4048188F26FCAF9FD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id x4DANaf1166111 Hi, We found out that the following simple command fails on Solaris with: =C2=A0cat srcfile.txt | /usr/gnu/bin/cp /dev/stdin dstfile.txt =C2=A0cp: skipping file '/dev/stdin', as it was replaced while being cop= ied I found that problem is with SAME_INODE macro. It accepts two=20 structures, one from stat and another from fstat function. On Solaris,=20 each of these can return a different thing. While stat returns=20 information about the /dev/fd/0 file itself (linked by /dev/stdin),=20 fstat knows much more from the file descriptor and returns info about=20 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=20 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=20 validation for special devices and pipes (as they won't be moved=20 anyway). Patch is attached as well as small program that can show stat=20 and fstat differences on Solaris. Thanks Jakub --------------200898F4048188F26FCAF9FD Content-Type: text/x-patch; name="copy.c.patch" Content-Disposition: attachment; filename="copy.c.patch" Content-Transfer-Encoding: 7bit --- src/copy.c +++ src/copy.c @@ -1050,11 +1050,18 @@ copy_reg (char const *src_name, char con saved ones obtained via a previous call to stat. */ if (! SAME_INODE (*src_sb, src_open_sb)) { - error (0, 0, - _("skipping file %s, as it was replaced while being copied"), - quoteaf (src_name)); - return_val = false; - goto close_src_desc; + /* Stat and fstat returns different results on Solaris for devices + like /dev/stdin. Confirm that this is not the case. */ + mode_t file_type = src_open_sb.st_mode & S_IFMT; + if (!(file_type == S_IFBLK || file_type == S_IFCHR || + file_type == S_IFIFO || file_type == S_IFSOCK)) + { + error (0, 0, + _("skipping file %s, as it was replaced while being copied"), + quoteaf (src_name)); + return_val = false; + goto close_src_desc; + } } /* The semantics of the following open calls are mandated --------------200898F4048188F26FCAF9FD Content-Type: text/x-csrc; name="stdin_test.c" Content-Disposition: attachment; filename="stdin_test.c" Content-Transfer-Encoding: 7bit #include #include #include #include #include #include int main() { int source_desc; struct stat sb; char* src_name = "/dev/stdin"; source_desc = open(src_name, (O_RDONLY)); if (source_desc < 0) { printf("cannot open %s for reading\n", src_name); return 1; } if (fstat (source_desc, &sb) != 0) { printf("cannot fstat %s\n", src_name); return 2; } printf("fstat results:\n"); printf("fd: %d\n", source_desc); printf("ino: %lu, dev: %lu\n", sb.st_ino, sb.st_dev); /* Get the same info from stat */ if (stat(src_name, &sb) != 0) { printf("cannot fstat %s\n", src_name); return 3; } printf("Stat results:\n"); printf("ino: %lu, dev: %lu\n", sb.st_ino, sb.st_dev); return 0; } --------------200898F4048188F26FCAF9FD-- ------------=_1559455262-11119-1--