File Aliases Considered a Plague

,

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, probably meaning some Hidden and System attributes in NTFS. 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.)

Addendum: See Windows expert Raymond Chen's blog: 〔Why doesn't Explorer have an interface for creating hard links? By Raymond Chen. @ blogs.msdn.com…〕.

See also: Windows Vista VirtualStore Problem.

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.

blog comments powered by Disqus