ftw() and AustinDraft
Thorsten Kukuk
kukuk@suse.de
Thu Dec 13 10:33:00 GMT 2001
On Tue, Dec 11, Thorsten Kukuk wrote:
> On Mon, Dec 10, Ulrich Drepper wrote:
>
> > Thorsten Kukuk <kukuk@suse.de> writes:
> >
> > > I have a small patch for this which works with all of my test cases
> > > (LSB.os test suite). But I'm not sure if it is really correct, there
> > > are to much other cases which I could break.
> >
> > The patch looks OK except that __access must be used. I've applied
> > the patch and added a test case. Thanks,
>
> No, it was not ok :-(
> Found another test case where it now breaks. Looks like I have to
> check at first if the argument is a directory or something else
> and that I cannot use access on a direcotry. I will look at it
> today again.
Ok, I got the clarification, which of the tests is wrong and which
is correct.
Looks like we have to check:
ftw(dir,...);
"dir" must be searchable (x bit is set).
"dirname(dir)" must be readable.
I don't like the "dirname" call here very much, but I don't know if
searching the parent dir and the handling of the special cases is
really faster. Here is an updated patch which passes now all tests
except one with symlink handling (I will look at that the next days).
Thorsten
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE GmbH Deutschherrenstr. 15-19 D-90429 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B
-------------- next part --------------
2001-12-13 Thorsten Kukuk <kukuk@suse.de>
* io/ftw.c(ftw_startup): Correct last patch: check, if dir
is searchable and parent dir is readable.
--- io/ftw.c 2001/12/10 23:47:20 1.31
+++ io/ftw.c 2001/12/13 17:14:16
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <sys/param.h>
#include <include/sys/stat.h>
+#include <libgen.h>
/* #define NDEBUG 1 */
#include <assert.h>
@@ -473,8 +474,14 @@
return -1;
}
- if (__access (dir, R_OK) != 0)
+ if (__access (dir, X_OK) != 0)
return -1;
+ else
+ {
+ char *bdir = dirname (strdupa (dir));
+ if (__access (bdir, R_OK) != 0)
+ return -1;
+ }
data.maxdir = descriptors < 1 ? 1 : descriptors;
data.actdir = 0;
More information about the Libc-alpha
mailing list