Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/gen/fts-compat.c
Show First 20 Lines • Show All 627 Lines • ▼ Show 20 Lines | |||||
fts_build(FTS *sp, int type) | fts_build(FTS *sp, int type) | ||||
{ | { | ||||
struct freebsd11_dirent *dp; | struct freebsd11_dirent *dp; | ||||
FTSENT *p, *head; | FTSENT *p, *head; | ||||
int nitems; | int nitems; | ||||
FTSENT *cur, *tail; | FTSENT *cur, *tail; | ||||
DIR *dirp; | DIR *dirp; | ||||
void *oldaddr; | void *oldaddr; | ||||
size_t dnamlen; | |||||
int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno, | int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno, | ||||
nostat, doadjust; | nostat, doadjust, dnamlen; | ||||
char *cp; | char *cp; | ||||
/* Set current node pointer. */ | /* Set current node pointer. */ | ||||
cur = sp->fts_cur; | cur = sp->fts_cur; | ||||
/* | /* | ||||
* Open the directory for reading. If this fails, we're done. | * Open the directory for reading. If this fails, we're done. | ||||
* If being called from fts_read, set the fts_info field. | * If being called from fts_read, set the fts_info field. | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | #endif | ||||
/* Read the directory, attaching each entry to the `link' pointer. */ | /* Read the directory, attaching each entry to the `link' pointer. */ | ||||
doadjust = 0; | doadjust = 0; | ||||
for (head = tail = NULL, nitems = 0; | for (head = tail = NULL, nitems = 0; | ||||
dirp && (dp = freebsd11_readdir(dirp));) { | dirp && (dp = freebsd11_readdir(dirp));) { | ||||
dnamlen = dp->d_namlen; | dnamlen = dp->d_namlen; | ||||
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) | if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) | ||||
continue; | continue; | ||||
if ((p = fts_alloc(sp, dp->d_name, (int)dnamlen)) == NULL) | if ((p = fts_alloc(sp, dp->d_name, dnamlen)) == NULL) | ||||
goto mem1; | goto mem1; | ||||
if (dnamlen >= maxlen) { /* include space for NUL */ | if (dnamlen >= maxlen) { /* include space for NUL */ | ||||
oldaddr = sp->fts_path; | oldaddr = sp->fts_path; | ||||
if (fts_palloc(sp, dnamlen + len + 1)) { | if (fts_palloc(sp, dnamlen + len + 1)) { | ||||
/* | /* | ||||
* No more memory for path or structures. Save | * No more memory for path or structures. Save | ||||
* errno, free up the current structure and the | * errno, free up the current structure and the | ||||
* structures already allocated. | * structures already allocated. | ||||
▲ Show 20 Lines • Show All 460 Lines • Show Last 20 Lines |