Replace lsdir system call by readdir, isdir system calls,
[pintos-anon] / src / tests / filesys / extended / dir-lsdir.c
index 091fec589c7b628d47dd83deb795d8cf5a1a28a0..254e59501b504f2dfb7c7d08eb1ca67ccf41d7ee 100644 (file)
@@ -1,4 +1,4 @@
-/* Just runs lsdir(). */
+/* Lists the contents of a directory using readdir. */
 
 #include <syscall.h>
 #include "tests/lib.h"
@@ -7,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);
 }