Port: Replace dirent->d_type by stat S_ISREG
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 9 Oct 2015 20:19:40 +0000 (16:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 14 Oct 2015 20:17:34 +0000 (16:17 -0400)
dirent->d_type is Linux specific while 'stat' is part of POSIX

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/lib/test_ctf_writer.c

index f15ad43784ac3d811bbf966523ebe24e2b1777d6..007423d1870c5cbfa39b989fe70828832b86f8d8 100644 (file)
@@ -42,6 +42,7 @@
 #include "tap/tap.h"
 #include <math.h>
 #include <float.h>
+#include <sys/stat.h>
 
 #define METADATA_LINE_SIZE 512
 #define SEQUENCE_TEST_LENGTH 10
@@ -3297,7 +3298,19 @@ int main(int argc, char **argv)
 
        struct dirent *entry;
        while ((entry = readdir(trace_dir))) {
-               if (entry->d_type == DT_REG) {
+               struct stat st;
+               char filename[PATH_MAX];
+
+               if (snprintf(filename, sizeof(filename), "%s/%s",
+                                       trace_path, entry->d_name) <= 0) {
+                       continue;
+               }
+
+               if (stat(entry->d_name, &st)) {
+                       continue;
+               }
+
+               if (S_ISREG(st.st_mode)) {
                        unlinkat(bt_dirfd(trace_dir), entry->d_name, 0);
                }
        }
This page took 0.026224 seconds and 4 git commands to generate.