+ if (tflag != FTW_D)
+ return 0;
+
+ dirfd = open(fpath, 0);
+ if (dirfd < 0) {
+ fprintf(stderr, "[error] [Context] Unable to open trace "
+ "directory file descriptor.\n");
+ return 0; /* partial error */
+ }
+ metafd = openat(dirfd, "metadata", O_RDONLY);
+ if (metafd < 0) {
+ closeret = close(dirfd);
+ if (closeret < 0) {
+ perror("close");
+ return -1;
+ }
+ /* No meta data, just return */
+ return 0;
+ } else {
+ closeret = close(metafd);
+ if (closeret < 0) {
+ perror("close");
+ return -1; /* failure */
+ }
+ closeret = close(dirfd);
+ if (closeret < 0) {
+ perror("close");
+ return -1; /* failure */
+ }
+
+ /* Add path to the global list */
+ if (traversed_paths == NULL) {
+ fprintf(stderr, "[error] [Context] Invalid open path array.\n");
+ return -1;
+ }
+ g_ptr_array_add(traversed_paths, g_string_new(fpath));
+ }
+
+ return 0;
+}