Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/gen/opendir.c
Show First 20 Lines • Show All 267 Lines • ▼ Show 20 Lines | for (dpv = NULL;;) { | ||||
} | } | ||||
} | } | ||||
dirp->dd_len = len; | dirp->dd_len = len; | ||||
dirp->dd_size = ddptr - dirp->dd_buf; | dirp->dd_size = ddptr - dirp->dd_buf; | ||||
return (true); | return (true); | ||||
} | } | ||||
static bool | |||||
is_unionstack(int fd) | |||||
{ | |||||
struct statfs sfb; | |||||
int unionstack; | |||||
unionstack = _fcntl(fd, F_ISUNIONSTACK); | |||||
if (unionstack != -1) | |||||
return (unionstack); | |||||
/* | /* | ||||
* Temporary compat for kernels which don't provide F_ISUNIONSTACK. | |||||
*/ | |||||
if (_fstatfs(fd, &sfb) < 0) | |||||
return (true); | |||||
return (strcmp(sfb.f_fstypename, "unionfs") == 0 || | |||||
(sfb.f_flags & MNT_UNION)); | |||||
} | |||||
/* | |||||
* Common routine for opendir(3), __opendir2(3) and fdopendir(3). | * Common routine for opendir(3), __opendir2(3) and fdopendir(3). | ||||
*/ | */ | ||||
static DIR * | static DIR * | ||||
__opendir_common(int fd, int flags, bool use_current_pos) | __opendir_common(int fd, int flags, bool use_current_pos) | ||||
{ | { | ||||
DIR *dirp; | DIR *dirp; | ||||
int incr; | int incr; | ||||
int saved_errno; | int saved_errno; | ||||
Show All 21 Lines | __opendir_common(int fd, int flags, bool use_current_pos) | ||||
if ((incr % DIRBLKSIZ) != 0) | if ((incr % DIRBLKSIZ) != 0) | ||||
incr = DIRBLKSIZ; | incr = DIRBLKSIZ; | ||||
/* | /* | ||||
* Determine whether this directory is the top of a union stack. | * Determine whether this directory is the top of a union stack. | ||||
*/ | */ | ||||
unionstack = false; | unionstack = false; | ||||
if (flags & DTF_NODUP) { | if (flags & DTF_NODUP) { | ||||
struct statfs sfb; | unionstack = is_unionstack(fd); | ||||
if (_fstatfs(fd, &sfb) == 0) { | |||||
unionstack = strcmp(sfb.f_fstypename, "unionfs") == 0 || | |||||
(sfb.f_flags & MNT_UNION); | |||||
} | |||||
} | } | ||||
if (unionstack) { | if (unionstack) { | ||||
if (!_filldir(dirp, use_current_pos)) | if (!_filldir(dirp, use_current_pos)) | ||||
goto fail; | goto fail; | ||||
dirp->dd_flags |= __DTF_READALL; | dirp->dd_flags |= __DTF_READALL; | ||||
} else { | } else { | ||||
dirp->dd_len = incr; | dirp->dd_len = incr; | ||||
Show All 32 Lines |