Hardlinks not updating?

F

farhanarain

10th April 2007

Hi,

As I understand, hardlinks in XP are like pointers to the same piece
of data. Hence, if a file is modified thru one hardlink, shouldn't the
same modified file open no matter which location (hardlink) the file
is opened from? However, that is not happening in practice. I've tried
creating hardlinks to a file in various directories, but each one is a
different copy. When I change a file in one directory, its the only
one changed. All the rest stay independent.

This seems like simple copies of the same file, instead of pointers.

Any clarification would be helpful.

Farhan.
 
B

Brian Cryer

10th April 2007
As I understand, hardlinks in XP are like pointers to the same piece
of data. Hence, if a file is modified thru one hardlink, shouldn't the
same modified file open no matter which location (hardlink) the file
is opened from? However, that is not happening in practice. I've tried
creating hardlinks to a file in various directories, but each one is a
different copy. When I change a file in one directory, its the only
one changed. All the rest stay independent.

This seems like simple copies of the same file, instead of pointers.

Any clarification would be helpful.

Your understanding of hard-links is correct ... for Unix systems. Windows
doesn't support the concept, the closest you have is a shortcut which
doesn't really even come close to a soft-link in Unix.

That said, I understand that there is a resource kit command line tool for
creating hard-links and that there may be some GUI utilities for creating
them
(http://blog.taragana.com/index.php/...links-junctions-and-symboliclinks-on-windows/).
I don't have any first hand experience with any of these so, whilst its
unlikely that I'll be able to help further, it may be useful for others if
you post how you are creating your hard-links.
 
L

Lem

Brian said:
Your understanding of hard-links is correct ... for Unix systems. Windows
doesn't support the concept, the closest you have is a shortcut which
doesn't really even come close to a soft-link in Unix.

That said, I understand that there is a resource kit command line tool for
creating hard-links and that there may be some GUI utilities for creating
them
(http://blog.taragana.com/index.php/...links-junctions-and-symboliclinks-on-windows/).
I don't have any first hand experience with any of these so, whilst its
unlikely that I'll be able to help further, it may be useful for others if
you post how you are creating your hard-links.

Actually, Win XP does (supposedly) support the creation of hardlinks
using the command line command
fsutil: hardlink
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/fsutil_hardlink.mspx

I don't know why it isn't working correctly for the OP, but see below
for some more info.

From
http://www.microsoft.com/technet/prodtechnol/winxppro/reskit/c13621675.mspx#EQFBG
<quote>
Hard Links
Use the fsutil hardlink create command to create hard links. A hard link
is an NTFS-based link to a given file. When you create a hard link to a
file on an NTFS volume, NTFS adds a directory entry for the hard link
without duplicating the original file. You can create hard links that

• Use the same file name as the original file but appear in different
folders.

• Use different file names from the original file but appear in the same
folder.

• Use different file names from the original file and appear in
different folders.


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. 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.

Warning NTFS updates the properties of a hard link only when a user
accesses the original file by using the hard link, not every time a user
makes a change to the original file.

Hard links do not have security descriptors; instead, the security
descriptor belongs to the original file to which the hard link points.
Thus, if you change the security descriptor of any hard link, you
actually change the underlying file’s security descriptor. All hard
links that point to the file allow the newly specified access. You
cannot give a file different security descriptors based on different
hard links.

When creating hard links, consider the following:

• You can create hard links only on NTFS volumes; not on FAT volumes.

• You cannot create a hard link on one volume that refers to a file on
another volume.


To delete a file that has multiple hard links, you must delete the file
and all its associated hard links.

For more information about using the fsutil hardlink create command, see
Windows XP Professional Help
</quote>
 
F

farhanarain

Actually, Win XP does (supposedly) support the creation of hardlinks
using the command line command
fsutil: hardlinkhttp://www.microsoft.com/resources/documentation/windows/xp/all/prodd...

I don't know why it isn't working correctly for the OP, but see below
for some more info.

Fromhttp://www.microsoft.com/technet/prodtechnol/winxppro/reskit/c1362167...
<quote>
Hard Links
Use the fsutil hardlink create command to create hard links. A hard link
is an NTFS-based link to a given file. When you create a hard link to a
file on an NTFS volume, NTFS adds a directory entry for the hard link
without duplicating the original file. You can create hard links that

· Use the same file name as the original file but appear in different
folders.

· Use different file names from the original file but appear in the same
folder.

· Use different file names from the original file and appear in
different folders.

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. 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.

Warning NTFS updates the properties of a hard link only when a user
accesses the original file by using the hard link, not every time a user
makes a change to the original file.

Hard links do not have security descriptors; instead, the security
descriptor belongs to the original file to which the hard link points.
Thus, if you change the security descriptor of any hard link, you
actually change the underlying file's security descriptor. All hard
links that point to the file allow the newly specified access. You
cannot give a file different security descriptors based on different
hard links.

When creating hard links, consider the following:

· You can create hard links only on NTFS volumes; not on FAT volumes.

· You cannot create a hard link on one volume that refers to a file on
another volume.

To delete a file that has multiple hard links, you must delete the file
and all its associated hard links.

For more information about using the fsutil hardlink create command, see
Windows XP Professional Help
</quote>

Thanks Lem and Brain. Unfortunately, the above doesn't work in
practice. All hardlinked files remain independent, and don't reflect
the changes made in any one location. Hope someone can point me to a
solution for this problem.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top