Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Improves naming of session's module
[src/app-framework-binder.git]
/
src
/
afb-api-so.c
diff --git
a/src/afb-api-so.c
b/src/afb-api-so.c
index
5fa3e44
..
74f94f3
100644
(file)
--- a/
src/afb-api-so.c
+++ b/
src/afb-api-so.c
@@
-22,6
+22,7
@@
#include <assert.h>
#include <string.h>
#include <dirent.h>
#include <assert.h>
#include <string.h>
#include <dirent.h>
+#include <errno.h>
#include <dlfcn.h>
#include <unistd.h>
#include <limits.h>
#include <dlfcn.h>
#include <unistd.h>
#include <limits.h>
@@
-32,7
+33,7
@@
#include <afb/afb-req-itf.h>
#include <afb/afb-event-itf.h>
#include <afb/afb-req-itf.h>
#include <afb/afb-event-itf.h>
-#include "session.h"
+#include "
afb-
session.h"
#include "afb-common.h"
#include "afb-context.h"
#include "afb-apis.h"
#include "afb-common.h"
#include "afb-context.h"
#include "afb-apis.h"
@@
-350,7
+351,7
@@
error:
static int adddirs(char path[PATH_MAX], size_t end)
{
DIR *dir;
static int adddirs(char path[PATH_MAX], size_t end)
{
DIR *dir;
- struct dirent
ent, *resul
t;
+ struct dirent
*den
t;
size_t len;
/* open the DIR now */
size_t len;
/* open the DIR now */
@@
-365,29
+366,34
@@
static int adddirs(char path[PATH_MAX], size_t end)
if (end)
path[end++] = '/';
for (;;) {
if (end)
path[end++] = '/';
for (;;) {
- readdir_r(dir, &ent, &result);
- if (result == NULL)
+ errno = 0;
+ dent = readdir(dir);
+ if (dent == NULL) {
+ if (errno != 0)
+ ERROR("read error while scanning directory %.*s: %m", (int)(end - 1), path);
break;
break;
+ }
- len = strlen(
ent.
d_name);
+ len = strlen(
dent->
d_name);
if (len + end >= PATH_MAX) {
if (len + end >= PATH_MAX) {
- ERROR("path too long while scanning bindings for %s",
ent.
d_name);
+ ERROR("path too long while scanning bindings for %s",
dent->
d_name);
continue;
}
continue;
}
- memcpy(&path[end], ent.d_name, len+1);
- if (ent.d_type == DT_DIR) {
+ if (dent->d_type == DT_DIR) {
/* case of directories */
/* case of directories */
- if (
ent.
d_name[0] == '.') {
+ if (
dent->
d_name[0] == '.') {
if (len == 1)
continue;
if (len == 1)
continue;
- if (
ent.
d_name[1] == '.' && len == 2)
+ if (
dent->
d_name[1] == '.' && len == 2)
continue;
}
continue;
}
+ memcpy(&path[end], dent->d_name, len+1);
adddirs(path, end+len);;
adddirs(path, end+len);;
- } else if (
ent.
d_type == DT_REG) {
+ } else if (
dent->
d_type == DT_REG) {
/* case of files */
/* case of files */
- if (
!strstr(ent.d_name, ".so"
))
+ if (
memcmp(&dent->d_name[len - 3], ".so", 4
))
continue;
continue;
+ memcpy(&path[end], dent->d_name, len+1);
if (afb_api_so_add_binding(path) < 0)
return -1;
}
if (afb_api_so_add_binding(path) < 0)
return -1;
}