tst-scandir.c 274 B

123456789101112131415161718192021
  1. #include <dirent.h>
  2. #include <errno.h>
  3. int skip_all(const struct dirent *dirbuf)
  4. {
  5. __set_errno(EBADF);
  6. return 0;
  7. }
  8. int main()
  9. {
  10. struct dirent **namelist;
  11. int n;
  12. n = scandir(".", &namelist, skip_all, 0);
  13. if (n < 0) {
  14. perror("scandir");
  15. return 1;
  16. }
  17. return 0;
  18. }