From patchwork Fri Jun 23 05:51:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 779798 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wv6yW6LfCz9ryQ for ; Fri, 23 Jun 2017 15:51:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="lpz6TjW2"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wv6yW4YWfzDqkF for ; Fri, 23 Jun 2017 15:51:31 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="lpz6TjW2"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mendozajonas.com (mendozajonas.com [188.166.185.233]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wv6yR1HvPzDqjF for ; Fri, 23 Jun 2017 15:51:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="lpz6TjW2"; dkim-atps=neutral Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: sam@mendozajonas.com) by mendozajonas.com (Postfix) with ESMTPSA id A116C143FC8; Fri, 23 Jun 2017 13:51:23 +0800 (SGT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com; s=mail; t=1498197084; bh=Me/hH6/E4kT2VLp/uzeQDE+6gk5Cb79uUPgVP/eoMPA=; h=From:To:Cc:Subject:Date:From; b=lpz6TjW2Uq5y2/UcoenntKcLjKPQf1ciadxgwZc2gAh5B1mP6xVFL/NTaDb2VatIn zrtr4Zy8VJRc0hy5GN2VHbyAFDSRA3758VnH0qQojYzGCot3smshuM/w8L+FBZ0DjO nviSZDSBS5larnevJpEGC8MEVUgc+LEUdQ/Tg9QI= From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH 1/4] discover/sysinfo: Add system_info_reinit() Date: Fri, 23 Jun 2017 15:51:12 +1000 Message-Id: <20170623055115.23963-1-sam@mendozajonas.com> X-Mailer: git-send-email 2.13.1 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" 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 --- discover/device-handler.c | 2 ++ discover/sysinfo.c | 18 ++++++++++++++++++ discover/sysinfo.h | 1 + 3 files changed, 21 insertions(+) diff --git a/discover/device-handler.c b/discover/device-handler.c index ec1eee3..a0c21b7 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -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); diff --git a/discover/sysinfo.c b/discover/sysinfo.c index 0ac29c1..e8e6d52 100644 --- a/discover/sysinfo.c +++ b/discover/sysinfo.c @@ -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; +} diff --git a/discover/sysinfo.h b/discover/sysinfo.h index 19ed950..c570951 100644 --- a/discover/sysinfo.h +++ b/discover/sysinfo.h @@ -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 */