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 <llvm-libc-types/ino_t.h> 13 #include <llvm-libc-types/off_t.h> 14 15 struct dirent { 16 ino_t d_ino; 17 #ifdef __unix__ 18 off_t d_off; 19 unsigned short d_reclen; 20 #endif 21 // The user code should use strlen to determine actual the size of d_name. 22 // Likewise, it is incorrect and prohibited by the POSIX standard to detemine 23 // the size of struct dirent type using sizeof. The size should be got using 24 // a different method, for example, from the d_reclen field on Linux. 25 char d_name[1]; 26 }; 27 28 #endif // __LLVM_LIBC_TYPES_STRUCT_DIRENT_H__ 29