dirent.h revision 53812
1131320Sdas/*- 2131320Sdas * Copyright (c) 1989, 1993 3131320Sdas * The Regents of the University of California. All rights reserved. 4131320Sdas * 5131320Sdas * Redistribution and use in source and binary forms, with or without 6131320Sdas * modification, are permitted provided that the following conditions 7131320Sdas * are met: 8131320Sdas * 1. Redistributions of source code must retain the above copyright 9131320Sdas * notice, this list of conditions and the following disclaimer. 10131320Sdas * 2. Redistributions in binary form must reproduce the above copyright 11131320Sdas * notice, this list of conditions and the following disclaimer in the 12131320Sdas * documentation and/or other materials provided with the distribution. 13131320Sdas * 3. All advertising materials mentioning features or use of this software 14131320Sdas * must display the following acknowledgement: 15131320Sdas * This product includes software developed by the University of 16131320Sdas * California, Berkeley and its contributors. 17131320Sdas * 4. Neither the name of the University nor the names of its contributors 18131320Sdas * may be used to endorse or promote products derived from this software 19131320Sdas * without specific prior written permission. 20131320Sdas * 21131320Sdas * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22131320Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23131320Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24131320Sdas * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25131320Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26131320Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27131320Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28131320Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29131320Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30131320Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31131320Sdas * SUCH DAMAGE. 32131320Sdas * 33131320Sdas * @(#)dirent.h 8.2 (Berkeley) 7/28/94 34131320Sdas * 35131320Sdas * $FreeBSD: head/include/dirent.h 53812 1999-11-28 05:38:13Z alfred $ 36131320Sdas * 37131320Sdas */ 38131320Sdas 39131320Sdas#ifndef _DIRENT_H_ 40131320Sdas#define _DIRENT_H_ 41131320Sdas 42131320Sdas/* 43131320Sdas * The kernel defines the format of directory entries returned by 44131320Sdas * the getdirentries(2) system call. 45131320Sdas */ 46131320Sdas#include <sys/dirent.h> 47131320Sdas 48131320Sdas#ifdef _POSIX_SOURCE 49131320Sdastypedef void * DIR; 50131320Sdas#else 51131320Sdas 52131320Sdas#define d_ino d_fileno /* backward compatibility */ 53131320Sdas 54/* definitions for library routines operating on directories. */ 55#define DIRBLKSIZ 1024 56 57/* structure describing an open directory. */ 58typedef struct _dirdesc { 59 int dd_fd; /* file descriptor associated with directory */ 60 long dd_loc; /* offset in current buffer */ 61 long dd_size; /* amount of data returned by getdirentries */ 62 char *dd_buf; /* data buffer */ 63 int dd_len; /* size of data buffer */ 64 long dd_seek; /* magic cookie returned by getdirentries */ 65 long dd_rewind; /* magic cookie for rewinding */ 66 int dd_flags; /* flags for readdir */ 67} DIR; 68 69#define dirfd(dirp) ((dirp)->dd_fd) 70 71/* flags for opendir2 */ 72#define DTF_HIDEW 0x0001 /* hide whiteout entries */ 73#define DTF_NODUP 0x0002 /* don't return duplicate names */ 74#define DTF_REWIND 0x0004 /* rewind after reading union stack */ 75#define __DTF_READALL 0x0008 /* everything has been read */ 76 77#ifndef NULL 78#define NULL 0 79#endif 80 81#endif /* _POSIX_SOURCE */ 82 83#ifndef KERNEL 84 85#include <sys/cdefs.h> 86 87__BEGIN_DECLS 88DIR *opendir __P((const char *)); 89struct dirent *readdir __P((DIR *)); 90void rewinddir __P((DIR *)); 91int closedir __P((DIR *)); 92#ifndef _POSIX_SOURCE 93DIR *__opendir2 __P((const char *, int)); 94long telldir __P((const DIR *)); 95void seekdir __P((DIR *, long)); 96int scandir __P((const char *, struct dirent ***, 97 int (*)(struct dirent *), int (*)(const void *, const void *))); 98int alphasort __P((const void *, const void *)); 99int getdirentries __P((int, char *, int, long *)); 100#endif /* not POSIX */ 101int readdir_r __P((DIR *, struct dirent *, struct dirent **)); 102__END_DECLS 103 104#endif /* !KERNEL */ 105 106#endif /* !_DIRENT_H_ */ 107