Commit 74a806bf authored by Philip Carns's avatar Philip Carns
Browse files

json sub-object for pmem backend

parent ce62da3f
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "bake-server.h" #include "bake-server.h"
#include "bake-provider.h" #include "bake-provider.h"
#include "bake-backend.h" #include "bake-backend.h"
#include "bake-macros.h"
/* definition of BAKE root data structure (just a uuid for now) */ /* definition of BAKE root data structure (just a uuid for now) */
typedef struct { typedef struct {
...@@ -89,6 +90,15 @@ static int bake_pmem_backend_initialize(bake_provider_t provider, ...@@ -89,6 +90,15 @@ static int bake_pmem_backend_initialize(bake_provider_t provider,
new_context->filename = strdup(tmp); new_context->filename = strdup(tmp);
ptrdiff_t d = tmp - path; ptrdiff_t d = tmp - path;
new_context->root = strndup(path, d); new_context->root = strndup(path, d);
struct json_object* pmem_backend_json = NULL;
struct json_object* target_array = NULL;
CONFIG_HAS_OR_CREATE_OBJECT(provider->json_cfg, "pmem_backend",
"pmem_backend", pmem_backend_json);
CONFIG_HAS_OR_CREATE_ARRAY(pmem_backend_json, "targets",
"pmem_backend.targets", target_array);
/* TODO: populate tuning parameters specific to this backend */
new_context->pmem_pool = pmemobj_open(path, NULL); new_context->pmem_pool = pmemobj_open(path, NULL);
if (!(new_context->pmem_pool)) { if (!(new_context->pmem_pool)) {
...@@ -115,6 +125,11 @@ static int bake_pmem_backend_initialize(bake_provider_t provider, ...@@ -115,6 +125,11 @@ static int bake_pmem_backend_initialize(bake_provider_t provider,
return BAKE_ERR_UNKNOWN_TARGET; return BAKE_ERR_UNKNOWN_TARGET;
} }
/* target successfully added; inject it into the json in array of
* targets for this backend
*/
json_object_array_add(target_array, json_object_new_string(path));
*target = tid; *target = tid;
*context = new_context; *context = new_context;
return 0; return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment