]> git.ozlabs.org Git - petitboot/blobdiff - lib/pb-config/storage-test.c
discover: Handle incoming configuration messages
[petitboot] / lib / pb-config / storage-test.c
index 3ce58ef0a03c30b39ea44ac9b0abbfa79a58eea1..48cb238bd383bcaabb1efc2e571d3033d1c749d4 100644 (file)
@@ -4,7 +4,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#include <array-size/array-size.h>
+#include <util/util.h>
 
 #include "pb-config.h"
 #include "storage.h"
 
 #include "pb-config.h"
 #include "storage.h"
@@ -40,22 +40,34 @@ struct test_storage {
        struct config_storage   storage;
        struct param            *params;
        int                     n_params;
        struct config_storage   storage;
        struct param            *params;
        int                     n_params;
+       struct config           *config;
 };
 
 };
 
-static int load(struct config_storage *st __attribute__((unused)),
-               struct config *config)
+#define to_test_storage(st) container_of(st, struct test_storage, storage)
+
+static int load(struct config_storage *st, struct config *config)
+{
+       struct test_storage *ts = to_test_storage(st);
+       memcpy(config, ts->config, sizeof(test_config));
+       return 0;
+}
+
+static int save(struct config_storage *st, struct config *newconfig)
 {
 {
-       memcpy(config, &test_config, sizeof(test_config));
+       struct test_storage *ts = to_test_storage(st);
+       ts->config = newconfig;
        return 0;
 }
 
 static struct test_storage st = {
        .storage = {
                .load  = load,
        return 0;
 }
 
 static struct test_storage st = {
        .storage = {
                .load  = load,
+               .save = save,
        },
 };
 
 struct config_storage *create_test_storage(void *ctx __attribute__((unused)))
 {
        },
 };
 
 struct config_storage *create_test_storage(void *ctx __attribute__((unused)))
 {
+       st.config = &test_config;
        return &st.storage;
 }
        return &st.storage;
 }