Re: Enumerating the hardlinks for a file.



ldick_at_Asempra.com wrote:

Thanks for the start, but...
How is this done in 2003 Server and XP, etc.?
Larry

As I explained below. GetFileInformationByHandle gives you the # of
links and the file ID and if the # of links is > 1, scan the disk for
other files with the same file ID.

"Corinna Vinschen" wrote:
ldick_at_Asempra.com wrote:
Question

This is a link to the hlscan.exe tool for enumerating the hardlinks for a
file.
Is there source code available for this?
http://www.microsoft.com/downloads/details.aspx?familyid=289adee4-abb3-4e18-ab07-c77db8654979&displaylang=en

Even if there's no source code available, it's quite easy. Open the
file you want to know the hardlinks for and get the file ID (using for
instance the GetFileInformationByHandle function). Then scan the whole
disk to search for files with the same file ID. There's no other way,
AFAIK, until Windows 2003. However...

-- I'd settle for further info about how to do this other than a brute force
scan of the entire file system. Is there a reference to read?

....starting with Windows Vista, NTFS supports a much quicker way to
fetch all hard links for a given file. Look here:
http://msdn.microsoft.com/en-us/library/cc232118.aspx
and here:
http://msdn.microsoft.com/en-us/library/aa364421(VS.85).aspx


Corinna

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
.


Loading