Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm building an IO abstraction library for CIL code, and I have a very hard time understanding the differences between a junction between two folders in NTFS and hard links.

Are they equivalent? Are there differences I should know about?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

NTFS junction points are a type of reparse point, effectively acting as symbolic links but restricted to targeting local directories by absolute path.

Suppose you have

C:\>mkdir a b
C:\>linkd b\c C:\a

What happens is that within the directory table for C:\b, a directory entry named c is inserted, with an attribute $Reparse containing data specifying that it is a junction point with target C:\a.

When Windows 2000 (when reparse points and junction points were introduced) encounters a reparse point, it gets handed off to the appropriate handler. In this case, when accessing a path below C:\b\c, the handler for junction points would replace the path C:\b\c with C:\a and normal filesystem operations would continue from there on.

Other file system filters can be installed which intercept and handle other types of reparse points; Windows Vista, Server 2008, and later come with a handler for "symlink" reparse points on NTFS, which can point to a file or directory, absolute or relative, local or remote - pretty much like symlinks on other systems.


Separately, NTFS does have support for hardlinks, in much the same manner UNIX does - multiple directory entries can point to the same "inode", which is the actual file data. This has nothing to do with reparse points. On almost all systems, hard links can only be made to files; hardlinking directories is fraught with danger. (Among other things, what should the .. entry of a hardlinked directory point to?)

share|improve this answer
    
so would you say that, from a usage perspective, the creation of a junction could on a unix filesystem be implemented as a symlink between folders? –  serialseb Oct 21 '10 at 11:53
2  
Symlinks on NTFS and UNIX filesystems are almost the same, except that an NTFS symlink can point to remote filesystems and UNIX doesn't really have a standard for that. Junctions on NTFS are similar to symlinks but restricted to absolute paths to local directories, so yes, symlinks on a UNIX filesystem fully subsume all the capability of junctions on NTFS. –  ephemient Oct 21 '10 at 13:09

An NTFS reparse point to a directory is very much like loopback mount in Linux/UNIX.

An NTFS hardlink to a file is very much like a hardlink to a file in Linux/UNIX.

An NTFS symlink is very much like a symlink in Linux/UNIX.

An older version of Cygwin for Windows treated reparse points the same as hardlinks, which caused /usr/bin/find to complain about loops in the filesystem. The later versions of Cygwin treat reparse points to be the same as symlinks, as far as POSIX-compliant programs are concerned.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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