Artifacts Associated With Ticket daba77ae1d
Ticket change [4cd8cba031] (rid 258530) by serhiy.storchaka on 2026-10-17 10:51:11:
- cmimetype initialized to: "text/x-fossil-wiki"
- 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. - foundin initialized to: "8.6.18, 9.0.5, 9.1.0"
- login: "serhiy.storchaka"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- subsystem initialized to: "37. File System"
- title initialized to:
[file delete -force] fails with "file name too long" on trees deeper than PATH_MAX (Unix)
- type initialized to: "Bug"
Ticket change [eb8329112d] (rid 258610) by serhiy.storchaka on 2026-10-17 13:17:31:
- 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.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [5b8d648010] (rid 258621) by serhiy.storchaka on 2026-10-17 14:15:15:
- 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).
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [c281bbea2a] (rid 259537) by serhiy.storchaka on 2026-10-20 18:11:29:
- submitter changed to: "serhiy.storchaka"