static int act(const char *file, struct stat *statbuf, void *args, int depth) { if (depth == 1) return TRUE; if (depth == 2 && ( !(statbuf->st_mode & (S_IFREG | S_IFLNK)) || invalid_name(file) || (!list_mode && access(file, X_OK) != 0)) ) { return SKIP; } names = xrealloc(names, (cur + 2) * sizeof(names[0])); names[cur++] = xstrdup(file); names[cur] = NULL; return TRUE; }
/* Open a directory stream on NAME. */ DIR * __opendir (const char *name) { if (__glibc_unlikely (invalid_name (name))) return NULL; if (need_isdir_precheck ()) { /* We first have to check whether the name is for a directory. We cannot do this after the open() call since the open/close operation performed on, say, a tape device might have undesirable effects. */ struct stat64 statbuf; if (__glibc_unlikely (__xstat64 (_STAT_VER, name, &statbuf) < 0)) return NULL; if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode))) { __set_errno (ENOTDIR); return NULL; } } return opendir_tail (open_not_cancel_2 (name, opendir_oflags ())); }