Overview
| Artifact ID: | 985161716d93f48d78a8c90b178f7e8141d8a8c1 |
|---|---|
| Ticket: | 1034337fffffffffffffffffffffffffffffffff
recursive file/dir delete broken on OSX |
| User & Date: | hobbs on 2005-10-04 01:23:32 |
Changes
- icomment:
Logged In: YES user_id=72656 This is from a discussion with DAS on the problem (me > quoted, DAS bare): > So I'm curious whether this should be considered "correct" across > platforms or not. It certainly seems undesirable that a file delete > -force can effectively hang due to NFS file recreation. I basically just implemented in TraverseUnixTree() the change described by the apple note, i.e. the need to do a rewind after any readdir loop involving deletion of files in the directory being iterated. As the note explains, it is unspecified if readdir() iterates over all files in that case, and for HFS file systems this is indeed not always the case (c.f. test fCmd-20.2). Note that this issue may occur on systems other than Darwin if they have an HFS filesystem mounted via NFS as mentioned in the note. > In NFS world, if a file open and if gets deleted by some other > process, the file will be renamed as .nfsXXX(and will have same contents of > this > deleted file). Any dir which has these type of hidden files cannot be > deleted. clearly this behaviour will cause an infinite loop problem with the rewind code as implemented as any non-empty dir cannot ever be emptied even with all the calls to TclpDeleteFile() during the readdir lopp returning no errors... (of course, IMHO returning no error when deleting such a special .nfsXXX file should probably not be considered correct behaviour...) The simplest solution would be to special case those .nfsXXX names at the top of TraverseUnixTree(), where we already check for . and .. names. Of course if similar issues exist with other filesystems that use other magic names, this is not a good general solution... Otherwise, it would be possible to reimplement recursive deletion by first enumerating all directory entries and only then deleting them all, this would avoid the unspecified readdir behaviour(), but could present memory issues for large directory trees Darwin and other BSDs also have the more efficient fts_ family of functions for directory traversal (c.f. man 3 fts on OSX) which do not have this issue AFAICT, so TraverseUnixTree() could be reimplemented using this such platforms, but that will not solve the issue generally either...
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"