Whamcloud - gitweb
land b_eq on HEAD
[fs/lustre-release.git] / lustre / liblustre / tests / test_common.c
similarity index 91%
rename from lustre/liblustre/test_common.c
rename to lustre/liblustre/tests/test_common.c
index 210d57e..6f6676e 100644 (file)
@@ -6,6 +6,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
+#include <dirent.h>
 
 #include "test_common.h"
 
@@ -243,7 +244,7 @@ void t_echo_create(const char *path, const char *str)
         }
 }
 
-void _t_grep(const char *path, char *str, int should_contain)
+static void _t_grep(const char *path, char *str, int should_contain)
 {
        char buf[1024];
        int fd;
@@ -278,3 +279,25 @@ void t_grep_v(const char *path, char *str)
 {
        _t_grep(path, str, 0);
 }
+
+void t_ls(int fd, char *buf, int size)
+{
+       struct dirent64 *ent;
+       int rc, pos;
+       loff_t base = 0;
+
+       printf("dir entries listing...\n");
+       while ((rc = getdirentries64(fd, buf, size, &base)) > 0) {
+               pos = 0;
+               while (pos < rc) {
+                       ent = (struct dirent64 *) ((char*) buf + pos);
+                       printf("%s\n", ent->d_name);
+                       pos += ent->d_reclen;
+               }
+       }
+
+       if (rc < 0) {
+               printf("getdents error %d\n", rc);
+               EXIT(-1);
+       }
+}