aboutsummaryrefslogtreecommitdiffstats
path: root/tests/readdir_inode.c
diff options
context:
space:
mode:
authorMartin Pärtel <martin.partel@gmail.com>2012-04-05 12:56:05 +0300
committerMartin Pärtel <martin.partel@gmail.com>2012-04-05 12:56:05 +0300
commit2ee96eccd49c8f7f722b6dc21b60147a6c4997ec (patch)
tree935773238e6a137bfa694bf23e664f9d9f41c8a1 /tests/readdir_inode.c
parentcfb79b08a1e0b72b8d905b24b565485eef13bd3e (diff)
downloadbindfs-2ee96eccd49c8f7f722b6dc21b60147a6c4997ec.tar.gz
Made -ouse_ino and -oreaddir_ino the default to mirror inodes.
Diffstat (limited to 'tests/readdir_inode.c')
-rw-r--r--tests/readdir_inode.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/readdir_inode.c b/tests/readdir_inode.c
new file mode 100644
index 0000000..a216c7e
--- /dev/null
+++ b/tests/readdir_inode.c
@@ -0,0 +1,36 @@
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+
+int main(int argc, char* argv[])
+{
+ DIR* dirp;
+ struct dirent* dent;
+
+ if (argc != 2) {
+ fprintf(stderr, "Usage: readdir_inode dir\n");
+ return 1;
+ }
+
+ dirp = opendir(argv[1]);
+ if (dirp == NULL) {
+ perror("failed to open directory");
+ return 2;
+ }
+
+ dent = readdir(dirp);
+ while (dent != NULL) {
+ if (errno != 0) {
+ perror("failed to read directory entry");
+ return 3;
+ }
+ printf("%llu %s\n", (unsigned long long)dent->d_ino, dent->d_name);
+ dent = readdir(dirp);
+ }
+
+ closedir(dirp);
+
+ return 0;
+}