]> git.ozlabs.org Git - petitboot/commitdiff
types: Add is_default to struct boot_option
authorJeremy Kerr <jk@ozlabs.org>
Fri, 17 May 2013 03:41:04 +0000 (11:41 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 24 Jun 2013 04:52:49 +0000 (12:52 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/pb-protocol/pb-protocol.c
lib/types/types.h

index 2792bf832c7ea2866a6accbe3b82b191eaa406f4..d3174af7994cc8937fd1ca1df9d92948f0ba5238 100644 (file)
@@ -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:
index 90b23c37a77446d0cda4b531869c6dee31eed343..5be2cb697597a3c12c177aea26644b67bc9e3dec 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _TYPES_H
 #define _TYPES_H
 
+#include <stdbool.h>
 #include <list/list.h>
 
 struct device {
@@ -24,6 +25,7 @@ struct boot_option {
        char            *boot_image_file;
        char            *initrd_file;
        char            *boot_args;
+       bool            is_default;
 
        struct list_item        list;