aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-02-23 10:47:13 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2017-02-23 10:47:13 +0100
commit7cf2890d871e76c082528565f59e1d0d1055b7f9 (patch)
tree5e1ff053addae965f5e15ddf2b304b2bb0c3cb0e
parent512e870e35747c6114e0dd5e0d94060b3b3cf6a5 (diff)
Fix readdir that doesn't return dt_type
This is an incomplete fix. More readdir calls exists that should be treated. Change-Id: Ib80c9f4ac8fe7ce02d22968a9cf37f7841514f57 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/wgtpkg-zip.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wgtpkg-zip.c b/src/wgtpkg-zip.c
index e450c0f..a182261 100644
--- a/src/wgtpkg-zip.c
+++ b/src/wgtpkg-zip.c
@@ -243,6 +243,7 @@ static int zwr(struct zws *zws, size_t offset)
zip_int64_t z64;
struct zip_source *zsrc;
FILE *fp;
+ struct stat st;
fd = openat(workdirfd, offset ? zws->name : ".", O_DIRECTORY|O_RDONLY);
if (fd < 0) {
@@ -275,6 +276,13 @@ static int zwr(struct zws *zws, size_t offset)
ERROR("invalid name %s", zws->name);
goto error;
}
+ 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:
z64 = zip_dir_add(zws->zip, zws->name, ZIP_FL_ENC_UTF_8);