/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1989, 19934* The Regents of the University of California. All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. Neither the name of the University nor the names of its contributors15* may be used to endorse or promote products derived from this software16* without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*/3031#ifndef _DIRENT_H_32#define _DIRENT_H_3334/*35* The kernel defines the format of directory entries returned by36* the getdirentries(2) system call.37*/38#include <sys/cdefs.h>39#include <sys/_types.h>40#include <sys/dirent.h>4142#if __BSD_VISIBLE4344#ifndef _SIZE_T_DECLARED45typedef __size_t size_t;46#define _SIZE_T_DECLARED47#endif4849#ifndef _SSIZE_T_DECLARED50typedef __ssize_t ssize_t;51#define _SSIZE_T_DECLARED52#endif5354#ifndef _OFF_T_DECLARED55typedef __off_t off_t;56#define _OFF_T_DECLARED57#endif5859#endif /* __BSD_VISIBLE */6061#if __XSI_VISIBLE6263#ifndef _INO_T_DECLARED64typedef __ino_t ino_t;65#define _INO_T_DECLARED66#endif6768/*69* XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer70* to the specification.71*/72#define d_ino d_fileno /* backward and XSI compatibility */7374#endif /* __XSI_VISIBLE */7576#if __BSD_VISIBLE7778#include <sys/_null.h>7980/* definitions for library routines operating on directories. */81#define DIRBLKSIZ 10248283struct _dirdesc;84typedef struct _dirdesc DIR;8586/* flags for opendir2 */87#define DTF_HIDEW 0x0001 /* hide whiteout entries */88#define DTF_NODUP 0x0002 /* don't return duplicate names */89#define DTF_REWIND 0x0004 /* rewind after reading union stack */90#define __DTF_READALL 0x0008 /* everything has been read */91#define __DTF_SKIPREAD 0x0010 /* assume internal buffer is populated */9293#else /* !__BSD_VISIBLE */9495typedef void * DIR;9697#endif /* __BSD_VISIBLE */9899#ifndef _KERNEL100101__BEGIN_DECLS102#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700103int alphasort(const struct dirent **, const struct dirent **);104int dirfd(DIR *);105#endif106#if __BSD_VISIBLE107int versionsort(const struct dirent **, const struct dirent **);108DIR *__opendir2(const char *, int);109int fdclosedir(DIR *);110ssize_t getdents(int, char *, size_t);111ssize_t getdirentries(int, char *, size_t, off_t *);112#endif113DIR *opendir(const char *);114DIR *fdopendir(int);115struct dirent *116readdir(DIR *);117#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500118int readdir_r(DIR *, struct dirent *, struct dirent **)119__deprecated1("Does not take variable {NAME_MAX} into account");120#endif121void rewinddir(DIR *);122#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700123int scandir(const char *, struct dirent ***,124int (*)(const struct dirent *), int (*)(const struct dirent **,125const struct dirent **));126#ifdef __BLOCKS__127int scandir_b(const char *, struct dirent ***,128int (^)(const struct dirent *),129int (^)(const struct dirent **, const struct dirent **));130#endif131#endif132#if __BSD_VISIBLE133int fdscandir(int, struct dirent ***,134int (*)(const struct dirent *), int (*)(const struct dirent **,135const struct dirent **));136#ifdef __BLOCKS__137int fdscandir_b(int, struct dirent ***,138int (^)(const struct dirent *),139int (^)(const struct dirent **, const struct dirent **));140#endif141int scandirat(int, const char *, struct dirent ***,142int (*)(const struct dirent *), int (*)(const struct dirent **,143const struct dirent **));144#ifdef __BLOCKS__145int scandirat_b(int, const char *, struct dirent ***,146int (^)(const struct dirent *),147int (^)(const struct dirent **, const struct dirent **));148#endif149#endif150#if __XSI_VISIBLE151void seekdir(DIR *, long);152long telldir(DIR *);153#endif154int closedir(DIR *);155__END_DECLS156157#endif /* !_KERNEL */158159#endif /* !_DIRENT_H_ */160161162