5 #include <darwintest.h>
6 #include <darwintest_multiprocess.h>
9 #include "../bsd/sys/dirent.h"
11 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
13 ssize_t
__getdirentries64(int fd
, void *buf
, size_t bufsize
, off_t
*basep
);
15 T_DECL(getdirentries64_extended
, "check for GETDIRENTRIES64_EOF")
17 char buf
[GETDIRENTRIES64_EXTENDED_BUFSIZE
];
18 getdirentries64_flags_t
*flags
;
24 flags
= (getdirentries64_flags_t
*)(uintptr_t)(buf
+ sizeof(buf
) -
25 sizeof(getdirentries64_flags_t
));
26 fd
= open("/", O_DIRECTORY
| O_RDONLY
);
27 T_ASSERT_POSIX_SUCCESS(fd
, "open(/)");
30 *flags
= (getdirentries64_flags_t
)~0;
31 result
= __getdirentries64(fd
, buf
, sizeof(buf
), &offset
);
32 T_ASSERT_POSIX_SUCCESS(result
, "__getdirentries64()");
33 T_ASSERT_LE((size_t)result
, sizeof(buf
) - sizeof(getdirentries64_flags_t
),
34 "The kernel should have left space for the flags");
35 T_ASSERT_NE(*flags
, (getdirentries64_flags_t
)~0,
36 "The kernel should have returned status");
38 T_ASSERT_EQ(result
, 0l, "At EOF, we really should be done");
39 T_ASSERT_TRUE(*flags
& GETDIRENTRIES64_EOF
, "And EOF should still be set");
42 T_ASSERT_NE(result
, 0l, "We're not at EOF, we should have an entry");
43 eof
= (*flags
& GETDIRENTRIES64_EOF
);