Lines 610-615
__fts_set_clientptr_44bsd(FTS *sp, void *clientptr)
Link Here
|
610 |
sp->fts_clientptr = clientptr; |
610 |
sp->fts_clientptr = clientptr; |
611 |
} |
611 |
} |
612 |
|
612 |
|
|
|
613 |
static struct dirent * |
614 |
fts_safe_readdir(DIR *dirp, int *readdir_errno) |
615 |
{ |
616 |
struct dirent *ret; |
617 |
|
618 |
errno = 0; |
619 |
if (!dirp) |
620 |
return (NULL); |
621 |
ret = freebsd11_readdir(dirp); |
622 |
*readdir_errno = errno; |
623 |
return (ret); |
624 |
} |
625 |
|
613 |
/* |
626 |
/* |
614 |
* This is the tricky part -- do not casually change *anything* in here. The |
627 |
* This is the tricky part -- do not casually change *anything* in here. The |
615 |
* idea is to build the linked list of entries that are used by fts_children |
628 |
* idea is to build the linked list of entries that are used by fts_children |
Lines 634-640
fts_build(FTS *sp, int type)
Link Here
|
634 |
DIR *dirp; |
647 |
DIR *dirp; |
635 |
void *oldaddr; |
648 |
void *oldaddr; |
636 |
int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno, |
649 |
int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno, |
637 |
nostat, doadjust, dnamlen; |
650 |
nostat, doadjust, dnamlen, readdir_errno; |
638 |
char *cp; |
651 |
char *cp; |
639 |
|
652 |
|
640 |
/* Set current node pointer. */ |
653 |
/* Set current node pointer. */ |
Lines 738-745
fts_build(FTS *sp, int type)
Link Here
|
738 |
|
751 |
|
739 |
/* Read the directory, attaching each entry to the `link' pointer. */ |
752 |
/* Read the directory, attaching each entry to the `link' pointer. */ |
740 |
doadjust = 0; |
753 |
doadjust = 0; |
|
|
754 |
readdir_errno = 0; |
741 |
for (head = tail = NULL, nitems = 0; |
755 |
for (head = tail = NULL, nitems = 0; |
742 |
dirp && (dp = freebsd11_readdir(dirp));) { |
756 |
(dp = fts_safe_readdir(dirp, &readdir_errno));) { |
743 |
dnamlen = dp->d_namlen; |
757 |
dnamlen = dp->d_namlen; |
744 |
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) |
758 |
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) |
745 |
continue; |
759 |
continue; |
Lines 839-844
mem1: saved_errno = errno;
Link Here
|
839 |
} |
853 |
} |
840 |
++nitems; |
854 |
++nitems; |
841 |
} |
855 |
} |
|
|
856 |
|
857 |
if (readdir_errno) { |
858 |
cur->fts_errno = readdir_errno; |
859 |
/* |
860 |
* If we've not read any items yet, treat |
861 |
* the error as if we can't access the dir. |
862 |
*/ |
863 |
cur->fts_info = nitems ? FTS_ERR : FTS_DNR; |
864 |
} |
865 |
|
842 |
if (dirp) |
866 |
if (dirp) |
843 |
(void)closedir(dirp); |
867 |
(void)closedir(dirp); |
844 |
|
868 |
|
Lines 877-883
mem1: saved_errno = errno;
Link Here
|
877 |
|
901 |
|
878 |
/* If didn't find anything, return NULL. */ |
902 |
/* If didn't find anything, return NULL. */ |
879 |
if (!nitems) { |
903 |
if (!nitems) { |
880 |
if (type == BREAD) |
904 |
if (type == BREAD && |
|
|
905 |
cur->fts_info != FTS_DNR && cur->fts_info != FTS_ERR) |
881 |
cur->fts_info = FTS_DP; |
906 |
cur->fts_info = FTS_DP; |
882 |
return (NULL); |
907 |
return (NULL); |
883 |
} |
908 |
} |