Sunday, February 28, 2016

Interesting phenomenon: Symlinks evade DOS device names

Today I discovered an interesting thing involving the special file names. Normally, attempting to write to any file called NUL will result in nothing going anywhere. If you poke around the registry, you'll find that IO on that actually goes to \Device\Null. There are several other files like this, such as AUX. These are holdovers from DOS.

If you make a symbolic link targeted at a file with such a name, no special redirection will occur. Suppose a symlink named NotNul is created with a target of NUL. Writes to NotNul will produce a file literally called NUL in that directory. That new file can only be deleted by its \\?\ name.

No comments:

Post a Comment