- if (directory) {
- if (closedir(directory)) {
- /*
- * We don't want to override the error since there is
- * nothing could do.
- */
- perror("Failed to close plug-in directory");
- }
+ return ret;
+}
+
+static
+enum bt_plugin_status bt_plugin_create_append_all_from_dir(
+ struct bt_plugin_set *plugin_set, const char *path,
+ bt_bool recurse)
+{
+ int nftw_flags = FTW_PHYS;
+ enum bt_plugin_status ret = BT_PLUGIN_STATUS_OK;
+
+ BT_ASSERT(plugin_set);
+ BT_ASSERT(path);
+ BT_ASSERT(strlen(path) < PATH_MAX);
+ pthread_mutex_lock(&append_all_from_dir_info.lock);
+ append_all_from_dir_info.plugin_set = plugin_set;
+ append_all_from_dir_info.recurse = recurse;
+ ret = nftw(path, nftw_append_all_from_dir,
+ APPEND_ALL_FROM_DIR_NFDOPEN_MAX, nftw_flags);
+ pthread_mutex_unlock(&append_all_from_dir_info.lock);
+ if (ret != 0) {
+ BT_LOGW_ERRNO("Cannot open directory", ": path=\"%s\"", path);
+ ret = BT_PLUGIN_STATUS_ERROR;