4

There are many answers on why hard links, junction points, and symbolic links are useful.

I understand that junction points are supported from Vista onward and are described as "directory hardlinks" (even though they're directory symbolic links and in no way resemble hardlinks for directories). Am I right about that?

On a related note, why can't we support directory hardlinks? Would it affect the file system's integrity? If so, how?

I understand that directory symbolic links are only there on Windows to provide interoperability/compatibility with UNIX File Systems.

I understand that hardlinks for files allow maintaining multiple copies of a file without any additional storage. They are useful in case you accidentally delete the one of the hardlinks or to have quick access to files stored in very long paths.

But are there any other major uses that I'm missing out on?

3

Actually, junctions have been around since Windows 2000; it's symbolic links that appeared in Vista. (Well, strictly speaking, they appeared in XP, but ntfs.sys didn't expose the functionality until Vista.) Neither junctions nor symbolic links are similar to hard links; both of the former are represented as different file system objects, while hard links are different names for the same file object. That last fact can be verified by noting that the ACLs for all hard links of a file are always the same.

I don't think symlinks are around only for Linux/Unix compatibility. Symlinks to folders are more versatile than junctions in that:

  • Symlinks can point to relative paths. Though mklink /j ..\..\relative\stuff will succeed, the resulting junction actually turns out to use the resultant absolute path. (See the output of dir /a.)
  • Symlinks can point to remote volumes or UNC paths. Junctions cannot.

Directory hard links are theoretically possible, but allowing them would open up a can of worms - directories would then be able to literally contain themselves. Lots of applications that recursively examine the file system would break because there would be no way to distinguish a loop from a really deep and weirdly-named tree. (With symlinks and junctions, the entries are distinguishable.) Applications would have to poke at NTFS bookkeeping, and basically nobody does. Directory hard links would also open the possibility of a directory having two (or more!) real parents. In short, breaking the non-cyclical model of the directory structure creates a boatload of complication. Further reading: this Unix&Linux question (different OS, I know, but the same reasoning applies).

I think you've figured out the big uses of symbolic links and junctions. One additional common use on Windows is to mount a drive as a directory on an existing drive. (See Disk Management's Change Drive Letter and Paths.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.