Home Dashboard Directory Help

robocopy.exe: Error 1921, Recursive Junctions (Reparse Points) by SurroundedByChaos



Sign in
to vote
Type: Bug
ID: 776397
Opened: 1/12/2013 9:01:36 AM
Access Restriction: Public
User(s) can reproduce this bug


Since the introduction of reparse points, one type being a junction point, in Windows 2000, the Directed Acyclic Graph (DAC) that was once the NTFS file system, can now contain loops. A loop in this situation refers to a subdirectory created as reparse point, that targets one of its parent directories. For tools, such as robocopy, that recursively walk the file system directory structure, a child directory implemented as a looping reparse point will either directly or indirectly cause the program to revisit one of its parent directories, thus restarting the tool's recursive decent, over, and over, and over.... So why has this bug been neglected for over a decade now?

It wasn't until the introduction of Windows Vista, when to their credit, Microsoft sensibly reconfigure its file system directory structure, that reparse points surfaced as the recurrent mechanism to support backward compatibility of the frankly wordy and document centric "\Documents And Settings" tree. Unfortunately, in order to remap “\Documents And Settings” to the new “\Users” directory tree, a small number of looping reparse points were introduced by Vista (which grow linearly with each additional user account). However, only one looping reparse point need exist to induce chaos within programs coded assuming a DAC file system when traversing it.

In the case of robocopy, a looping reparse point eventually causes robocopy to issue the following message: “ERROR 1921 The name of the file cannot be resolved by the system.”, as the length of the path it's attempting to traverse/backup exceeds the OS maximum.

Although a number of posts recommend using robocopy's /XJ switch, to exclude/ignore junction points, this recommendation simply subverts the purpose of robocopy: to create a faithful reproduction of the file system, as all junction points, even ones that aren't loopers are excluded.

I'm simply requesting that a Microsoft Developer repair robocopy:
1. Identify & save all reparse points and their properties, such as ACL lists, but don't traverse them.
2. Or detect a looping reparse point and treat a direct/indirect traversal to a parent node within the reparse point's path as a leaf node of the reparse point's directory chain. Remember, one can define a subdirectory of a reparse point that is also a reparse point.
Sign in to post a comment.
Sign in to post a workaround.
Posted by SurroundedByChaos on 1/12/2013 at 9:04 AM
I've implemented a backup solution for my own needs that essentially does the following:

1. Identify all the reparse points, record their redirection, and ACL information. I used robocopy itself to identify the reparse points, as Mark Russinovich's junction.exe suffers from the looping issue too. Although it's not immediately apparent that it does, as you either need to change the file permissions assigned to the Vista/7 reparse points, so the program can list the contents of the directory implemented as a reparse point, or update junction.exe's execution context so it doesn't include the “Everyone” group. This group group has been assigned “Deny” permissions, that prevents individual administrators and other accounts from listing the various reparse points that were added by Vista to support backward compatibility for programs reliant on the “\Documents And Settngs” tree.
2. Delete all the reparse points using "junction.exe".
3. Execute robocopy.

The above seems to work well enough for my needs but it lacks the rigor of in depth knowledge (did I miss something?) and testing.