1 //===-- Definition of type struct dirent ----------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIBC_TYPES_STRUCT_DIRENT_H 10 #define LLVM_LIBC_TYPES_STRUCT_DIRENT_H 11 12 #include "ino_t.h" 13 #include "off_t.h" 14 15 struct dirent { 16 ino_t d_ino; 17 #ifdef __linux__ 18 off_t d_off; 19 unsigned short d_reclen; 20 #endif 21 unsigned char d_type; 22 // The user code should use strlen to determine actual the size of d_name. 23 // Likewise, it is incorrect and prohibited by the POSIX standard to detemine 24 // the size of struct dirent type using sizeof. The size should be got using 25 // a different method, for example, from the d_reclen field on Linux. 26 char d_name[1]; 27 }; 28 29 #endif // LLVM_LIBC_TYPES_STRUCT_DIRENT_H 30