Message151032
| Author |
neologix |
| Recipients |
hynek, jcea, ncoghlan, neologix, pitrou, rosslagerwall, tarek |
| Date |
2012年01月10日.23:06:21 |
| SpamBayes Score |
2.3024807e-06 |
| Marked as misclassified |
No |
| Message-id |
<CAH_1eM3u2gcQzvW42oq2ARB2GXwS3aOzFQNAYU0Y-oVc03qRGQ@mail.gmail.com> |
| In-reply-to |
<1326155629.34.0.182190024692.issue13734@psf.upfronthosting.co.za> |
| Content |
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). |
| Files |
| File name |
Uploaded |
|
fdwalk.diff
|
neologix,
2012年01月10日.23:06:20
|
|