-
Notifications
You must be signed in to change notification settings - Fork 743
Do not follow Reparse Points during deletion and copy #303
Changes from all commits
1bb4c90
f22b500
3329aeb
e9cd9da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1442,6 +1442,13 @@ GetNextPair(PCOPYROOT pcr, LPTSTR pFrom, | |
| if (pcr->bFastMove) | ||
| goto FastMoveSkipDir; | ||
| #endif | ||
| // Check if we should skip an entry because it was e.g. an reparse point | ||
| if (pDTA->fd.dwFileAttributes & ( ATTR_SYMBOLIC | ATTR_JUNCTION) ) { | ||
| RemoveLast(pcr->szDest); | ||
| dwOp = OPER_RMDIR; | ||
| goto ReturnPair; | ||
| } | ||
|
|
||
| pcr->cDepth++; | ||
| pDTA++; | ||
|
|
||
|
|
@@ -1685,7 +1692,14 @@ GetNextPair(PCOPYROOT pcr, LPTSTR pFrom, | |
| goto ReturnPair; | ||
| } | ||
|
|
||
| // | ||
| // Return reparse point and delete it via OPER_RMDIR | ||
| if (dwFunc == FUNC_DELETE && pDTA->fd.dwFileAttributes & (ATTR_SYMBOLIC | ATTR_JUNCTION)) { | ||
| pcr->fRecurse = FALSE; | ||
| dwOp = OPER_RMDIR; | ||
| goto ReturnPair; | ||
| } | ||
|
|
||
| // | ||
| // Directory: operation is recursive. | ||
| // | ||
| pcr->fRecurse = TRUE; | ||
|
|
@@ -2723,7 +2737,7 @@ WFMoveCopyDriverThread(LPVOID lpParameter) | |
| goto CancelWholeOperation; | ||
| } | ||
| #endif | ||
| break; | ||
| break; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change (to unlink) not in the case 'OPER_RMDIR | FUNC_DELETE' as indicated by the comment above this code?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Short answer: Because when it recursivley runs it only comes along OPER_MKDIR | FUNC_DELETE, but not OPER_RMDIR | FUNC_DELETE. (which I agree, sounds weird) Long answer: From trying to understand the code, I guess it all started with a 'recursive runner', which was meant to perform a copy of a complete tree. This involves OPER_MKDIR on the destination. OPER_RMDIR is only used for non-recursive directory deletion.... I assume.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fwiw, the first time I looked at this block I had to run it under the debugger to understand it too. Although the labels I've been playing around with this code and I think if the first section is changed from to then this block can be removed. But I've only tried the most trivial test cases, so it's possible I'm missing something. Also, I've been trying to find a case where this matters. I think it matters with a non-fast move (across volumes), where the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx, this makes the code more lean. One more thing came up, when I retested copying trees with Symbolic links: As long as one has SeCreateSymbolicLinkPrivilege CreateDirectoryEx works fine and it 'copies' symbolic links. @malxau : Is there a non documented way that CreateDirectoryEx can be enabled to respect SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE? If not I hope my solution is sufficient.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ouch, that hurts. No, I don't think there's a way to make |
||
| case IDNO: | ||
| case IDCANCEL: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Skip" doesn't seem like the right point; we are returning the reparse point as a directory, but not recursing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better comment would be
'Return reparse point and delete it via OPER_RMDIR'