GNU bug report logs - #25814
Windows same_file macro is not reliable

Previous Next

Package: diffutils;

Reported by: Kees Dekker <Kees.Dekker <at> infor.com>

Date: Mon, 20 Feb 2017 16:02:01 UTC

Severity: normal

Full log


Message #14 received at 25814 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Kees Dekker <Kees.Dekker <at> infor.com>,
 "25814 <at> debbugs.gnu.org" <25814 <at> debbugs.gnu.org>
Subject: Re: [bug-diffutils] bug#25814: Windows same_file macro is not reliable
Date: Tue, 21 Feb 2017 08:18:46 -0600
[Message part 1 (text/plain, inline)]
On 02/21/2017 03:21 AM, Kees Dekker wrote:
>> NTFS supports inodes; Cygwin uses them.  Just because Window's native
>> stat() is broken does not mean NTFS is broken.
> 
> NTFS is not broken, but according to MSDN, it does not support inodes. The fact that Cygwin supports is, is more how Cygwin implemented fstat/struct fstat (more in the *NIX way). Since Cygwin is not an option for us (everything is native Windows/Visual Studio), it does not help me in saying 'Cygwin is a solution'. I know that the GNU guys like Cygwin, but on Windows, it is beyond reality to expect that Cygwin on Windows is a synonym to native Windows. It is not.

[Please configure your mailer to wrap long lines]

I didn't say you had to use Cygwin, but was rather pointing out that
Cygwin is able to implement stat() on top of NTFS in a manner that
exposes NTFS' native inodes, so the native inodes exist and are
available through native Windows API (how else would cygwin be able to
get it).  And therefore it should be possible to write a gnulib stat()
replacement for mingw that uses the same tricks as cygwin uses to get at
the raw NTFS inode information.

>> At any rate, this is an issue that needs to be resolved in gnulib, as
>> more than just diffutils is affected by it.
> 
> I don't know how Cygwin implements stat(),

It's open source, so you can find out by reading the source code.

https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/fhandler_disk_file.cc#l220

inline ino_t
path_conv::get_ino_by_handle (HANDLE hdl)
{
  IO_STATUS_BLOCK io;
  FILE_INTERNAL_INFORMATION fii;

  if (NT_SUCCESS (NtQueryInformationFile (hdl, &io, &fii, sizeof fii,
                                          FileInternalInformation))
      && isgood_inode (fii.IndexNumber.QuadPart))
    return fii.IndexNumber.QuadPart;
  return 0;
}

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

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 8 years and 117 days ago.

Previous Next


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