/*
- Copyright 2015, 2016 IoT.bzh
+ Copyright 2015, 2016, 2017 IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
+#include <fcntl.h>
+#include <sys/stat.h>
#include "verbose.h"
#include "wgtpkg-workdir.h"
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;
unsigned len;
DIR *dir;
struct dirent *ent;
+ struct stat st;
fd = openat(workdirfd, offset ? name : ".", O_DIRECTORY|O_RDONLY);
if (fd < 0) {
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) {