GNU bug report logs - #13347
stat/fstat inappropriately used in cp, install, rm, sort, chown for Windows 7 platforms

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: "Burkhardt, Glenn UTAS" <Glenn.Burkhardt@HIDDEN>; dated Thu, 3 Jan 2013 18:06:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.

Message received at 13347 <at> debbugs.gnu.org:


Received: (at 13347) by debbugs.gnu.org; 7 Jan 2013 14:09:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 07 09:09:53 2013
Received: from localhost ([127.0.0.1]:33982 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TsDOi-0002FV-AA
	for submit <at> debbugs.gnu.org; Mon, 07 Jan 2013 09:09:52 -0500
Received: from mx0a-00105401.pphosted.com ([67.231.144.184]:32782)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <Glenn.Burkhardt@HIDDEN>) id 1TsDOd-0002FL-D4
	for 13347 <at> debbugs.gnu.org; Mon, 07 Jan 2013 09:09:49 -0500
Received: from pps.filterd (m0004020 [127.0.0.1])
	by mx0a-00105401.pphosted.com (8.14.5/8.14.5) with SMTP id
	r07E51WT003309; Mon, 7 Jan 2013 09:09:42 -0500
Received: from xmnpv32.utc.com (xmnpv32.utc.com [159.82.164.212])
	by mx0a-00105401.pphosted.com with ESMTP id 19qya528nb-1
	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK);
	Mon, 07 Jan 2013 09:09:41 -0500
Received: from pps.filterd (localhost.localdomain [127.0.0.1])
	by xmnpv32.utc.com (8.14.5/8.14.5) with SMTP id r07E9Yps032602;
	Mon, 7 Jan 2013 09:09:39 -0500
Received: from uusmna1q.utc.com (uusmna1q.utc.com [159.82.219.65])
	by xmnpv32.utc.com with ESMTP id 19h9rynpnk-1
	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL);
	Mon, 07 Jan 2013 09:09:39 -0500
Received: from GR-GWI-WEST-A.goodrich.com ([170.126.245.4])
	by uusmna1q.utc.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP
	id r07E9cWf002629; Mon, 7 Jan 2013 09:09:39 -0500
Received: from NHC0EX53.goodrich.root.local ([170.126.248.100])
	by GR-GWI-WEST-A.goodrich.com (8.13.5/8.13.5) with ESMTP id
	r07E9bpC029508; Mon, 7 Jan 2013 09:09:37 -0500 (EST)
Received: from NHC0EX52.goodrich.root.local ([fe80::e542:e16f:7c39:9d7f]) by
	NHC0EX53.goodrich.root.local ([fe80::8a4:dec8:8adc:7756%18]) with mapi
	id 14.02.0328.009; Mon, 7 Jan 2013 07:09:36 -0700
From: "Burkhardt, Glenn UTAS" <Glenn.Burkhardt@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: RE: bug#13347: stat/fstat inappropriately used in cp, install, rm,
	sort, chown for Windows 7 platforms
Thread-Topic: bug#13347: stat/fstat inappropriately used in cp, install, rm,
	sort, chown for Windows 7 platforms
Thread-Index: AQHN7C51+gy7aZQvT0i4xUL2m3A22Zg95xrQ
Date: Mon, 7 Jan 2013 14:09:35 +0000
Message-ID: <86DD1E0283018749B08AA5A580CB853E03F687@HIDDEN>
References: <86DD1E0283018749B08AA5A580CB853E038F78@HIDDEN>
	<50E5D037.10104@HIDDEN> <83pq1i8d7h.fsf@HIDDEN>
In-Reply-To: <83pq1i8d7h.fsf@HIDDEN>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.116.67.33]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0
	spamscore=0 suspectscore=1
	phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0
	reason=mlx
	scancount=1 engine=7.0.1-1211240000 definitions=main-1301070116
X-Spam-Score: 0.1 (/)
X-Debbugs-Envelope-To: 13347
Cc: Eric Blake <eblake@HIDDEN>, "bug-gnulib@HIDDEN" <bug-gnulib@HIDDEN>,
	"13347 <at> debbugs.gnu.org" <13347 <at> debbugs.gnu.org>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -0.7 (/)



> -----Original Message-----
> From: Eli Zaretskii [mailto:eliz@HIDDEN]
> Sent: Sunday, January 06, 2013 11:54 AM
> To: Eric Blake
> Cc: Burkhardt, Glenn UTAS; bug-gnulib@HIDDEN; 13347 <at> debbugs.gnu.org
> Subject: Re: bug#13347: stat/fstat inappropriately used in cp, install, r=
m, sort,
> chown for Windows 7 platforms
>=20
> > Date: Thu, 03 Jan 2013 11:38:47 -0700
> > From: Eric Blake <eblake@HIDDEN>
> > Cc: Bug-gnulib <bug-gnulib@HIDDEN>, 13347 <at> debbugs.gnu.org
> >
> > > But then it gets interesting. The 'cp' command is built with a differ=
ent
> version of 'stat' and 'fstat' than one normally gets with a MinGW build
> environment. The coreutils need the Msys build environment, and the
> 'stat/fstat' functions are pulled from libmsys-1.0.dll.a. A build in regu=
lar
> MinGW environment with the current compiler gets the functions from
> libmoldname.a. So were the coreutils built with gcc-4.7.0, and no libmsys=
-
> 1.0.dll.a, the copy command would fail for files on the local hard drive,=
 since
> stat.st_dev is different for stat() and fstat().
>=20
> Sorry for chiming in, but are you saying that the 'cp' binary sometimes
> dynamically links to the MSYS runtime and sometimes to the native Windows
> runtime?  That is a sure way to disaster, as these two runtimes are
> incompatible.  (MSYS is a fork of an old version of
> Cygwin.)  A given binary should only ever use one of these, depending on
> whether it was built as a MinGW program or an MSYS program.
>=20
> If that's not the issue here, then why MSYS is relevant to the discussion=
 at
> all?  What am I missing?

The MinGW folks have their own problems, of course.  I made that note only =
because if one tries using the test code I supplied, the result from stat/f=
stat will be different than what MinGW's 'cp' command gets, since the 'cp' =
command uses a different stat/fstat implementation than one gets using crea=
ting a new program in a standard way.

I started exploring this problem by building 'cp.exe' using MinGW's build s=
cript.  When I discovered the stat/fstat problem, I tried duplicating it wi=
th a simple test program.  But the st_ino/st_dev values for my program were=
 different that what 'cp.exe' got on the same files.

The comment is only relevant for testing in the MinGW environment.




Information forwarded to bug-coreutils@HIDDEN:
bug#13347; Package coreutils. Full text available.

Message received at 13347 <at> debbugs.gnu.org:


Received: (at 13347) by debbugs.gnu.org; 6 Jan 2013 16:54:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 06 11:54:13 2013
Received: from localhost ([127.0.0.1]:47642 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TrtUC-0000z2-NK
	for submit <at> debbugs.gnu.org; Sun, 06 Jan 2013 11:54:13 -0500
Received: from mtaout20.012.net.il ([80.179.55.166]:54931)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <eliz@HIDDEN>) id 1TrtU9-0000yv-5U
	for 13347 <at> debbugs.gnu.org; Sun, 06 Jan 2013 11:54:10 -0500
Received: from conversion-daemon.a-mtaout20.012.net.il by
	a-mtaout20.012.net.il (HyperSendmail v2007.08) id
	<0MG700200QWZTG00@HIDDEN> for
	13347 <at> debbugs.gnu.org; Sun, 06 Jan 2013 18:53:48 +0200 (IST)
Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il
	(HyperSendmail v2007.08) with ESMTPA id
	<0MG7002SPQXM8OB0@HIDDEN>;
	Sun, 06 Jan 2013 18:53:46 +0200 (IST)
Date: Sun, 06 Jan 2013 18:53:54 +0200
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#13347: stat/fstat inappropriately used in cp, install, rm,
	sort, chown for Windows 7 platforms
In-reply-to: <50E5D037.10104@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Eric Blake <eblake@HIDDEN>
Message-id: <83pq1i8d7h.fsf@HIDDEN>
References: <86DD1E0283018749B08AA5A580CB853E038F78@HIDDEN>
	<50E5D037.10104@HIDDEN>
X-Spam-Score: 1.5 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
	has
	identified this incoming email as possible spam. The original message
	has been attached to this so you can view it (if it isn't spam) or
	label similar future email.  If you have any questions, see
	the administrator of that system for details.
	Content preview:  > Date: Thu,
	03 Jan 2013 11:38:47 -0700 > From: Eric Blake
	<eblake@HIDDEN> > Cc: Bug-gnulib <bug-gnulib@HIDDEN>,
	13347 <at> debbugs.gnu.org
	> > > But then it gets interesting. The 'cp' command is built with a
	different
	version of 'stat' and 'fstat' than one normally gets with a MinGW build
	environment. The coreutils need the Msys build environment,
	and the 'stat/fstat' functions
	are pulled from libmsys-1.0.dll.a. A build in regular MinGW environment
	with
	the current compiler gets the functions from libmoldname.a. So were the
	coreutils built with gcc-4.7.0, and no libmsys-1.0.dll.a,
	the copy command would fail for files on the local hard drive,
	since stat.st_dev is different for stat() and fstat(). [...] 
	Content analysis details:   (1.5 points, 10.0 required)
	pts rule name              description
	---- ----------------------
	--------------------------------------------------
	-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,
	no trust [80.179.55.166 listed in list.dnswl.org]
	0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail)
	0.8 BAYES_50               BODY: Bayes spam probability is 40 to 60%
	[score: 0.5000]
X-Debbugs-Envelope-To: 13347
Cc: Glenn.Burkhardt@HIDDEN, bug-gnulib@HIDDEN, 13347 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: 0.7 (/)

> Date: Thu, 03 Jan 2013 11:38:47 -0700
> From: Eric Blake <eblake@HIDDEN>
> Cc: Bug-gnulib <bug-gnulib@HIDDEN>, 13347 <at> debbugs.gnu.org
> 
> > But then it gets interesting. The 'cp' command is built with a different version of 'stat' and 'fstat' than one normally gets with a MinGW build environment. The coreutils need the Msys build environment, and the 'stat/fstat' functions are pulled from libmsys-1.0.dll.a. A build in regular MinGW environment with the current compiler gets the functions from libmoldname.a. So were the coreutils built with gcc-4.7.0, and no libmsys-1.0.dll.a, the copy command would fail for files on the local hard drive, since stat.st_dev is different for stat() and fstat().

Sorry for chiming in, but are you saying that the 'cp' binary
sometimes dynamically links to the MSYS runtime and sometimes to the
native Windows runtime?  That is a sure way to disaster, as these two
runtimes are incompatible.  (MSYS is a fork of an old version of
Cygwin.)  A given binary should only ever use one of these, depending
on whether it was built as a MinGW program or an MSYS program.

If that's not the issue here, then why MSYS is relevant to the
discussion at all?  What am I missing?

> If that's the case, then perhaps the right thing to do is to modify
> gnulib to replace fstat() on mingw so that it is always massaged to
> provide the same st_dev as stat() (on mingw, gnulib is already doing
> other things to track the original file name alongside every open fd, to
> work around other bugs in POSIX compliance, so it wouldn't actually cost
> that much extra).

Actually, TRT would be to have a replacement for 'stat' and 'fstat'
that return the Windows equivalent of the inode, which is accessible
by a file handle or a descriptor.  The problem is that this also
requires to replace the definition of 'struct stat', since the
resulting inodes are 64-bit numbers, while a typical 'struct stat'
declares the inode as 'short' (why waste storage on something that is
always zero?)




Information forwarded to bug-coreutils@HIDDEN:
bug#13347; Package coreutils. Full text available.

Message received at 13347 <at> debbugs.gnu.org:


Received: (at 13347) by debbugs.gnu.org; 3 Jan 2013 18:38:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 03 13:38:56 2013
Received: from localhost ([127.0.0.1]:41892 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Tqpgt-0002a4-TV
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2013 13:38:56 -0500
Received: from mx1.redhat.com ([209.132.183.28]:25453)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <eblake@HIDDEN>) id 1Tqpgq-0002Zv-2A
	for 13347 <at> debbugs.gnu.org; Thu, 03 Jan 2013 13:38:54 -0500
Received: from int-mx09.intmail.prod.int.phx2.redhat.com
	(int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r03Icm7Y009857
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Thu, 3 Jan 2013 13:38:48 -0500
Received: from [10.3.113.75] (ovpn-113-75.phx2.redhat.com [10.3.113.75])
	by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP
	id r03IclBl010920; Thu, 3 Jan 2013 13:38:48 -0500
Message-ID: <50E5D037.10104@HIDDEN>
Date: Thu, 03 Jan 2013 11:38:47 -0700
From: Eric Blake <eblake@HIDDEN>
Organization: Red Hat, Inc.
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To: "Burkhardt, Glenn UTAS" <Glenn.Burkhardt@HIDDEN>
Subject: Re: bug#13347: stat/fstat inappropriately used in cp, install, rm,
	sort, chown for Windows 7 platforms
References: <86DD1E0283018749B08AA5A580CB853E038F78@HIDDEN>
In-Reply-To: <86DD1E0283018749B08AA5A580CB853E038F78@HIDDEN>
X-Enigmail-Version: 1.4.6
OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg
Content-Type: multipart/signed; micalg=pgp-sha256;
	protocol="application/pgp-signature";
	boundary="------------enigA8900BF1D4A6D64BDBC319C4"
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22
X-Spam-Score: -6.9 (------)
X-Debbugs-Envelope-To: 13347
Cc: Bug-gnulib <bug-gnulib@HIDDEN>, 13347 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigA8900BF1D4A6D64BDBC319C4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

[adding gnulib]

On 01/03/2013 10:10 AM, Burkhardt, Glenn UTAS wrote:
> MINGW32_NT-6.1 BOS0DT-1QLS1R1 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Ms=
ys
> gcc version 4.7.0 (GCC)
> Windows 7 Enterprise SP1
> coreutils-5.97
>=20
> I noticed this when trying to use the "cp" command in a Clearcase local=
ly hosted dynamic view.

Clearcase is notoriously buggy when it comes to POSIX compliance, and
I'm not surprised you are running into problems because of those bugs.
Since you paid for Clearcase (and coreutils is free), you might want to
consider reporting this issue upstream to the clearcase folks; then
again, since clearcase is closed source, I wouldn't hold out any hope
for them to fix their bugs.

> But then it gets interesting. The 'cp' command is built with a differen=
t version of 'stat' and 'fstat' than one normally gets with a MinGW build=
 environment. The coreutils need the Msys build environment, and the 'sta=
t/fstat' functions are pulled from libmsys-1.0.dll.a. A build in regular =
MinGW environment with the current compiler gets the functions from libmo=
ldname.a. So were the coreutils built with gcc-4.7.0, and no libmsys-1.0.=
dll.a, the copy command would fail for files on the local hard drive, sin=
ce stat.st_dev is different for stat() and fstat().

If that's the case, then perhaps the right thing to do is to modify
gnulib to replace fstat() on mingw so that it is always massaged to
provide the same st_dev as stat() (on mingw, gnulib is already doing
other things to track the original file name alongside every open fd, to
work around other bugs in POSIX compliance, so it wouldn't actually cost
that much extra).

>=20
> I've attached a small test program to show the stat()/fstat() output, a=
nd a patch for system.h in coreutils that allows a working version of 'cp=
=2Eexe

Unfortunately, your patch cannot be accepted upstream as-is, as it would
violate POSIX semantics on systems that actually obey POSIX.  But it
might be something that could be made conditional on whether things are
being targeted to mingw.

> http://sourceforge.net/tracker/?func=3Ddetail&aid=3D3590842&group_id=3D=
2435&atid=3D102435

>=20
> *** system.h.orig	Mon Nov 26 16:54:58 2012
> --- system.h	Wed Nov 28 18:15:04 2012
> ***************
> *** 535,542 ****
>   #include "unlocked-io.h"
>  =20
>   #define SAME_INODE(Stat_buf_1, Stat_buf_2) \
> !   ((Stat_buf_1).st_ino =3D=3D (Stat_buf_2).st_ino \
> !    && (Stat_buf_1).st_dev =3D=3D (Stat_buf_2).st_dev)
>  =20
>   #define DOT_OR_DOTDOT(Basename) \
>     (Basename[0] =3D=3D '.' && (Basename[1] =3D=3D '\0' \
> --- 535,541 ----
>   #include "unlocked-io.h"
>  =20
>   #define SAME_INODE(Stat_buf_1, Stat_buf_2) \
> !   ((Stat_buf_1).st_ino =3D=3D (Stat_buf_2).st_ino)
>  =20
>   #define DOT_OR_DOTDOT(Basename) \
>     (Basename[0] =3D=3D '.' && (Basename[1] =3D=3D '\0' \
>=20

Also, while this patch is unlikely to go in as-is to upstream coreutils,
you may want to pursue getting it included into mingw and msys builds as
downstream distros affected by the need for the workaround.

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


--------------enigA8900BF1D4A6D64BDBC319C4
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBCAAGBQJQ5dA3AAoJEKeha0olJ0Nq49gH/06ecWCchI7SKzFnJZ+/d2il
CQ2PZLdMpJUyTQnznRWuoD5D5C3LPHKqJwwAz1toonXacX3FcIWVSrYqDo3FaRkv
cxDOs9pzwsTVlCoUtKguUyawCQF2Pdl8fQwfJZzgQW0k54Gy4H6LO7QraHOjm2z0
lRWygbmJXrw2u/qADGMhw603rAOE7nkYxbrX76Za3W7wDFHg5Sn0s/KNSwHawZKZ
UxkEHwhkBKp3f8IApW/NHauBm59fZzMTzCrpgwbZIcpOLPXxgUDbqgZM3tZrM2Ta
F6tGpSiOwR7SeULbdYSsC95D88Y3GbeyVr8QIgxL8PG143UmT7C5DjhcziSlS3I=
=hkXh
-----END PGP SIGNATURE-----

--------------enigA8900BF1D4A6D64BDBC319C4--




Information forwarded to bug-coreutils@HIDDEN:
bug#13347; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 3 Jan 2013 18:05:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 03 13:05:02 2013
Received: from localhost ([127.0.0.1]:41852 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TqpA5-0000ls-SC
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2013 13:05:02 -0500
Received: from eggs.gnu.org ([208.118.235.92]:39608)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <Glenn.Burkhardt@HIDDEN>) id 1TqoKK-0006wT-Py
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2013 12:11:34 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Glenn.Burkhardt@HIDDEN>) id 1TqoKA-0002on-G5
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2013 12:11:30 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW
	autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:59338)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Glenn.Burkhardt@HIDDEN>) id 1TqoKA-0002oi-CX
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2013 12:11:22 -0500
Received: from eggs.gnu.org ([208.118.235.92]:50916)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Glenn.Burkhardt@HIDDEN>) id 1TqoK5-0004k4-06
	for bug-coreutils@HIDDEN; Thu, 03 Jan 2013 12:11:22 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Glenn.Burkhardt@HIDDEN>) id 1TqoK0-0002lw-CH
	for bug-coreutils@HIDDEN; Thu, 03 Jan 2013 12:11:16 -0500
Received: from mx0b-00105401.pphosted.com ([67.231.152.184]:40516)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Glenn.Burkhardt@HIDDEN>) id 1TqoK0-0002jF-6m
	for bug-coreutils@HIDDEN; Thu, 03 Jan 2013 12:11:12 -0500
Received: from pps.filterd (m0004641 [127.0.0.1])
	by mx0b-00105401.pphosted.com (8.14.5/8.14.5) with SMTP id
	r03HB16m001243
	for <bug-coreutils@HIDDEN>; Thu, 3 Jan 2013 12:11:02 -0500
Received: from xnwpv31.utc.com (xnwpv31.utc.com [159.82.148.211])
	by mx0b-00105401.pphosted.com with ESMTP id 19n11schje-1
	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK)
	for <bug-coreutils@HIDDEN>; Thu, 03 Jan 2013 12:11:02 -0500
Received: from pps.filterd (localhost.localdomain [127.0.0.1])
	by xnwpv31.utc.com (8.14.5/8.14.5) with SMTP id r03HAGOi030049
	for <bug-coreutils@HIDDEN>; Thu, 3 Jan 2013 12:10:56 -0500
Received: from uusnwa4t.utc.com (uusnwa4t.utc.com [159.82.101.253])
	by xnwpv31.utc.com with ESMTP id 19k7twq723-1
	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL)
	for <bug-coreutils@HIDDEN>; Thu, 03 Jan 2013 12:10:56 -0500
Received: from GR-GWI-WEST-A.goodrich.com ([170.126.245.4])
	by uusnwa4t.utc.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP
	id r03HAt8h021377
	for <bug-coreutils@HIDDEN>; Thu, 3 Jan 2013 12:10:56 -0500
Received: from NHC0EX55.goodrich.root.local ([170.126.248.102])
	by GR-GWI-WEST-A.goodrich.com (8.13.5/8.13.5) with ESMTP id
	r03HAeiV017359
	for <bug-coreutils@HIDDEN>; Thu, 3 Jan 2013 12:10:54 -0500 (EST)
Received: from NHC0EX52.goodrich.root.local ([fe80::e542:e16f:7c39:9d7f]) by
	NHC0EX55.goodrich.root.local ([fe80::75b1:c5c8:6d9d:42a8%17]) with mapi
	id 14.02.0328.009; Thu, 3 Jan 2013 10:10:45 -0700
From: "Burkhardt, Glenn UTAS" <Glenn.Burkhardt@HIDDEN>
To: "bug-coreutils@HIDDEN" <bug-coreutils@HIDDEN>
Subject: stat/fstat inappropriately used in cp, install, rm, sort, chown for
	Windows 7 platforms
Thread-Topic: stat/fstat inappropriately used in cp, install, rm, sort,
	chown for Windows 7 platforms
Thread-Index: Ac3p0+tQPAfdWeJwRzusHurwxxqXNA==
Date: Thu, 3 Jan 2013 17:10:45 +0000
Message-ID: <86DD1E0283018749B08AA5A580CB853E038F78@HIDDEN>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator: 
x-originating-ip: [10.116.67.33]
Content-Type: multipart/mixed;
	boundary="_003_86DD1E0283018749B08AA5A580CB853E038F78NHC0EX52goodrichr_"
MIME-Version: 1.0
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0
	spamscore=0 suspectscore=2
	phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0
	reason=mlx
	scancount=1 engine=7.0.1-1211240000 definitions=main-1301030156
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.17
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 03 Jan 2013 13:05:01 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

--_003_86DD1E0283018749B08AA5A580CB853E038F78NHC0EX52goodrichr_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

MINGW32_NT-6.1 BOS0DT-1QLS1R1 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys
gcc version 4.7.0 (GCC)
Windows 7 Enterprise SP1
coreutils-5.97

I noticed this when trying to use the "cp" command in a Clearcase locally h=
osted dynamic view. When trying to copy a view private file, the 'cp' comma=
nd would fail with a message like

skipping file `jj', as it was replaced while being copied

The problem is that the 'cp' command uses 'stat' on the source file initial=
ly, and then, when it's ready to copy, uses 'fstat' on it again, after the =
file has been opened for reading (about line 237 in copy.c from coreutils-5=
.97). This works on a file that's on a local hard drive, but not on a Clear=
case locally hosted dynamic view. The 'install' command has the same proble=
m.

This test really shouldn't be done on a Windows platform. Microsoft's docum=
entation describes different values for stat.st_dev returned by the 'stat()=
' and 'fstat()' functions. There's also a note that the stat.st_ino value i=
s meaningless for NTFS filesystems.  Although MinGW releases a very old ver=
sion of 'coreutils', the current 8.9 version will have the same problem.  T=
he definition of the macro SAME_INODE is unchanged.

But then it gets interesting. The 'cp' command is built with a different ve=
rsion of 'stat' and 'fstat' than one normally gets with a MinGW build envir=
onment. The coreutils need the Msys build environment, and the 'stat/fstat'=
 functions are pulled from libmsys-1.0.dll.a. A build in regular MinGW envi=
ronment with the current compiler gets the functions from libmoldname.a. So=
 were the coreutils built with gcc-4.7.0, and no libmsys-1.0.dll.a, the cop=
y command would fail for files on the local hard drive, since stat.st_dev i=
s different for stat() and fstat().

I've attached a small test program to show the stat()/fstat() output, and a=
 patch for system.h in coreutils that allows a working version of 'cp.exe' =
and 'install.exe' to be built.

Please also see the bug report to the MinGW bug tracker, ID 3590842:

http://sourceforge.net/tracker/?func=3Ddetail&aid=3D3590842&group_id=3D2435=
&atid=3D102435


--_003_86DD1E0283018749B08AA5A580CB853E038F78NHC0EX52goodrichr_
Content-Type: application/octet-stream; name="system.h.patch"
Content-Description: system.h.patch
Content-Disposition: attachment; filename="system.h.patch"; size=614;
	creation-date="Wed, 28 Nov 2012 23:35:05 GMT";
	modification-date="Wed, 28 Nov 2012 23:35:05 GMT"
Content-Transfer-Encoding: base64

KioqIHN5c3RlbS5oLm9yaWcJTW9uIE5vdiAyNiAxNjo1NDo1OCAyMDEyCi0tLSBzeXN0ZW0uaAlX
ZWQgTm92IDI4IDE4OjE1OjA0IDIwMTIKKioqKioqKioqKioqKioqCioqKiA1MzUsNTQyICoqKioK
ICAjaW5jbHVkZSAidW5sb2NrZWQtaW8uaCIKICAKICAjZGVmaW5lIFNBTUVfSU5PREUoU3RhdF9i
dWZfMSwgU3RhdF9idWZfMikgXAohICAgKChTdGF0X2J1Zl8xKS5zdF9pbm8gPT0gKFN0YXRfYnVm
XzIpLnN0X2lubyBcCiEgICAgJiYgKFN0YXRfYnVmXzEpLnN0X2RldiA9PSAoU3RhdF9idWZfMiku
c3RfZGV2KQogIAogICNkZWZpbmUgRE9UX09SX0RPVERPVChCYXNlbmFtZSkgXAogICAgKEJhc2Vu
YW1lWzBdID09ICcuJyAmJiAoQmFzZW5hbWVbMV0gPT0gJ1wwJyBcCi0tLSA1MzUsNTQxIC0tLS0K
ICAjaW5jbHVkZSAidW5sb2NrZWQtaW8uaCIKICAKICAjZGVmaW5lIFNBTUVfSU5PREUoU3RhdF9i
dWZfMSwgU3RhdF9idWZfMikgXAohICAgKChTdGF0X2J1Zl8xKS5zdF9pbm8gPT0gKFN0YXRfYnVm
XzIpLnN0X2lubykKICAKICAjZGVmaW5lIERPVF9PUl9ET1RET1QoQmFzZW5hbWUpIFwKICAgIChC
YXNlbmFtZVswXSA9PSAnLicgJiYgKEJhc2VuYW1lWzFdID09ICdcMCcgXAo=

--_003_86DD1E0283018749B08AA5A580CB853E038F78NHC0EX52goodrichr_
Content-Type: text/plain; name="test-stat.c"
Content-Description: test-stat.c
Content-Disposition: attachment; filename="test-stat.c"; size=662;
	creation-date="Wed, 28 Nov 2012 21:17:20 GMT";
	modification-date="Wed, 28 Nov 2012 22:30:43 GMT"
Content-Transfer-Encoding: base64

I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3R5cGVzLmg+DQojaW5jbHVkZSA8c3lz
L3N0YXQuaD4NCiNpbmNsdWRlIDxmY250bC5oPg0KDQppbnQgbWFpbihpbnQgYWMsIGNoYXIgKiph
dikNCnsNCiAgICBpbnQgcywgZmQ7DQogICAgc3RydWN0IHN0YXQgczAsIHMxOw0KDQogICAgaWYg
KGFjIDwgMikgew0KICAgICAgICBwdXRzKCJVc2FnZTogIHRlc3Qtc3RhdCA8ZmlsZW5hbWU+Iik7
DQogICAgICAgIHJldHVybiAtMTsNCiAgICB9DQoNCiAgICBzID0gc3RhdChhdlsxXSwgJnMwKTsN
CiAgICBpZiAocykgcGVycm9yKCJzdGF0IGZhaWxlZCIpOw0KDQogICAgZmQgPSBvcGVuKGF2WzFd
LCBPX1JET05MWSB8IE9fQklOQVJZKTsNCiAgICBpZiAoZmQgPCAwKSB7DQogICAgICAgIHBlcnJv
cigib3BlbiBmYWlsZWQiKTsNCiAgICAgICAgcmV0dXJuIC0xOw0KICAgIH0NCg0KICAgIHMgPSBm
c3RhdChmZCwgJnMxKTsNCiAgICBpZiAocykgcGVycm9yKCJmc3RhdCBmYWlsZWQiKTsNCg0KICAg
IHByaW50ZigiczA6ICBzdF9kZXY9JWQgIHN0X2lubz0lZFxuIiwgczAuc3RfZGV2LCBzMC5zdF9p
bm8pOw0KICAgIHByaW50ZigiczE6ICBzdF9kZXY9JWQgIHN0X2lubz0lZFxuIiwgczEuc3RfZGV2
LCBzMS5zdF9pbm8pOw0KDQogICAgcmV0dXJuIDA7DQp9DQo=

--_003_86DD1E0283018749B08AA5A580CB853E038F78NHC0EX52goodrichr_--




Acknowledgement sent to "Burkhardt, Glenn UTAS" <Glenn.Burkhardt@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#13347; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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