Windows 7 mklink – hard link’s attributes (expected !) + contents do not affect the linked file

hardlinkmklinkwindows 7

I created a hard link pointing to a file in my dropbox dir – the link was created inside a folder where this file needs to be in order to be accessed by the programs I use to edit it –

mklink /h path_to_hard_link C:\dropbox\git\repo\existing_file

I started working with the hard link alright. At some point I realized that the changes do not propagate to the file in repo\ – filesize, modification date, nothing – NOT EVEN the contents.

What am I doing wrong ?

EDIT : is it possible to be program dependent ? I mean the editor I use for these files does indeed edit them – but only edits the hard link. The file linked hasn't been modified. Moreover this editor does not seem to be able to follow symbolic links

EDIT2 : according to the article linked by surfasb :

Because a hard link is a directory
entry for a file, an application can
modify a file by using any of its hard
links. Applications that use any other
hard link can detect the changes.

Meaning the original file must contain the modifications when opened with an appropriate editor directly – not only via its hard link – right ?

However, directory entries for hard
links are updated only when a user
accesses a file by using the hard
link. For example, if a user opens and
modifies a file by using its hard
link, and the size of the original
file changes, the hard link that is
used to access the file also shows the
new size.

If I understand this deplorable specimen of english correctly this means that I can have 69 hard links (up to 1023 actually) to the same file showing different sizes for that same file ?!

EDIT 3 : well according to surfasb I do understand this correctly – a limitation of the filesystem. Anyway – strange thing – this is not always the case – sometimes the change in the attributes is immediately visible back to the original file – when there is change – my real concern now is that at least one program I am using does not seem to edit the file linked but only the hard link. Possible ?
dir /a does not reveal much about hard links – any way to see them ?

Best Answer

I think the answer is (quoted from some helpful guy) :

What you have to consider is the way an application/program works on a file.

Some edit the file directly, and they should work perfectly fine with hardlinks. Although I didn't knew the "fileinfo difference" problem until now ...

Other applications copy the file and then delete the old one when they save their edited version. This programs obviously break the hard link with that hidden copy operation. What they save is no longer the file they had opened. When they then delete the old version, they remove this single hardlink from the directory. Other hardlinks remain, and so you get two files in the end.

So yes - hardlinks can and will break - which limits their usefulness - badly thought.

correct me if wrong