2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_SYS_DIRENT_H
8 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_SYS_DIRENT_H
10 #if defined(NACL_IN_TOOLCHAIN_HEADERS)
11 #include <sys/types.h>
13 #include "native_client/src/trusted/service_runtime/include/machine/_types.h"
16 #if defined(NACL_IN_TOOLCHAIN_HEADERS)
17 /* check the compiler toolchain */
18 # ifdef NACL_ABI_MAXNAMLEN
19 # if NACL_ABI_MAXNAMLEN != 255
20 # error "MAXNAMLEN inconsistent"
24 # error "NAME_MAX inconsistent"
28 # define NACL_ABI_MAXNAMLEN 255
30 #else /* defined(NACL_IN_TOOLCHAIN_HEADERS) */
31 # define NACL_ABI_MAXNAMLEN 255
35 * _dirdesc contains the state used by opendir/readdir/closedir.
37 typedef struct nacl_abi__dirdesc {
40 long nacl_abi_dd_size;
41 char *nacl_abi_dd_buf;
43 long nacl_abi_dd_seek;
47 * dirent represents a single directory entry.
49 struct nacl_abi_dirent {
50 nacl_abi_ino_t nacl_abi_d_ino;
51 nacl_abi_off_t nacl_abi_d_off;
52 uint16_t nacl_abi_d_reclen;
53 char nacl_abi_d_name[NACL_ABI_MAXNAMLEN + 1];
57 * external function declarations
59 extern nacl_abi_DIR *nacl_abi_opendir(const char *dirpath);
60 extern struct nacl_abi_dirent *nacl_abi_readdir(nacl_abi_DIR *direntry);
61 extern int nacl_abi_closedir(nacl_abi_DIR *direntry);
62 extern void nacl_abi_rewinddir(nacl_abi_DIR *direntry);
63 extern int nacl_abi_readdir_r(nacl_abi_DIR *direntry,
64 struct nacl_abi_dirent *entry,
65 struct nacl_abi_dirent **res);