summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-04-30 10:17:20 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-07-21 17:20:08 +0800
commite19c5fe83174de749843bb8486a0d12c25adcb82 (patch)
treec3602dff45153c6d021c0e3920574179cb63f52b /lib
parent0adfe11dc0738321cdd529f30773899cc8f79855 (diff)
downloadtalos-petitboot-e19c5fe83174de749843bb8486a0d12c25adcb82.tar.gz
talos-petitboot-e19c5fe83174de749843bb8486a0d12c25adcb82.zip
config: Add boot_device member to config
We'd like to specify a way to only boot from a specific block device; this adds a field to the configuration to hold the value. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/pb-config/pb-config.c5
-rw-r--r--lib/pb-protocol/pb-protocol.c13
-rw-r--r--lib/types/types.h1
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c
index ed84fec..2adc7b2 100644
--- a/lib/pb-config/pb-config.c
+++ b/lib/pb-config/pb-config.c
@@ -68,5 +68,10 @@ struct config *config_copy(void *ctx, const struct config *src)
dest->boot_priorities[i].type = src->boot_priorities[i].type;
}
+ if (src->boot_device && strlen(src->boot_device))
+ dest->boot_device = talloc_strdup(dest, src->boot_device);
+ else
+ dest->boot_device = NULL;
+
return dest;
}
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index cf27b8e..4a5c75a 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -472,6 +472,8 @@ int pb_protocol_serialise_config(const struct config *config,
pos += 4;
}
+ pos += pb_protocol_serialise_string(pos, config->boot_device);
+
assert(pos <= buf + buf_len);
(void)buf_len;
@@ -846,6 +848,7 @@ int pb_protocol_deserialise_config(struct config *config,
unsigned int len, i, tmp;
const char *pos;
int rc = -1;
+ char *str;
len = message->payload_len;
pos = message->payload;
@@ -878,10 +881,9 @@ int pb_protocol_deserialise_config(struct config *config,
config->network.n_dns_servers);
for (i = 0; i < config->network.n_dns_servers; i++) {
- char *tmp;
- if (read_string(config->network.dns_servers, &pos, &len, &tmp))
+ if (read_string(config->network.dns_servers, &pos, &len, &str))
goto out;
- config->network.dns_servers[i] = tmp;
+ config->network.dns_servers[i] = str;
}
if (read_u32(&pos, &len, &config->n_boot_priorities))
@@ -898,6 +900,11 @@ int pb_protocol_deserialise_config(struct config *config,
config->boot_priorities[i].type = tmp;
}
+ if (read_string(config, &pos, &len, &str))
+ goto out;
+
+ config->boot_device = str;
+
rc = 0;
out:
diff --git a/lib/types/types.h b/lib/types/types.h
index 1293193..762530a 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -124,6 +124,7 @@ struct config {
struct network_config network;
struct boot_priority *boot_priorities;
unsigned int n_boot_priorities;
+ char *boot_device;
};
#endif /* _TYPES_H */
OpenPOWER on IntegriCloud