host_root_fs.c 570 B

12345678910111213141516171819202122232425262728293031
  1. #include <dirent.h>
  2. #include <stdio.h>
  3. static int showdir(char* path) {
  4. struct dirent* de;
  5. DIR* dir = opendir(path);
  6. if (!dir) {
  7. printf("Could not open directory `%s`\n", path);
  8. return 1;
  9. }
  10. printf("Contents of directory `%s`:\n", path);
  11. while ((de = readdir(dir)))
  12. printf(" %s\n", de->d_name);
  13. printf("\n");
  14. closedir(dir);
  15. return 0;
  16. }
  17. int main(int argc, char** argv) {
  18. if (showdir("/"))
  19. return 1;
  20. if (showdir("/var/"))
  21. return 1;
  22. puts("Test was successful");
  23. return 0;
  24. }