in reply to readdir() on a sysopen() handle?
A file system is like a continually evolving biological organism. There can be incestuous liaisons between family groups (symlinks).
The directory structure correlates "textual names" to "structures of bits" which are called "files".
When you do something like a readdir(), you get an imperfect snapshot of the "family tree" of textual names. It is completely possible to get a filename from a readdir() which can't be opened because it doesn't exist anymore once you actually try to open that textual name because some other process has deleted that name in the meantime.
Depending upon the O/S and the type of file, it is possible to read a directory (which produces textual names), open a file (which resolves to a binary filehandle (independent of the text name)), and continue to use that file while the textual name is deleted from the directory. That situation means that one or many programs continue to use the "file" although no new program can open it because its "textual name" no longer exists.
If you get to a file and actually open that file via a symlink, that file is open for use, even if the symlink is deleted (textual representation is deleted).
I like the first post by Laurent_R. If you don't want to follow a directory symlink, don't open it if it is one. I guess you can check if that directory name is still not a symlink once you open it, but all sorts of strange thinks can still happen.
It would be helpful if you explained a bit more about what your applications does and how it handles failed directory or file "opens".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: readdir() on a sysopen() handle?
by perlhuhn (Novice) on Aug 21, 2017 at 15:33 UTC |