]> git.ozlabs.org Git - petitboot/commitdiff
discover/sysinfo: Add system_info_reinit()
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 23 Mar 2017 06:41:28 +0000 (17:41 +1100)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 11 Jul 2017 04:32:17 +0000 (14:32 +1000)
Currently over reinit events the system info is not affected. However
network and block device information can change over reinit, so clear
this information.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/device-handler.c
discover/sysinfo.c
discover/sysinfo.h

index ec1eee344802a24e3c9f4febdd69d1c6f6fdc6c4..a0c21b71b906e5eea8c3d986a6bb9c4d3f9fc921 100644 (file)
@@ -1407,6 +1407,8 @@ static void device_handler_reinit_sources(struct device_handler *handler)
                return;
        }
 
+       system_info_reinit();
+
        udev_reinit(handler->udev);
 
        network_shutdown(handler->network);
index 0ac29c1ead35adddd7f9a52acbe6c8fbd8f811c5..e8e6d52bce971452ebff7f6d714c2005ccd58715 100644 (file)
@@ -139,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;
+}
index 19ed95077d247917eceff5875e4d1b751361e74f..c570951db312e3c3385d5d66ce91ff7c9ff165c3 100644 (file)
@@ -15,6 +15,7 @@ void system_info_register_blockdev(const char *name, const char *uuid,
                const char *mountpoint);
 
 void system_info_init(struct discover_server *server);
+void system_info_reinit(void);
 
 #endif /* SYSINFO_H */