os/ossrv/genericopenlibs/openenvcore/include/sys/dirent.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*-
sl@0
     2
 * Copyright (c) 1989, 1993
sl@0
     3
 *	The Regents of the University of California.  All rights reserved.
sl@0
     4
 *
sl@0
     5
 * Redistribution and use in source and binary forms, with or without
sl@0
     6
 * modification, are permitted provided that the following conditions
sl@0
     7
 * are met:
sl@0
     8
 * 1. Redistributions of source code must retain the above copyright
sl@0
     9
 *    notice, this list of conditions and the following disclaimer.
sl@0
    10
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    11
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    12
 *    documentation and/or other materials provided with the distribution.
sl@0
    13
 * 4. Neither the name of the University nor the names of its contributors
sl@0
    14
 *    may be used to endorse or promote products derived from this software
sl@0
    15
 *    without specific prior written permission.
sl@0
    16
 *
sl@0
    17
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
sl@0
    18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
sl@0
    21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    27
 * SUCH DAMAGE.
sl@0
    28
 *
sl@0
    29
 *	@(#)dirent.h	8.3 (Berkeley) 8/10/94
sl@0
    30
 * $FreeBSD: src/sys/sys/dirent.h,v 1.14 2004/04/07 04:19:49 imp Exp $
sl@0
    31
 */
sl@0
    32
sl@0
    33
#ifndef	_SYS_DIRENT_H_
sl@0
    34
#define	_SYS_DIRENT_H_
sl@0
    35
sl@0
    36
#include <sys/cdefs.h>
sl@0
    37
#include <sys/_types.h>
sl@0
    38
#include <stddef.h>
sl@0
    39
sl@0
    40
/*
sl@0
    41
 * The dirent structure defines the format of directory entries returned by
sl@0
    42
 * the getdirentries(2) system call.
sl@0
    43
 *
sl@0
    44
 * A directory entry has a struct dirent at the front of it, containing its
sl@0
    45
 * inode number, the length of the entry, and the length of the name
sl@0
    46
 * contained in the entry.  These are followed by the name padded to a 4
sl@0
    47
 * byte boundary with null bytes.  All names are guaranteed null terminated.
sl@0
    48
 * The maximum length of a name in a directory is MAXNAMLEN.
sl@0
    49
 */
sl@0
    50
sl@0
    51
struct dirent {
sl@0
    52
	__uint32_t d_fileno;		/* file number of entry */
sl@0
    53
	__uint16_t d_reclen;		/* length of this record */
sl@0
    54
	__uint8_t  d_type; 		/* file type, see below */
sl@0
    55
	__uint8_t  d_namlen;		/* length of string in d_name */
sl@0
    56
#if __BSD_VISIBLE
sl@0
    57
#define	MAXNAMLEN	255
sl@0
    58
	char	d_name[MAXNAMLEN + 1];	/* name must be no longer than this */
sl@0
    59
#else
sl@0
    60
	char	d_name[255 + 1];	/* name must be no longer than this */
sl@0
    61
#endif
sl@0
    62
};
sl@0
    63
sl@0
    64
#if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
sl@0
    65
#define dirent64	dirent
sl@0
    66
#endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
sl@0
    67
sl@0
    68
sl@0
    69
#ifdef __SYMBIAN32__
sl@0
    70
struct wdirent {
sl@0
    71
	unsigned long	d_fileno;
sl@0
    72
	unsigned short	d_namlen;
sl@0
    73
	wchar_t*		d_name;
sl@0
    74
};
sl@0
    75
sl@0
    76
#if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
sl@0
    77
#define wdirent64	wdirent
sl@0
    78
#endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
sl@0
    79
sl@0
    80
typedef struct __EPOC32_WDIR WDIR;
sl@0
    81
#endif
sl@0
    82
sl@0
    83
sl@0
    84
#if __BSD_VISIBLE
sl@0
    85
/*
sl@0
    86
 * File types
sl@0
    87
 */
sl@0
    88
#define	DT_UNKNOWN	 0
sl@0
    89
#define	DT_FIFO		 1
sl@0
    90
#define	DT_CHR		 2
sl@0
    91
#define	DT_DIR		 4
sl@0
    92
#define	DT_BLK		 6
sl@0
    93
#define	DT_REG		 8
sl@0
    94
#define	DT_LNK		10
sl@0
    95
#define	DT_SOCK		12
sl@0
    96
#define	DT_WHT		14
sl@0
    97
sl@0
    98
/*
sl@0
    99
 * Convert between stat structure types and directory types.
sl@0
   100
 */
sl@0
   101
#define	IFTODT(mode)	(((mode) & 0170000) >> 12)
sl@0
   102
#define	DTTOIF(dirtype)	((dirtype) << 12)
sl@0
   103
sl@0
   104
/*
sl@0
   105
 * The _GENERIC_DIRSIZ macro gives the minimum record length which will hold
sl@0
   106
 * the directory entry.  This requires the amount of space in struct direct
sl@0
   107
 * without the d_name field, plus enough space for the name with a terminating
sl@0
   108
 * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
sl@0
   109
 *
sl@0
   110
 * XXX although this macro is in the implementation namespace, it requires
sl@0
   111
 * a manifest constant that is not.
sl@0
   112
 */
sl@0
   113
#define	_GENERIC_DIRSIZ(dp) \
sl@0
   114
    ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
sl@0
   115
#endif /* __BSD_VISIBLE */
sl@0
   116
sl@0
   117
#ifdef _KERNEL
sl@0
   118
#define	GENERIC_DIRSIZ(dp)	_GENERIC_DIRSIZ(dp)
sl@0
   119
#endif
sl@0
   120
sl@0
   121
#endif /* !_SYS_DIRENT_H_ */