Skip to content
Tcl Source Code History Of Ticket 08203e
Login

History Of Ticket 08203e

Artifacts Associated With Ticket 08203e

  1. Ticket change [f5651f90c1] (rid 258532) by serhiy.storchaka on 2026-10-17 10:51:12:

    1. cmimetype initialized to: "text/x-fossil-wiki"
    2. comment initialized to:
      On Windows, <nowiki>[file delete -force]</nowiki> fails on a directory that contains a file symbolic link. Tcl itself creates such links: <nowiki>[file link -symbolic]</nowiki> makes a real symlink for a file target since 8.6.11 ([548cd945d6]). This needs administrator rights or Developer Mode, the same as <tt>mklink</tt>.
      
      <verbatim>
      file mkdir d
      close [open d/a.txt w]
      file link -symbolic d/b.txt d/a.txt   ;# or: mklink d\b.txt a.txt
      file delete -force d
      </verbatim>
      
      Actual: <tt>error deleting "...": invalid argument</tt>, and <tt>d</tt> stays. Expected: <tt>d</tt> is deleted. Deleting the link itself with <nowiki>[file delete d/b.txt]</nowiki> works.
      
      Cause: <tt>TraverseWinTree()</tt> (win/tclWinFCmd.c) hands every reparse point to <tt>TraversalDelete()</tt> as <tt>DOTREE_LINK</tt>, which calls <tt>DoRemoveJustDirectory()</tt> and so <tt>TclWinSymLinkDelete()</tt> (win/tclWinFile.c). That function always passes <tt>IO_REPARSE_TAG_MOUNT_POINT</tt> to <tt>FSCTL_DELETE_REPARSE_POINT</tt>, which fails with a tag mismatch for a symlink (tag <tt>0xA000000C</tt>), giving EINVAL. Even if the reparse data were removed, <tt>RemoveDirectoryW()</tt> cannot remove a file. A directory symlink inside the tree goes through the same code and probably fails the same way. The same function also explains [3c13c4ed31] (<nowiki>[file delete]</nowiki> on a directory symlink fails with "illegal operation on a directory"/"is a directory"), which was closed as Invalid. Possible fix: delete links with <tt>DeleteFileW()</tt> or <tt>RemoveDirectoryW()</tt> depending on <tt>FILE_ATTRIBUTE_DIRECTORY</tt>. Both remove the link and not its target.
      
      Related: [972c35d41d] (<nowiki>[file copy]</nowiki> of symlinks), [c8d4f01a54] (NTFS symlinks not supported by <nowiki>[file]</nowiki>).
      
      Seen on Windows 11 in 8.6.18, 9.0.5 and 9.1.
      
    3. foundin initialized to: "8.6.18, 9.0.5, 9.1.0"
    4. login: "serhiy.storchaka"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. severity initialized to: "Minor"
    8. status initialized to: "Open"
    9. subsystem initialized to: "37. File System"
    10. title initialized to:
      Windows: [file delete -force] fails on a directory containing a symlink
      
    11. type initialized to: "Bug"
  2. Ticket change [9861d42209] (rid 258627) by serhiy.storchaka on 2026-10-17 14:27:36:

    1. icomment:
      Proposed fix in branch [/timeline?r=win-delete-tree-with-symlinks|win-delete-tree-with-symlinks]: a link to a file is removed like a file, and a link to a directory that is not a junction (<tt>mklink /D</tt>) with <tt>RemoveDirectoryW()</tt>; the targets are not touched. Directory symbolic links inside the tree failed the same way. Tests winFCmd-9.7 and 9.8 (need the right to create symbolic links).
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [1340e057a3] (rid 259538) by serhiy.storchaka on 2026-10-20 18:11:29:

    1. submitter changed to: "serhiy.storchaka"
  4. Ticket change [29fcdf14f1] (rid 262031) by jan.nijtmans on 2026-11-22 22:58:12:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2461367.4570865394"
    3. closer changed to: "jan.nijtmans"
    4. comment changed to:
      On Windows, <nowiki>[file delete -force]</nowiki> fails on a directory that contains a file symbolic link. Tcl itself creates such links: <nowiki>[file link -symbolic]</nowiki> makes a real symlink for a file target since 8.6.11 ([548cd945d6]). This needs administrator rights or Developer Mode, the same as <tt>mklink</tt>.
      
      <verbatim>
      file mkdir d
      close [open d/a.txt w]
      file link -symbolic d/b.txt d/a.txt   ;# or: mklink d\b.txt a.txt
      file delete -force d
      </verbatim>
      
      Actual: <tt>error deleting "...": invalid argument</tt>, and <tt>d</tt> stays. Expected: <tt>d</tt> is deleted. Deleting the link itself with <nowiki>[file delete d/b.txt]</nowiki> works.
      
      Cause: <tt>TraverseWinTree()</tt> (win/tclWinFCmd.c) hands every reparse point to <tt>TraversalDelete()</tt> as <tt>DOTREE_LINK</tt>, which calls <tt>DoRemoveJustDirectory()</tt> and so <tt>TclWinSymLinkDelete()</tt> (win/tclWinFile.c). That function always passes <tt>IO_REPARSE_TAG_MOUNT_POINT</tt> to <tt>FSCTL_DELETE_REPARSE_POINT</tt>, which fails with a tag mismatch for a symlink (tag <tt>0xA000000C</tt>), giving EINVAL. Even if the reparse data were removed, <tt>RemoveDirectoryW()</tt> cannot remove a file. A directory symlink inside the tree goes through the same code and probably fails the same way. The same function also explains [3c13c4ed31] (<nowiki>[file delete]</nowiki> on a directory symlink fails with "illegal operation on a directory"/"is a directory"), which was closed as Invalid. Possible fix: delete links with <tt>DeleteFileW()</tt> or <tt>RemoveDirectoryW()</tt> depending on <tt>FILE_ATTRIBUTE_DIRECTORY</tt>. Both remove the link and not its target.
      
      Related: [972c35d41d] (<nowiki>[file copy]</nowiki> of symlinks), [c8d4f01a54] (NTFS symlinks not supported by <nowiki>[file]</nowiki>).
      
      Seen on Windows 11 in 8.6.18, 9.0.5 and 9.1.
      
    5. icomment:
      Merged to [6f1fbfbc88|trunk], core-9-0-branch and core-8-6-branch
      
      Many thanks!
      
    6. login: "jan.nijtmans"
    7. mimetype: "text/x-fossil-wiki"
    8. resolution changed to: "Fixed"
    9. status changed to: "Closed"