aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-09 12:56:47 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 14:12:02 +0100
commit2fdc44f69750b44ab7b1a5fb5f3a447c3607038b (patch)
treea9f980a9afb411e4b5385bd00d7b5412e1386608
parent844042f3f8c523e42b721670cea971301ea18fde (diff)
Adapt function to dynamic API
A dynamic API being dynamic, you need to pass as parameter on behalf of which API you want to act. If you are using classic v2 API then just pass a NULL pointer value. Change-Id: I9ac6b606ff25c63a05a647e418a7c2bcc4b2a7fe Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--filescan-utils.c13
-rw-r--r--filescan-utils.h2
2 files changed, 8 insertions, 7 deletions
diff --git a/filescan-utils.c b/filescan-utils.c
index d590aab..60905a6 100644
--- a/filescan-utils.c
+++ b/filescan-utils.c
@@ -130,19 +130,21 @@ const char *GetBinderName() {
return binderName;
}
-#ifndef USE_API_DYN
-char *GetBindingDirPath()
+char *GetBindingDirPath(struct afb_dynapi *dynapi)
{
// A file description should not be greater than 999.999.999
char fd_link[CONTROL_MAXPATH_LEN];
char retdir[CONTROL_MAXPATH_LEN];
- sprintf(fd_link, "/proc/self/fd/%d", afb_daemon_rootdir_get_fd());
-
ssize_t len;
+
+ if(dynapi)
+ sprintf(fd_link, "/proc/self/fd/%d", afb_dynapi_rootdir_get_fd(dynapi));
+ else
+ sprintf(fd_link, "/proc/self/fd/%d", afb_daemon_rootdir_get_fd_v2());
+
if((len = readlink(fd_link, retdir, sizeof(retdir)-1)) == -1)
{
perror("lstat");
- AFB_ERROR("Error reading stat of link: %s", fd_link);
strncpy(retdir, "/tmp", 4);
}
else
@@ -152,4 +154,3 @@ char *GetBindingDirPath()
return strndup(retdir, sizeof(retdir));
}
-#endif
diff --git a/filescan-utils.h b/filescan-utils.h
index c282c2b..fb942e0 100644
--- a/filescan-utils.h
+++ b/filescan-utils.h
@@ -51,8 +51,8 @@ typedef enum {
const char *GetMidleName(const char*name);
const char *GetBinderName();
json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *pre, const char *ext);
-char *GetBindingDirPath();
+char *GetBindingDirPath(struct afb_dynapi *dynapi);
#ifdef __cplusplus
}