Windows: hardlink support is broken on shared drives

Gavin Erry gavinerry at erry.co.uk
Tue Aug 24 16:11:41 CDT 2010


Oh well...  Unfortunately I don't have two Windows 7 machines to check this
out.

Gavin


-----Original Message-----
From: Adrian Buehlmann [mailto:adrian at cadifra.com] 
Sent: 24 August 2010 10:24
To: Patrick Mézard
Cc: Gavin Erry; mercurial-devel at selenic.com
Subject: Re: Windows: hardlink support is broken on shared drives

On 24.08.2010 00:35, Patrick Mézard wrote:
> Le 23/08/10 22:22, Gavin Erry a écrit :
>> All
>>
>>  
>>
>> I’ve been reading this thread with interest since I posted the problem on
the discussion list.  Thanks for the fix – I will test it in the next build
of Hg.  It seemed strange that GetFileInformationByHandle doesn’t work too
well so I had a look (in C++ though)
>>
>>  
>>
>> It seems that you can get different results depending on how the handle
was created with the CreateFile function.
>>
>> If I use GENERIC_READ or FILE_GENERIC_READ for the desired access in
CreateFile then I get an incorrect hardlink count.
>>
>> Using FILE_READ_ATTRIBUTES | SYNCHRONIZE (which is a subset of
FILE_GENERIC_READ) then I get the correct hardlink count over the network.
> 
> OK, I have seen correct links count returned with FILE_READ_ATTRIBUTES. Do
you need the SYNCHRONIZE flag too? I am asking because I first tried without
it and it failed then with it alone and it succeeds and now without it, it
succeeds again. It's late and I will retry again tomorrow. But I cannot make
sense of SYNCHRONIZE in this context.
> 
> These flags are really promising, I managed to get the correct link count
with all my setups, except when reading through Parallels share, in which
case the serial number was zero.
> 
> Thanks for this excellent insight.

Bad news.

$ python testlink.py linka
links=1                             <--- should be 2
serial=-1898895920

For 

  Windows 7 x64 (as client) -> Windows 7 x64 (as server)

With

             fh = win32file.CreateFile(pathname,
                                       0x0080 | 0x00100000L,
                                       win32file.FILE_SHARE_READ,
                                       None, win32file.OPEN_EXISTING, 0,
None)

and with

             fh = win32file.CreateFile(pathname,
                                       0,
                                       win32file.FILE_SHARE_READ,
                                       None, win32file.OPEN_EXISTING, 0,
None)



More information about the Mercurial-devel mailing list