X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Fpb-protocol%2Fpb-protocol.c;h=c6d8f635ad6a495d5f9bd15b7c6b94e851d375b1;hp=4e0af873b710ad8d72707c9fa60190076197e865;hb=b838cf777ed3d21b166f8daddd4b11fc75e07307;hpb=69c459db80abece18b5557d9b8a8098a88329c28 diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index 4e0af87..c6d8f63 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -338,10 +338,9 @@ struct pb_protocol_message *pb_protocol_read_message(void *ctx, int fd) } -struct device *pb_protocol_deserialise_device(void *ctx, +int pb_protocol_deserialise_device(struct device *dev, const struct pb_protocol_message *message) { - struct device *dev; const char *pos; int i, n_options; unsigned int len; @@ -349,8 +348,6 @@ struct device *pb_protocol_deserialise_device(void *ctx, len = message->payload_len; pos = message->payload; - dev = talloc(ctx, struct device); - if (read_string(dev, &pos, &len, &dev->id)) goto out_err; @@ -398,9 +395,35 @@ struct device *pb_protocol_deserialise_device(void *ctx, list_add(&dev->boot_options, &opt->list); } - return dev; + return 0; out_err: - talloc_free(dev); - return NULL; + return -1; +} + +int pb_protocol_deserialise_boot_command(struct boot_command *cmd, + const struct pb_protocol_message *message) +{ + const char *pos; + unsigned int len; + + len = message->payload_len; + pos = message->payload; + + if (read_string(cmd, &pos, &len, &cmd->option_id)) + goto out_err; + + if (read_string(cmd, &pos, &len, &cmd->boot_image_file)) + goto out_err; + + if (read_string(cmd, &pos, &len, &cmd->initrd_file)) + goto out_err; + + if (read_string(cmd, &pos, &len, &cmd->boot_args)) + goto out_err; + + return 0; + +out_err: + return -1; }