summaryrefslogtreecommitdiffstats
path: root/lib/pb-config/storage-test.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-05-29 17:24:42 +1000
committerJeremy Kerr <jk@ozlabs.org>2013-06-24 13:07:22 +0800
commit32fe8024f5af5cd8de23c638ddad8ada67a46cd5 (patch)
treecd64dcd7c093f7d10fe9325e5b1c5479aadfe01a /lib/pb-config/storage-test.c
parent0f9597ab801ad4591e943bd7efcb8f1549997fdd (diff)
downloadtalos-petitboot-32fe8024f5af5cd8de23c638ddad8ada67a46cd5.tar.gz
talos-petitboot-32fe8024f5af5cd8de23c638ddad8ada67a46cd5.zip
lib: Add pb-config module
Add a library for (name, value) configuration. Different storage backends are allowed (although currently hardcoded to powerpc nvram), and config is read-only at present. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'lib/pb-config/storage-test.c')
-rw-r--r--lib/pb-config/storage-test.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/pb-config/storage-test.c b/lib/pb-config/storage-test.c
new file mode 100644
index 0000000..ba4e952
--- /dev/null
+++ b/lib/pb-config/storage-test.c
@@ -0,0 +1,56 @@
+
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "pb-config.h"
+#include "storage.h"
+
+struct network_config net1 = {
+ .hwaddr = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 },
+ .method = CONFIG_METHOD_DHCP,
+};
+
+struct network_config net2 = {
+ .hwaddr = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x56 },
+ .method = CONFIG_METHOD_STATIC,
+ .static_config = {
+ .address = "192.168.0.2/24",
+ .gateway = "192.168.0.1",
+ },
+};
+
+struct network_config *network_configs[] = { &net1, &net2 };
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+struct config test_config = {
+ .autoboot_enabled = true,
+ .network_configs = network_configs,
+ .n_network_configs = ARRAY_SIZE(network_configs),
+};
+
+struct test_storage {
+ struct config_storage storage;
+ struct param *params;
+ int n_params;
+};
+
+static int load(struct config_storage *st __attribute__((unused)),
+ struct config *config)
+{
+ memcpy(config, &test_config, sizeof(test_config));
+ return 0;
+}
+
+static struct test_storage st = {
+ .storage = {
+ .load = load,
+ },
+};
+
+struct config_storage *create_test_storage(void *ctx __attribute__((unused)))
+{
+ return &st.storage;
+}
OpenPOWER on IntegriCloud