File Aliases Considered Harmful

By Xah Lee. Date: . Last updated: .

Windows Junction Problem: My Music, My Pictures, My Videos

Learned today about Windows's Junction. Basically, it's a file aliasing mechanism in NTFS much like unix's hardlink, softlink, and also Mac OS X's HFS+'s alias.

All these i have avoided like a plague in software. They create a lot problems.

I noticed this Windows juncture because i am using rsync thru cygwin to copy files in my Documents folder to my Mac. Rsync keeps telling me permission denied. Here's the error:

xah@xah-PC ~
$ rsync -z -r -v -t --exclude=".DS_Store" --delete --rsh="ssh -l xah" ~/Documents/ xah@169.254.153.147:~/Documents_PC/
Password:
building file list ... rsync: opendir "/cygdrive/c/Users/xah/Documents/My Music" failed: Permission denied (13)
rsync: opendir "/cygdrive/c/Users/xah/Documents/My Pictures" failed: Permission denied (13)
rsync: opendir "/cygdrive/c/Users/xah/Documents/My Videos" failed: Permission denied (13)

In my “Documents” folder, i don't have a folder named “My Music” or such. But of course, apparently i do. They are hidden. In Explorer, you won't see these files in your Documents dir (unless you have turned on viewing system files in Folder Options).

These hidden files are links to different dirs: ~/My Pictures and ~/My Videos. I get perm denied because i haven't made the link destination folders to be shared.

If you use PowerShell dir -force, you see:

    Directory: C:\Users\xah\Documents

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d--hs         5/23/2009   7:15 PM            My Music
d--hs         5/23/2009   7:15 PM            My Pictures
d----         6/18/2009   8:25 PM            My Received Files
d--hs         5/23/2009   7:15 PM            My Videos

Note those “hs” there, meaning Hidden and System attributes. If you use cmd.exe's dir /A , you see:

08/31/2009  06:27 AM    <DIR>          emacs_stuff
05/23/2009  07:15 PM    <JUNCTION>     My Music [C:\Users\xah\Music]
05/23/2009  07:15 PM    <JUNCTION>     My Pictures [C:\Users\xah\Pictures]
06/18/2009  08:25 PM    <DIR>          My Received Files
05/23/2009  07:15 PM    <JUNCTION>     My Videos [C:\Users\xah\Videos]

At that, the word JUNCTION give me a hook to search on the web, and found the answer.

All these different redirect mechanisms in unix, Mac, and now i know Windows, creates lots of complexities and problems. Problems in security, in copying deleting dirs, in deceptive dir structure. One thing i particularly hate is unix's “hard link”. Though, i guess in some situations they are convenient and probably the best solution.

The rsync problem is solved by adding --exclude="**/My *" .

(I was using --exclude="*/My *" to work around the perm denied error, but no go. Annoying, and i lived with it for days. Eventually, i bite the bullet to spend time to resolve it, which lead me to this juncture business. For rsync, it turns out i need two asterisks.)

Why doesn't Explorer have an interface for creating hard links?

Addendum: See Windows expert Raymond Chen's blog:

windows hard links raymond chen 2009-09-28
[Why doesn't Explorer have an interface for creating hard links? By Raymond Chen.. At https://devblogs.microsoft.com/oldnewthing/20090928-00/?p=16573 ]

learned this linux command update-alternatives.

It's basically another system of {file alias, soft/hard link, Junction, virtual store} — a pest. For detail, see update-alternatives --help and man update-alternatives.

Microsoft Windows File Alias, Juncture