开发者

Reproduce ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 error code from ReplaceFile

I am using the ReplaceFile Win32 function as part of an operation to get atomic behaviour.

Of the three special error codes for that function, I've been able to reproduce and recover (rollback) from two: ERROR_UNABLE_TO_MOVE_REPLACEMENT and ERROR_UNABLE_TO_REMOVE_REPLACED.

My questions relate to the third error code: ERROR_UNABLE_TO_MOVE_REPLACEMENT_2.

  1. Has anybody seen this error code returned? Under what conditions is it possible?
  2. Any ideas on how to repoduce this error so that I can test the path in my code that recovers from it?
  3. I gather from the documentation that to recover (rollback) from this error, I will need to rename the replaced file back to its original name, because ReplaceFile will have left it with the backup file name. Can anybody verify this is in fact the state that ReplaceFile leaves the files in?

Some more details in case it helps:

  • ReplaceFile is called with a non-NULL backup file name (in fact ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 cannot occur if a NULL backup name is given).
  • I also pass the REPLACEFILE_WRITE_THROUG开发者_如何学运维H flag.
  • The files all exist on the same NTFS volume.


ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 occurs when the attributes and secondary data streams have been attached to the replacement file, but the primary file itself cannot be replaced.

Your assumption about recovery is correct.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜