From patchwork Wed Nov 11 12:03:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1398194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::239; helo=mail-lj1-x239.google.com; envelope-from=swupdate+bncbcxploxj6ikrbk5gv76qkgqe6oqyw7a@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=GZt9rGRK; dkim-atps=neutral Received: from mail-lj1-x239.google.com (mail-lj1-x239.google.com [IPv6:2a00:1450:4864:20::239]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CWNgN20Zdz9sSf for ; Wed, 11 Nov 2020 23:03:59 +1100 (AEDT) Received: by mail-lj1-x239.google.com with SMTP id r19sf735554ljj.9 for ; Wed, 11 Nov 2020 04:03:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605096235; cv=pass; d=google.com; s=arc-20160816; b=BSR0DeqH/px7Sr8xVynMsVzneoJeiLThUsibHeL+ODqjHiWMKUgMrAXRGBmElE30jw i3p3IfzP8RPVrOTwH/bzpxmS2n1TxnDMSQ5WC34zmth1PH8u625rz+OH4Ykk02u2jw24 qHwN0fmTf1FKhzuPrCiBzdpBTRN10EqKYiyBHEgjSViweoap9Ins9yolUICE/yScE0UT STbmzoKW61RTAFybcWU5+1eeyCPwDcWTpTAZRHn+c9G7fSIdba6JbrBzQiAtCroBEXw0 3cdfs8PekRoDwkaTCf6/3lL6mQYpH7/fwpmaUIru3dO1fyMV1xkN0cs9Lq4Y8FyuX4J6 u90w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=HZjrbgTN2TVddIRowmCDKm5wR3nESqO5319a6WYUSvs=; b=boKGo9w5qxAG3Szum3gz5VcnuvT0H1GW2bYL7yQj+rxKyJ8tQsJpfIbZd6ryiFEmpe HKDUW+D5saVR8rGJ6b/XTKw9fPgfOO52KW/fQwXOjEzi5LVTmFP5/NZdbnQeEMbJc2bZ I45po3Sr5izn8WGkMIzIbVvvZOQbLDIISKs1o9dWCSZzv5QFhePj00HCahcvvrdq0Z8e zEjgROK12wiN0F2mNMt6p4i+IaI7rkdHamBYSUuGS28oItmdkvdQmIRoU/SqdaasBnny hdcU3rOKjLtW7cESFbvcERt+BEbpiQDawd59M1lYXisVKvjOTe0HVVjJhfHC9Xnsg14r PWBQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=HZjrbgTN2TVddIRowmCDKm5wR3nESqO5319a6WYUSvs=; b=GZt9rGRKJ34naUX22rWxFzJJJNj2vJid/C1alhNhdg5HGJJSvEBT7XT0CLHG8m4UA2 DfPedscRiTDQmYhjPDf5YsscHcWbhk9Jk34H8RHCbSzS4T5vrWYaXFiw7z/zGr43x9KG kmNFOCbyQa+gIf61m1ldcT3D0okNJilSHOtDyop+fI91M7GgnRQr5sHawe0hrj1/jRGe eDaJn8icdlg4FV829eBQwSPG5I4VCphBdZygDfrJeJq3K4XhO/JbOoN57/psWn5jBweW bYzp2FT46W3Nem6ylUWMxiQQnz8GtSKqzlavuJucpJ8+YWpbEobirSMzH7809YgZUqqp VZtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=HZjrbgTN2TVddIRowmCDKm5wR3nESqO5319a6WYUSvs=; b=t54VvS0WhS3U4ww8ZorKR8iwALZUyTZ3T65clu8smIgkSEKwQ2M+OBJYzA5RPi0YFo ZC07a83X7xgSHGntqWRFyFAzQ4PbN0+eUXr4MuF1sANQb+ZM0b4OoALVIA1u1KrFWni3 bxUSyo+xjx3dDERzTcrmcWeujT5D9ceu7uDwYhvUeeqBNTpDcmOKYGL/3+NrQkXSezZw GsCEwHyOrRK/uFLA3WNGaFvSoxjrz7RheY1nMphrWzt3NRJHcm+UTLKuit6DxDCv5HFY TE/morUyF7LdhPasMLh+LB5RXhmaKEjBnuaUJ2vqcrbgW1PSLlaJpF1El77tZVRcM14I XWMQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533WEIUronG24c9eR7eTm4KGq7JBXq2ezEtkPaUec8nQ83RZTzAJ VBw8Cirqnx0W0HW9MX6c04c= X-Google-Smtp-Source: ABdhPJzolJ0+mcrxYXIN2KSMsS9aw2z+XB1tw20B8qUJiDmiWt4Tz4JlPlVFLmYnuwBJvQfkz2lJzw== X-Received: by 2002:ac2:5141:: with SMTP id q1mr5233823lfd.157.1605096235691; Wed, 11 Nov 2020 04:03:55 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:480e:: with SMTP id v14ls2490829lfa.2.gmail; Wed, 11 Nov 2020 04:03:54 -0800 (PST) X-Received: by 2002:a19:c791:: with SMTP id x139mr4360695lff.513.1605096234617; Wed, 11 Nov 2020 04:03:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605096234; cv=none; d=google.com; s=arc-20160816; b=S49eHP9CE5lkRO2s/8x5fWax6kcNhpcLhPK86MpLPH34ArDN2Zha1MzBiX9/CTxuy3 1XmfZDdKF9gOJHCX6xZ7g194sRfzpMWCTXy9ikZyKjYMvpr3LuXDYmKWz7NJKbKGm+ZR KPyzcvQWVhvTNPM0TBq3hZAiAgz+r33HZ13mnSkRilgCIL2Ctxrh7lGjW+xs7csYqVFn iaIVGIuE2lXKVmz8aTcWMshwIL+tvIFM8YjAaf3jbeUAUohQTDgK1HjaujOKwAsE/MWa oNg0xk57CMoDIVQvujv1nn9UD5RvZ8pXt0x+C5QmnjA7Sk/SyexyrdSjL75IqQfsB3ga IqkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=TnMlWY/Gcyv+P7znerfpvQQZ5B83yGeFf9t7Cj3CyXA=; b=a92A2yX888YqNSFhshgc/DLYM4lDLoiLKuRjE5fnGopsN0khD9bqhWFPn0LTsYUdKE k/IZcJFg3TZAaWLkjhO8wkgQ6a1XXlP+hkqun4fYq2cjPGv3k1xlZtkuBqq68HWPAdTK OshOunM3gSTks7nM7kOXgPv+pdniXvlOXXC/fnO9DnB4jTizGgQ6JyAMtoYn3ovyWBEv sCOsul7wnvyZ5+pb+Zq0DtgxrjVEiMGaeaQYDzvb2OSktmc0/vAKazSuZ2kbclH8rwQ0 S5HODj3pH/R//QXe682rJ7WwAoP+AVRPBp2XZl6/VMB8ALSswp2aG6vDLupXEvfoshZr bSHA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id v2si23582ljd.5.2020.11.11.04.03.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Nov 2020 04:03:54 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CWNgG167zz1qs3Y; Wed, 11 Nov 2020 13:03:54 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CWNgG0rPTz1qy6d; Wed, 11 Nov 2020 13:03:54 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id ausWfYL2XS87; Wed, 11 Nov 2020 13:03:53 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Wed, 11 Nov 2020 13:03:53 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id ECA3845427AA; Wed, 11 Nov 2020 13:03:51 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id veVl1plbY1Qf; Wed, 11 Nov 2020 13:03:48 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 8EA8B45427AD; Wed, 11 Nov 2020 13:03:33 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 6/6] IPC: let decide selections at runtime Date: Wed, 11 Nov 2020 13:03:27 +0100 Message-Id: <20201111120327.607444-7-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201111120327.607444-1-sbabic@denx.de> References: <20201111120327.607444-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , It is useful to change the selection type at runtime if more as one section inside sw-description can be installed. This activates a selection sent via IPC to be used for the next update. The default configuration is cached and will be active at next update if the request does not contain any valid selection. Signed-off-by: Stefano Babic --- core/stream_interface.c | 19 ++++++++++++++++++- core/swupdate.c | 8 +++++++- include/swupdate.h | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/core/stream_interface.c b/core/stream_interface.c index e7298d9..89ae52e 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -476,6 +476,7 @@ void *network_initializer(void *data) { int ret; struct swupdate_cfg *software = data; + struct swupdate_request *req; /* No installation in progress */ memset(&inst, 0, sizeof(inst)); @@ -497,14 +498,30 @@ void *network_initializer(void *data) pthread_mutex_unlock(&stream_mutex); notify(START, RECOVERY_NO_ERROR, INFOLEVEL, "Software Update started !"); + req = &inst.req; + /* * Check if the dry run flag is overwritten */ - if (inst.req.dry_run) + if (req->dry_run) software->globals.dry_run = 1; else software->globals.dry_run = 0; + /* + * Find the selection to be installed + */ + if ((strnlen(req->software_set, sizeof(req->software_set)) > 0) && + (strnlen(req->running_mode, sizeof(req->running_mode)) > 0)) { + strlcpy(software->software_set, req->software_set, sizeof(software->software_set) - 1); + strlcpy(software->running_mode, req->running_mode, sizeof(software->running_mode) - 1); + } else { + strlcpy(software->software_set, software->globals.default_software_set, + sizeof(software->software_set) - 1); + strlcpy(software->running_mode, software->globals.default_running_mode, + sizeof(software->running_mode) - 1); + } + /* * Check if the stream should be saved */ diff --git a/core/swupdate.c b/core/swupdate.c index 5e5fbaf..ba5d129 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -414,8 +414,14 @@ static int parse_image_selector(const char *selector, struct swupdate_cfg *sw) *pos = '\0'; + /* + * the runtime copy in swcfg can be overloaded by IPC, + * so maintain a copy to restore it after an update + */ + strlcpy(sw->globals.default_software_set, selector, sizeof(sw->globals.default_software_set)); strlcpy(sw->software_set, selector, sizeof(sw->software_set)); /* pos + 1 will either be NULL or valid text */ + strlcpy(sw->globals.default_running_mode, pos + 1, sizeof(sw->globals.default_running_mode)); strlcpy(sw->running_mode, pos + 1, sizeof(sw->running_mode)); if (strlen(sw->software_set) == 0 || strlen(sw->running_mode) == 0) @@ -986,7 +992,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } fprintf(stderr, "software set: %s mode: %s\n", - swcfg.software_set, swcfg.running_mode); + swcfg.globals.default_software_set, swcfg.globals.default_running_mode); } /* Read sw-versions */ diff --git a/include/swupdate.h b/include/swupdate.h index 29b756d..4ae0b43 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -135,6 +135,8 @@ struct swupdate_global_cfg { char aeskeyfname[SWUPDATE_GENERAL_STRING_SIZE]; char postupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; char preupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; + char default_software_set[SWUPDATE_GENERAL_STRING_SIZE]; + char default_running_mode[SWUPDATE_GENERAL_STRING_SIZE]; char minimum_version[SWUPDATE_GENERAL_STRING_SIZE]; char current_version[SWUPDATE_GENERAL_STRING_SIZE]; int cert_purpose;