Hard Links
A hard link is the file system representation of a file by which more than one path references a single file in the same volume. To create a hard link, use the CreateHardLink function. Many changes to that file are instantly visible to applications that access it through the hard links that reference it. However, the directory entry size and attribute information is updated only for the link through which the change was made.
For example, in a system where C: and D: are local drives and Z: is a network drive mapped to \\fred\share, the following reference is permitted as a hard link:
- C:\dira\ethel.txt linked to C:\dirb\dirc\lucy.txt
The following are not:
- C:\dira linked to c:\dirb
- C:\dira\ethel.txt linked to D:\dirb\lucy.txt
By creating hard links you can:
- 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.
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 security descriptor. All hard links that point to the file allow the newly specified access. You cannot give a file different security descriptors on a per-hard-link basis.
|