diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-11-15 15:13:41 +1100 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-11-22 10:45:54 +0800 |
commit | 263968fb67cdaa58e1ff8d9a35a72921ffbac7ef (patch) | |
tree | a2b3bdd5c6fb8d38723b690efd0d40dc7c5072e2 | |
parent | 08e967ee301b502b2114e3855210a0b2600d095c (diff) | |
download | talos-petitboot-263968fb67cdaa58e1ff8d9a35a72921ffbac7ef.tar.gz talos-petitboot-263968fb67cdaa58e1ff8d9a35a72921ffbac7ef.zip |
protocol: Add block device information to system info
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | lib/pb-protocol/pb-protocol.c | 42 | ||||
-rw-r--r-- | lib/types/types.h | 8 |
2 files changed, 49 insertions, 1 deletions
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index 5a056ee..091fab7 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -223,7 +223,7 @@ int pb_protocol_system_info_len(const struct system_info *sysinfo) len = 4 + optional_strlen(sysinfo->type) + 4 + optional_strlen(sysinfo->identifier) + - 4; + 4 + 4; for (i = 0; i < sysinfo->n_interfaces; i++) { struct interface_info *if_info = sysinfo->interfaces[i]; @@ -231,6 +231,13 @@ int pb_protocol_system_info_len(const struct system_info *sysinfo) 4 + optional_strlen(if_info->name); } + for (i = 0; i < sysinfo->n_blockdevs; i++) { + struct blockdev_info *bd_info = sysinfo->blockdevs[i]; + len += 4 + optional_strlen(bd_info->name) + + 4 + optional_strlen(bd_info->uuid) + + 4 + optional_strlen(bd_info->mountpoint); + } + return len; } @@ -379,6 +386,17 @@ int pb_protocol_serialise_system_info(const struct system_info *sysinfo, pos += pb_protocol_serialise_string(pos, if_info->name); } + *(uint32_t *)pos = __cpu_to_be32(sysinfo->n_blockdevs); + pos += sizeof(uint32_t); + + for (i = 0; i < sysinfo->n_blockdevs; i++) { + struct blockdev_info *bd_info = sysinfo->blockdevs[i]; + + pos += pb_protocol_serialise_string(pos, bd_info->name); + pos += pb_protocol_serialise_string(pos, bd_info->uuid); + pos += pb_protocol_serialise_string(pos, bd_info->mountpoint); + } + assert(pos <= buf + buf_len); (void)buf_len; @@ -750,6 +768,28 @@ int pb_protocol_deserialise_system_info(struct system_info *sysinfo, sysinfo->interfaces[i] = if_info; } + /* number of interfaces */ + if (read_u32(&pos, &len, &sysinfo->n_blockdevs)) + goto out; + + sysinfo->blockdevs = talloc_array(sysinfo, struct blockdev_info *, + sysinfo->n_blockdevs); + + for (i = 0; i < sysinfo->n_blockdevs; i++) { + struct blockdev_info *bd_info = talloc(sysinfo, + struct blockdev_info); + + if (read_string(bd_info, &pos, &len, &bd_info->name)) + goto out; + + if (read_string(bd_info, &pos, &len, &bd_info->uuid)) + goto out; + + if (read_string(bd_info, &pos, &len, &bd_info->mountpoint)) + goto out; + + sysinfo->blockdevs[i] = bd_info; + } rc = 0; out: diff --git a/lib/types/types.h b/lib/types/types.h index d73f161..d2a2918 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -66,11 +66,19 @@ struct interface_info { char *name; }; +struct blockdev_info { + char *name; + char *uuid; + char *mountpoint; +}; + struct system_info { char *type; char *identifier; struct interface_info **interfaces; unsigned int n_interfaces; + struct blockdev_info **blockdevs; + unsigned int n_blockdevs; }; #define HWADDR_SIZE 6 |