Replace lsdir system call by readdir, isdir system calls,
[pintos-anon] / src / tests / filesys / extended / dir-lsdir.c
index 1896de32d884b07628331e2918e570ce7f90cb32..254e59501b504f2dfb7c7d08eb1ca67ccf41d7ee 100644 (file)
@@ -1,3 +1,5 @@
+/* Lists the contents of a directory using readdir. */
+
 #include <syscall.h>
 #include "tests/lib.h"
 #include "tests/main.h"
@@ -5,5 +7,15 @@
 void
 test_main (void) 
 {
-  lsdir ();
+  int fd;
+  char name[READDIR_MAX_LEN + 1];
+
+  CHECK ((fd = open (".")) > 1, "open .");
+  CHECK (isdir (fd), "isdir(.)");
+
+  while (readdir (fd, name))
+    msg ("readdir: \"%s\"", name);
+
+  msg ("close .");
+  close (fd);
 }