Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enumerate paths for all NTFS hard links pointing to a file?

Tags:

hardlink

ntfs

I can use GetFileInformationByHandle to determine the number of hard links associated with a file. How can I enumerate the paths which make up those links?

For example, if C:\TEMP_1.BIN and C:\TEMP_2.BIN are hard links to the same content, and I determine from GetFileInformationByHandle that C:\TEMP_1.BIN has nNumberOfLinks=2, how can I discover the path for the other link? (e.g. C:\TEMP_2.BIN)

GetFileInformationByHandle: http://msdn.microsoft.com/en-us/library/aa363788%28v=VS.85%29.aspx

like image 437
g01d Avatar asked Sep 30 '10 22:09

g01d


1 Answers

I think you're looking for FindFirstFileNameW, which tells you all of the names a file has.

like image 164
jrtipton Avatar answered Sep 22 '22 22:09

jrtipton