diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-12-03 17:14:59 +0100 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-12-04 14:38:18 +0100 |
commit | 4480e19e555318d04a8b63f8e5ef827b627ea408 (patch) | |
tree | e163044ec3643727a5004d808eb71acc30a6f23d | |
parent | 5b9cce9fd0a1da9aeaaba8465f9a2780282a2247 (diff) |
Add 'GetAFBRootDirPath' function
Add 'GetAFBRootDirPath' function that replace 'GetBindingDirPath'
function as previous 'GetBindingDirPath' was returning
'Binder root directory path' and not 'Binding directory path'.
'GetBindingDirPath' function has been kept to call 'GetAFBRootDirPath'
for compatibility issues.
FYI:
- 'Binding directory path' is the path to the directory that contains
the binding.
- 'Binder root directory path' is the path specified at binder launch
using '--rootdir' option. If no option is specified, binder root
directory is set to the current directory.
BUG-AGL: SPEC-3009
Change-Id: I3f4bb64f1d67558a291481e0987bd93666535add
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r-- | docs/filescan-utils.md | 32 | ||||
-rw-r--r-- | filescan-utils.c | 11 | ||||
-rw-r--r-- | filescan-utils.h | 42 |
3 files changed, 69 insertions, 16 deletions
diff --git a/docs/filescan-utils.md b/docs/filescan-utils.md index 4a4c2d2..d91ff1c 100644 --- a/docs/filescan-utils.md +++ b/docs/filescan-utils.md @@ -26,13 +26,37 @@ Scan a directory searching all files matching pattern: 'prefix*extention'. Returns a json_object array of object with 2 parts a 'fullpath' describing the fullpath to reach the file and 'filename' containing the matched files. -## char *GetBindingDirPath_(afb_api_t api) +## char *GetAFBRootDirPathUsingFd(int fd) -For binding with a version >= 3, get the root directory path. +Get the binder root directory path (the path specified with '--rootdir' option +at binder launch, if the option is not used, the path from where the binder +is launched) using binder root directory file descriptor. -* `api` : pointer to the AFB API. +* `fd` : Binder root directory file descriptor. -Returns a string representing the path to binding root directory. +Returns a string representing the path to binder root directory. + +## char *GetAFBRootDirPath(afb_api_t apiHandle) + +For binding with a version >= 3, same as 'GetAFBRootDirPathUsingFd' function, +but use pointer to the AFB API as parameter instead of +binder root directory file descriptor. + +* `apiHandle` : pointer to the AFB API. + +Returns a string representing the path to binder root directory. + +## char* GetBindingDirPath() + +For binding with a version <= 2, same as 'GetAFBRootDirPath' function, +but the pointer to the AFB API is not needed. +Kept for compatibility issues. + +## char* GetBindingDirPath(afb_api_t api) + +For binding with a version >= 3, same as 'GetAFBRootDirPath' function. +Deprecated, please use 'GetAFBRootDirPath' function. +Kept for compatibility issues. ## const char *getEnvDirList(const char *prefix, const char *suffix) diff --git a/filescan-utils.c b/filescan-utils.c index 6c6cf84..236e192 100644 --- a/filescan-utils.c +++ b/filescan-utils.c @@ -151,7 +151,7 @@ const char* GetBinderName() return binderName; } -char *GetBindingDirPath_(int fd) +char *GetAFBRootDirPathUsingFd(int fd) { // A file description should not be greater than 999.999.999 char fd_link[CONTROL_MAXPATH_LEN]; @@ -170,6 +170,15 @@ char *GetBindingDirPath_(int fd) return strndup(retdir, sizeof(retdir)); } +char *GetAFBRootDirPath(afb_api_t apiHandle) +{ + int fd; + + fd = afb_api_rootdir_get_fd(apiHandle); + + return GetAFBRootDirPathUsingFd(fd); +} + diff --git a/filescan-utils.h b/filescan-utils.h index d6c645f..f96d903 100644 --- a/filescan-utils.h +++ b/filescan-utils.h @@ -80,27 +80,47 @@ extern const char *GetBinderName(); extern json_object* ScanForConfig (const char* searchPath, CtlScanDirModeT mode, const char *prefix, const char *extension); /** - * @brief Get the Binding root directory file descriptor object + * @brief Get the Binder root directory path using root directory fd. * - * @param dynapi : Could be NULL if you don't use dynamic api + * @param fd : Binder root directory file descriptor. * - * @return char* string representing the path to binding root directory. + * @return char* string representing the path to the binder root directory. */ -extern char *GetBindingDirPath_(int fd); +extern char *GetAFBRootDirPathUsingFd(int fd); + +/** + * @brief Get the Binder root directory path using AFB API. + * + * @param apiHandle : pointer to the AFB API. + * + * @return char* string representing the path to binder root directory. + */ +extern char *GetAFBRootDirPath(afb_api_t apiHandle); + +/** + * For compatibility issues : + * 'GetBindingDirPath_' is linked to 'GetAFBRootDirPathUsingFd' + */ +#define GetBindingDirPath_ GetAFBRootDirPathUsingFd + +/** + * For compatibility issues : + * 'GetBindingDirPath' is linked to 'GetAFBRootDirPathUsingFd' +*/ #if(AFB_BINDING_VERSION == 2) -static inline char *GetBindingDirPath_v2() +static inline char *GetAFBRootDirPath_v2() { - return GetBindingDirPath_(afb_daemon_rootdir_get_fd_v2()); + return GetAFBRootDirPathUsingFd(afb_daemon_rootdir_get_fd()); } -__attribute__((alias("GetBindingDirPath_v2"))) +__attribute__((alias("GetAFBRootDirPath_v2"))) static char *GetBindingDirPath(); #else -static char *GetBindingDirPath_v3(struct afb_api_x3* api) +static char *GetAFBRootDirPath_v3(afb_api_t api) { - return GetBindingDirPath_(afb_api_x3_rootdir_get_fd(api)); + return GetAFBRootDirPathUsingFd(afb_api_rootdir_get_fd(api)); } -__attribute__((alias("GetBindingDirPath_v3"))) -static char *GetBindingDirPath(struct afb_api_x3* api); +__attribute__((alias("GetAFBRootDirPath_v3"))) +static char *GetBindingDirPath(afb_api_t api); #endif /** |