Skip to content
Tcl Source Code History Of Ticket daba77ae1d
Login

History Of Ticket daba77ae1d

Artifacts Associated With Ticket daba77ae1d

  1. Ticket change [4cd8cba031] (rid 258530) by serhiy.storchaka on 2026-10-17 10:51:11:

    1. cmimetype initialized to: "text/x-fossil-wiki"
    2. comment initialized to:
      On Unix, <nowiki>[file delete -force]</nowiki> cannot remove a directory tree that is deeper than <tt>PATH_MAX</tt> (4096 bytes on Linux). <tt>rm -rf</tt> removes it without trouble. Such trees can be created by Tcl itself. For example, <nowiki>[file copy 1 1/2]</nowiki> (ticket [82049f96f8]) recurses until "file name too long" and leaves a deep <tt>1/2/1/2/...</tt> tree behind, which <nowiki>[file delete -force]</nowiki> then cannot remove.
      
      <verbatim>
      set top [file join [pwd] deep]
      # 2100 nested directories "d", built with relative mkdir/cd
      exec sh -c {mkdir "$1" && cd "$1" && i=0 &&
          while [ $i -lt 2100 ]; do mkdir d && cd -P d || exit 1; i=$((i+1)); done} sh $top
      catch {file delete -force $top} msg
      puts $msg
      puts [file exists $top]
      exec rm -rf $top
      </verbatim>
      
      Actual: <tt>error deleting "/.../deep/d/d/.../d": file name too long</tt> and the tree is still there (<tt>1</tt>).
      
      Expected: the tree is removed (<tt>0</tt>), as with <tt>rm -rf</tt>.
      
      Cause: <tt>TraverseUnixTree()</tt> in unix/tclUnixFCmd.c builds full path names. With <tt>HAVE_FTS</tt> it runs <tt>fts_open(..., FTS_PHYSICAL | FTS_NOCHDIR | ...)</tt>, so fts accesses each entry by its full path. The non-fts branch does the same with <tt>opendir()</tt>/<tt>lstat()</tt>. <tt>TraversalDelete()</tt> also removes entries by their full path. Once that path exceeds <tt>PATH_MAX</tt>, <tt>lstat()</tt> fails with <tt>ENAMETOOLONG</tt> and the deletion stops. A possible fix is a traversal relative to directory file descriptors (<tt>openat()</tt>/<tt>fstatat()</tt>/<tt>unlinkat()</tt>), as <tt>rm</tt> does, at least for deletion.
      
      Reproduced on Linux with 8.4.20, 8.5.0, 8.5.19, 8.6.0, 8.6.18, 9.0.5 and main. So it is an old limitation, not a regression.
      
    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:
      [file delete -force] fails with "file name too long" on trees deeper than PATH_MAX (Unix)
      
    11. type initialized to: "Bug"
  2. Ticket change [eb8329112d] (rid 258610) by serhiy.storchaka on 2026-10-17 13:17:31:

    1. icomment:
      Proposed fix in branch [/timeline?r=unix-delete-deep-tree|unix-delete-deep-tree]: the recursive delete works relative to directory descriptors (<tt>openat()</tt>/<tt>unlinkat()</tt>, no <tt>chdir()</tt>), as <tt>rm</tt> does, and does not follow symlinks. Test unixFCmd-bug-daba77ae1d. Copying such a tree ([82049f96f8]) still fails.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [5b8d648010] (rid 258621) by serhiy.storchaka on 2026-10-17 14:15:15:

    1. icomment:
      The branch [/timeline?r=unix-delete-deep-tree|unix-delete-deep-tree] now also skips entries that someone else deletes meanwhile. Before, the deletion stopped at such an entry and left the rest of the tree behind, while <nowiki>[file delete -force]</nowiki> still returned OK. Test unixFCmd-22.2 (the deep tree test is now unixFCmd-22.1).
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [c281bbea2a] (rid 259537) by serhiy.storchaka on 2026-10-20 18:11:29:

    1. submitter changed to: "serhiy.storchaka"