diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-17 11:41:04 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-06-24 12:52:49 +0800 |
commit | 936e57208c8e651be0f3dee6cfc635d719410100 (patch) | |
tree | 508128a49bfb9f10ef816fed2a9d808842fefc64 /lib/pb-protocol | |
parent | 4dc604b496f388e6896d46bb02d109103c316e4f (diff) | |
download | talos-petitboot-936e57208c8e651be0f3dee6cfc635d719410100.tar.gz talos-petitboot-936e57208c8e651be0f3dee6cfc635d719410100.zip |
types: Add is_default to struct boot_option
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'lib/pb-protocol')
-rw-r--r-- | lib/pb-protocol/pb-protocol.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index 2792bf8..d3174af 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -2,6 +2,7 @@ #include <assert.h> #include <errno.h> #include <string.h> +#include <stdbool.h> #include <stdint.h> #include <asm/byteorder.h> @@ -177,7 +178,8 @@ int pb_protocol_boot_option_len(const struct boot_option *opt) 4 + optional_strlen(opt->icon_file) + 4 + optional_strlen(opt->boot_image_file) + 4 + optional_strlen(opt->initrd_file) + - 4 + optional_strlen(opt->boot_args); + 4 + optional_strlen(opt->boot_args) + + sizeof(opt->is_default); } int pb_protocol_boot_len(const struct boot_command *boot) @@ -226,6 +228,9 @@ int pb_protocol_serialise_boot_option(const struct boot_option *opt, pos += pb_protocol_serialise_string(pos, opt->initrd_file); pos += pb_protocol_serialise_string(pos, opt->boot_args); + *(bool *)pos = opt->is_default; + pos += sizeof(bool); + assert(pos <= buf + buf_len); (void)buf_len; @@ -421,6 +426,10 @@ int pb_protocol_deserialise_boot_option(struct boot_option *opt, if (read_string(opt, &pos, &len, &opt->boot_args)) goto out; + if (len < sizeof(bool)) + goto out; + opt->is_default = *(bool *)(pos); + rc = 0; out: |