#include #include #include #include int main() { int dirfd = open("/bin", O_RDONLY); if (dirfd < 0) { perror("open"); return 1; } struct luna_dirent dirent[5]; ssize_t nread; do { nread = getdents(dirfd, dirent, 5); if (nread < 0) { perror("getdents"); return 1; } for (int i = 0; i < nread; i++) { printf("%s\n", dirent[i].name); } } while (nread == 5); close(dirfd); return 0; }