readdir.c 203 B

123456789101112131415
  1. #include <u.h>
  2. #include <libc.h>
  3. void
  4. main(void)
  5. {
  6. Dir d;
  7. int fd, n;
  8. fd = open("/mail/fs", OREAD);
  9. while((n = dirread(fd, &d, sizeof(d))) > 0){
  10. print("%s\n", d.name);
  11. }
  12. print("n = %d\n", n);
  13. }