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

Previous Next

Package: coreutils;

Reported by: "Burkhardt, Glenn UTAS" <Glenn.Burkhardt <at> utas.utc.com>

Date: Thu, 3 Jan 2013 18:06:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: "Burkhardt, Glenn UTAS" <Glenn.Burkhardt <at> utas.utc.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Eric Blake <eblake <at> redhat.com>, "bug-gnulib <at> gnu.org" <bug-gnulib <at> gnu.org>, "13347 <at> debbugs.gnu.org" <13347 <at> debbugs.gnu.org>
Subject: bug#13347: stat/fstat inappropriately used in cp, install, rm, sort, chown for Windows 7 platforms
Date: Mon, 7 Jan 2013 14:09:35 +0000

> -----Original Message-----
> From: Eli Zaretskii [mailto:eliz <at> gnu.org]
> Sent: Sunday, January 06, 2013 11:54 AM
> To: Eric Blake
> Cc: Burkhardt, Glenn UTAS; bug-gnulib <at> gnu.org; 13347 <at> debbugs.gnu.org
> Subject: Re: bug#13347: stat/fstat inappropriately used in cp, install, rm, sort,
> chown for Windows 7 platforms
> 
> > Date: Thu, 03 Jan 2013 11:38:47 -0700
> > From: Eric Blake <eblake <at> redhat.com>
> > Cc: Bug-gnulib <bug-gnulib <at> gnu.org>, 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?

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/fstat will be different than what MinGW's 'cp' command gets, since the 'cp' command uses a different stat/fstat implementation than one gets using creating a new program in a standard way.

I started exploring this problem by building 'cp.exe' using MinGW's build script.  When I discovered the stat/fstat problem, I tried duplicating it with 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.




This bug report was last modified 12 years and 165 days ago.

Previous Next


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