Message151032
Here's a patch with tests and documentation.
I noticed something surprising:
walk() with followlinks=False returns links to directories as
directories (in dirnames).
I find this surprising, since if you don't follow symlinks, those are
just files (and you don't recurse into it). Also, it's a pain when you
want to remove dirnames, since you have to distinguish between a link
and a directory (unlink()/rmdir() or unlinkat() without/with
AT_REMOVEDIR)
To be consistent with this behavior, I had to change fdwalk() (I
renamed it to be consistent with fdlistdir()) to perform a call to
fstatat() without AT_SYMLINK_NOFOLLOW, since otherwise it would report
such links as files.
So the bottom line is that because of this, you can have up to 3
stat() calls per entry:
- fstatat(rootfd, name)
- fstatat(rootfd, name, AT_SYMLINK_NOFOLLOW) right before opening the directory
- fstat(dirfd) right after open to check that we're dealing with the same file
(walk() currently uses two stat() per entry, so it's not too bad). |
File name |
Uploaded |
fdwalk.diff
|
neologix,
2012-01-10.23:06:20
|
|
Date |
User |
Action |
Args |
2012-01-10 23:06:23 | neologix | set | recipients:
+ neologix, jcea, ncoghlan, pitrou, tarek, rosslagerwall, hynek |
2012-01-10 23:06:21 | neologix | link | issue13734 messages |
2012-01-10 23:06:21 | neologix | create | |
|