Code Review
/
src
/
app-framework-main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix native compilation
[src/app-framework-main.git]
/
src
/
wgtpkg-files.c
diff --git
a/src/wgtpkg-files.c
b/src/wgtpkg-files.c
index
bb758e0
..
e4b8ec6
100644
(file)
--- a/
src/wgtpkg-files.c
+++ b/
src/wgtpkg-files.c
@@
-1,5
+1,7
@@
/*
/*
- Copyright 2015 IoT.bzh
+ Copyright (C) 2015-2020 IoT.bzh
+
+ author: José Bollo <jose.bollo@iot.bzh>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@
-22,9
+24,13
@@
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <sys/stat.h>
#include "verbose.h"
#include "verbose.h"
-#include "wgtpkg.h"
+#include "wgtpkg-workdir.h"
+#include "wgtpkg-files.h"
struct fdb {
unsigned int count;
struct fdb {
unsigned int count;
@@
-46,7
+52,7
@@
static unsigned int what_signature(const char *name)
return UINT_MAX;
len = sizeof(distributor_file_prefix)-1;
return UINT_MAX;
len = sizeof(distributor_file_prefix)-1;
- if (
mem
cmp(name, distributor_file_prefix, len))
+ if (
strn
cmp(name, distributor_file_prefix, len))
return 0;
if (name[len] <= '0' || name[len] > '9')
return 0;
return 0;
if (name[len] <= '0' || name[len] > '9')
return 0;
@@
-248,11
+254,13
@@
void file_clear_flags()
allfiles.files[i]->flags &= flag_signature;
}
allfiles.files[i]->flags &= flag_signature;
}
-static int fill_files_rec(char name[PATH_MAX],
int
offset)
+static int fill_files_rec(char name[PATH_MAX],
unsigned
offset)
{
{
- int len, err, fd;
+ int err, fd;
+ unsigned len;
DIR *dir;
struct dirent *ent;
DIR *dir;
struct dirent *ent;
+ struct stat st;
fd = openat(workdirfd, offset ? name : ".", O_DIRECTORY|O_RDONLY);
if (fd < 0) {
fd = openat(workdirfd, offset ? name : ".", O_DIRECTORY|O_RDONLY);
if (fd < 0) {
@@
-270,7
+278,7
@@
static int fill_files_rec(char name[PATH_MAX], int offset)
ent = readdir(dir);
while (ent != NULL) {
ent = readdir(dir);
while (ent != NULL) {
- len = strlen(ent->d_name);
+ len =
(unsigned)
strlen(ent->d_name);
if (ent->d_name[0] == '.' && (len == 1 ||
(ent->d_name[1] == '.' && len == 2)))
;
if (ent->d_name[0] == '.' && (len == 1 ||
(ent->d_name[1] == '.' && len == 2)))
;
@@
-281,6
+289,13
@@
static int fill_files_rec(char name[PATH_MAX], int offset)
return -1;
} else {
memcpy(name + offset, ent->d_name, 1+len);
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) {
switch (ent->d_type) {
case DT_DIR:
if (file_add_directory(name) == NULL) {