Fix infinite recursion writing to removable drives mounted to NTFS folders
Fix another issue with unresolvable reparse points on Windows. ArchReadLink can return the passed in path if it refers to an "NT Object Manager" path, and we need to handle this as if it isn't a reparse point, because we can't follow the link.
This generalizes the fix by @seando-adsk in f6c2e82, by handling mounted volumes on Windows and avoiding infinitely recursive calls to TfReadLink by having TfIsLink return false in cases where this bad behavior could arise.
Description of Change(s)
Changed Tf_HasAttribute to remove the reparse point attribute on a directory if TfReadLink returns the original path or an empty string (i.e. we couldn't follow the link). This means TfIsLink returns false in these cases, preventing recursive calls to TfReadLink because we always call TfIsLink before calling TfReadLink.
Fixes Issue(s)
#3414
Checklist
[ X ] I have created this PR based on the dev branch
[ X ] I have followed the coding conventions
[ ] I have added unit tests that exercise this functionality Unit testing this is basically impossible given the complex steps required to set up the USB drive appropriately.
[ X ] I have verified that all unit tests pass with the proposed changes
[ X ] I have submitted a signed Contributor License Agreement (Reference:
Filed as internal issue #USD-10419
/AzurePipelines run
Azure Pipelines successfully started running 1 pipeline(s).
Yeah, that’s fair - thanks!
On Wed, Feb 26, 2025 at 11:06 AM Mark Tucker @.***> wrote:
@.**** commented on this pull request.
In pxr/base/tf/fileUtils.cpp https://github.com/PixarAnimationStudios/OpenUSD/pull/3415#discussion_r1972222501 :
@@ -106,8 +115,7 @@ Tf_HasAttribute( }
// Read symlinks until we find the real file.
- return Tf_HasAttribute(TfReadLink(path.c_str()), resolveSymlinks,
attribute, expected);
- return Tf_HasAttribute(linkPath, resolveSymlinks, attribute, expected);
Is an additional comment around line 117 sufficient? Something like:
// At this point we know (attribs & FILE_ATTRIBUTE_REPARSE_POINT) != 0 // or we would have returned in the if block above. This means linkPath will // be holding the result of calling TfReadLink(path.c_str()). The code is separated // in this way to avoid calling TfReadLink twice.
— Reply to this email directly, view it on GitHub https://github.com/PixarAnimationStudios/OpenUSD/pull/3415#discussion_r1972222501, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGZPGJGBIU33D4OMCYRDP32RYGCZAVCNFSM6AAAAABRMENEJSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMNBVGU4TKOJTGQ . You are receiving this because you commented.Message ID: @.***>