Replace lsdir system call by readdir, isdir system calls,
[pintos-anon] / src / filesys / fsutil.c
index 8ef5d98f2045f88d3f0a2fb5ed1490476a85a5db..14e615f8c989b5ad0863fd94d58a316068d2614d 100644 (file)
@@ -3,19 +3,27 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "filesys/directory.h"
 #include "filesys/file.h"
 #include "filesys/filesys.h"
 #include "devices/disk.h"
-#include "threads/mmu.h"
 #include "threads/malloc.h"
 #include "threads/palloc.h"
+#include "threads/vaddr.h"
 
 /* List files in the root directory. */
 void
 fsutil_ls (char **argv UNUSED) 
 {
+  struct dir *dir;
+  char name[NAME_MAX + 1];
+  
   printf ("Files in the root directory:\n");
-  filesys_list ();
+  dir = dir_open_root ();
+  if (dir == NULL)
+    PANIC ("root dir open failed");
+  while (dir_readdir (dir, name))
+    printf ("%s\n", name);
   printf ("End of listing.\n");
 }