X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgtpkg-files.c;h=0da84b378aa12c4be9c07e53679767947b2de640;hb=7553044c59814c33763bb4b1c34664dceed68735;hp=46ea0477b9f1a8df5b4edb40b4c3a00a96cc9232;hpb=2c6fcae14552ab6e7addc82516617a135f86b5ca;p=src%2Fapp-framework-main.git diff --git a/src/wgtpkg-files.c b/src/wgtpkg-files.c index 46ea047..0da84b3 100644 --- a/src/wgtpkg-files.c +++ b/src/wgtpkg-files.c @@ -1,5 +1,5 @@ /* - Copyright 2015 IoT.bzh + Copyright (C) 2015-2019 IoT.bzh author: José Bollo @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "verbose.h" #include "wgtpkg-workdir.h" @@ -50,7 +52,7 @@ static unsigned int what_signature(const char *name) return UINT_MAX; len = sizeof(distributor_file_prefix)-1; - if (memcmp(name, distributor_file_prefix, len)) + if (strncmp(name, distributor_file_prefix, len)) return 0; if (name[len] <= '0' || name[len] > '9') return 0; @@ -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) {