|
2026-10-20
| ||
| 18:11 | • Ticket [daba77ae1d] file delete -force fails with "file name too long&quo... artifact: c281bbea2a user: serhiy.storchaka | |
|
2026-10-19
| ||
| 18:54 | • Ticket [82049f96f8] file copy attempts to copy directory into itself status ... artifact: 616bbebb7e user: serhiy.storchaka | |
|
2026-10-17
| ||
| 14:15 | • Ticket [daba77ae1d] file delete -force fails with "file name too long&quo... artifact: 5b8d648010 user: serhiy.storchaka | |
| 13:17 | • Ticket [daba77ae1d]: 3 changes artifact: eb8329112d user: serhiy.storchaka | |
| 13:16 | Fix [daba77ae1d]: on Unix, [file delete -force] failed with "file name too long" on trees deeper tha... check-in: 920c3db3cb user: serhiy.storchaka tags: unix-delete-deep-tree | |
| 10:53 | • Ticket [82049f96f8] file copy attempts to copy directory into itself status ... artifact: 433c923ce3 user: serhiy.storchaka | |
| 10:51 | • New ticket [daba77ae1d] file delete -force fails with "file name too long... artifact: 4cd8cba031 user: serhiy.storchaka | |
[file delete -force] fails with "file name too long" on trees deeper than PATH_MAX (Unix)
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
Actual: error deleting "/.../deep/d/d/.../d": file name too long and the tree is still there (1).
Expected: the tree is removed (0), as with rm -rf.
Cause: TraverseUnixTree() in unix/tclUnixFCmd.c builds full path names. With HAVE_FTS it runs fts_open(..., FTS_PHYSICAL | FTS_NOCHDIR | ...), so fts accesses each entry by its full path. The non-fts branch does the same with opendir()/lstat(). TraversalDelete() also removes entries by their full path. Once that path exceeds PATH_MAX, lstat() fails with ENAMETOOLONG and the deletion stops. A possible fix is a traversal relative to directory file descriptors (openat()/fstatat()/unlinkat()), as rm 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.
616bbebb7eTicket [82049f96f8] file copy attempts to copy directory into itself status still Open with 4 other changes ticket2026-10-19 18:54:12920c3db3cbFix [daba77ae1d]: on Unix, [file delete -force] failed with "file name too long" on trees deeper than PATH_MAX. Delete recursively relative to directory descriptors (openat/unlinkat), like rm(1). check-in2026-10-17 13:16:59433c923ce3Ticket [82049f96f8] file copy attempts to copy directory into itself status still Open with 3 other changes ticket2026-10-17 10:53:34
Proposed fix in branch unix-delete-deep-tree: the recursive delete works relative to directory descriptors (openat()/unlinkat(), no chdir()), as rm does, and does not follow symlinks. Test unixFCmd-bug-daba77ae1d. Copying such a tree ([82049f96f8]) still fails.
The branch 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 [file delete -force] still returned OK. Test unixFCmd-22.2 (the deep tree test is now unixFCmd-22.1).