Re: [PATCH BlueZ 6/9] mesh: Define storage format specific read/write routines

Michał Lowas-Rzechonek
2019-07-10T07:52:51Z

On 07/09, Inga Stotland wrote:
> This adds the following generic APIs to mesh-config.h
> void *mesh_config_create_config(void);
> void mesh_config_release_config(void *config);
> void *mesh_config_get_config(const char *dir);
> void *mesh_config_get_config_backup(const char *dir);
> bool mesh_config_restore_backup(const char *dir);
> bool mesh_config_save_config(const char *dir, void *cfg);
>
> The implementation of these API routines depends on the
> underlying storage directory structure and can be specific to
> a chosen configuration file format.

I don't like the assumption that each node is stored in a separate file,
and there needs to be a backup file.

One of the storage formats I had in mind is a single transactional
database (some flavor of berkeley db, or maybe even sqlite) that would
hold all the nodes.

With this in mind, how about:

union mesh_config *mesh_config_create_config(const uint8_t uuid[16]);
bool mesh_config_save(union mesh_config *cfg);

and to iterate over saved nodes:
typedef struct mesh_node *(*mesh_node_load_cb)(union mesh_config *cfg,
const uint8_t uuid[16],
void *user_data);

void mesh_config_load_nodes(mesh_node_load_cb cb, void *user_data);

and move file/directory handling from storage.c to mesh-config-json.c?

regards
--
Michał Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>
Silvair http://silvair.com
Jasnogórska 44, 31-358 Krakow, POLAND