discover/sysinfo: Add system_info_reinit()
[petitboot] / discover / sysinfo.c
index 619c0c588ff61a42326dddfcc5885e113870a80e..e8e6d52bce971452ebff7f6d714c2005ccd58715 100644 (file)
@@ -23,6 +23,7 @@ void system_info_set_interface_address(unsigned int hwaddr_size,
 {
        struct interface_info *if_info;
        unsigned int i;
+       char mac[20];
 
        for (i = 0; i < sysinfo->n_interfaces; i++) {
                if_info = sysinfo->interfaces[i];
@@ -43,7 +44,8 @@ void system_info_set_interface_address(unsigned int hwaddr_size,
                }
        }
 
-       pb_log("Couldn't find interface matching %s\n", "foo");
+       mac_str(hwaddr, hwaddr_size, mac, sizeof(mac));
+       pb_log("Couldn't find interface matching %s\n", mac);
 }
 
 void system_info_register_interface(unsigned int hwaddr_size, uint8_t *hwaddr,
@@ -137,3 +139,21 @@ void system_info_init(struct discover_server *s)
        sysinfo = talloc_zero(server, struct system_info);
        platform_get_sysinfo(sysinfo);
 }
+
+/* Only reset device information. Platform information is static */
+void system_info_reinit(void)
+{
+       unsigned int i;
+
+       for (i = 0; i < sysinfo->n_blockdevs; i++)
+               talloc_free(sysinfo->blockdevs[i]);
+       talloc_free(sysinfo->blockdevs);
+       sysinfo->blockdevs = NULL;
+       sysinfo->n_blockdevs = 0;
+
+       for (i = 0; i < sysinfo->n_interfaces; i++)
+               talloc_free(sysinfo->interfaces[i]);
+       talloc_free(sysinfo->interfaces);
+       sysinfo->interfaces = NULL;
+       sysinfo->n_interfaces = 0;
+}