summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-02-22 18:47:48 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2017-02-22 18:47:48 +0100
commit512e870e35747c6114e0dd5e0d94060b3b3cf6a5 (patch)
treeaae6829c33ad652764f9658c08e516b6e3207a26
parent209fd4c8a7fff7ff0aadd915c072db8e14dc0375 (diff)
Fix readdir that doesn't return dt_type
This is an incomplete fix. More readdir calls exists that should be treated. Change-Id: Ic9ed98c7695a7c3d15136d0fe5eb9b5634f74d09 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/wgtpkg-files.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/wgtpkg-files.c b/src/wgtpkg-files.c
index cce6a04..0b55670 100644
--- a/src/wgtpkg-files.c
+++ b/src/wgtpkg-files.c
@@ -25,6 +25,8 @@
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
+#include <fcntl.h>
+#include <sys/stat.h>
#include "verbose.h"
#include "wgtpkg-workdir.h"
@@ -258,6 +260,7 @@ static int fill_files_rec(char name[PATH_MAX], unsigned offset)
unsigned len;
DIR *dir;
struct dirent *ent;
+ struct stat st;
fd = openat(workdirfd, offset ? name : ".", O_DIRECTORY|O_RDONLY);
if (fd < 0) {
@@ -286,6 +289,13 @@ static int fill_files_rec(char name[PATH_MAX], unsigned offset)
return -1;
} else {
memcpy(name + offset, ent->d_name, 1+len);
+ if (ent->d_type == DT_UNKNOWN) {
+ fstatat(fd, ent->d_name, &st, 0);
+ if (S_ISREG(st.st_mode))
+ ent->d_type = DT_REG;
+ else if (S_ISDIR(st.st_mode))
+ ent->d_type = DT_DIR;
+ }
switch (ent->d_type) {
case DT_DIR:
if (file_add_directory(name) == NULL) {