From patchwork Sun Nov 22 09:51:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1404461 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::63a; helo=mail-ej1-x63a.google.com; envelope-from=swupdate+bncbcxploxj6ikrbhhj5d6qkgqeehbscpq@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=BUfjKto3; dkim-atps=neutral Received: from mail-ej1-x63a.google.com (mail-ej1-x63a.google.com [IPv6:2a00:1450:4864:20::63a]) (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 4Cf5CR5H52z9sSf for ; Sun, 22 Nov 2020 20:51:29 +1100 (AEDT) Received: by mail-ej1-x63a.google.com with SMTP id p6sf4919602ejj.5 for ; Sun, 22 Nov 2020 01:51:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1606038685; cv=pass; d=google.com; s=arc-20160816; b=MvcYyKFF0XTypjr4vsPV7/Zp6hxLIGJvRnYQiTQyM+OP2+Mx5yKxcdyNxLw54zPZc2 j/Q+qyiBuakoQrag4iL+1eahcPM58GudJ7d64UXwksHRA9Q/9QUjlDc/vUY3JaaMk/WC uxpJdnP+YHUR5cyEhV9Xj51YDyC9NyK+OffrWttK0zHN6ag1t2yZfegIRzQShirnUOl7 R5euuPinzBXe7uvqXeCmRHifK9IjweBXLIaF494ZaXpDTKgIyi0uLJO4xlbVXfiRSt1w Xs5N9SWhOwo+QycdBkRxDrAbJ+ZwtBXSQHTmgp8Q2qpw/IEu229PIjq0wJu+pVMbIW0f WLbg== 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:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=WgnUnZxfgbMhQhNaowdE/Zg5kjuD+84bSndmjMRb9hE=; b=vsx11NE2Io72RFwxsebgiWrgoKWMMYDDeeKFzwtt8dlc0LFlhO6SBiFteqhChiVnbj S4OzTqicD0DIJbEhSovdwlBjlmuI9IA3N/ZcJGKfhUcj/P1zXcHOUWn8ulQdb4Jjhilq NZcdVXnhBUY5GV6vuAM2VsB6+9vcYa9QTlSRaScv/E2TWPbl2l7NeMbnAqeSNjDlHec/ jimM4O51n4ODKgiXWivOvCNQaotvSGyDySN6T77nxTVs5ba/EYx3oCfKWLQ3AzfqP1ZG qttIB0cSgDaDFXPMSbK6a8zGkv2f6ycOVAdFpzxTwolel4yPAISIg8+XGpZClxX1j63p 1djQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 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: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=WgnUnZxfgbMhQhNaowdE/Zg5kjuD+84bSndmjMRb9hE=; b=BUfjKto3obV3pOPE4GeZ1J8Tm+VgfzByT7t9zK8nOWaRTcebim1ZZUeM6VdLWDBOLA 5emG8iFTrwZ/z+QaCyplfUdbQfAMSGBCuy1uYnrnedKXq6jn7YEmAsjmepvvHPr7F3wT orAJT5mnDZnk8YlazCDeISh5zT/eMgOgfRKFRZIm+U/jeXdGVEpYPqOMrzDeRraf00VN 5DsJU2qA6EJ4j6FCme/81HRwYtkGJnyejU7z/ALgWzSIankamMPqlwqgMqxvY5seux8Q VPoCYGf+1p3IbO6kBO2lTNOMu6iAbG9jRdEh2+wNQMpYCKzZdyE1ockAAFef9YUaeMpj 6xdw== 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 :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=WgnUnZxfgbMhQhNaowdE/Zg5kjuD+84bSndmjMRb9hE=; b=jihTsO3xL7lGZkX6reu2tS0LnKdcbzipq7gAgv9zlSEhJDTH84STIV7Lzyr+mH3ybf 6suqOJBJg7kZaibh+vm/HEwaOeqpg5SP6UZiJrwrDc2UlV4btOgTZu3J9304CGPOn+F4 w7MB7UXy1fKBgnarYcFq8zl95uiov8T2p2OOWQsGj30+QHl9B6JkOuVR9XrycUWDeWbF FMxkl5wXi0HKl6NCqAUPakWFVWkQkiU846fcwwOF18uNEHd08Hdn72z/ZulgN3wfgYYr kPFxT3Oqw1Uiu/IyaTmnUy8nu8lozU65ffg696+0iGYnRcjYVvAV3W8KIqQvw4QtvHI0 Y43Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532TuwlD7r8Pb1g1U/bP9xwDE3EQ2UR7xTg36tJj5tvGzSFliRuj AwXRshB7ByDSUGp6zngnCxw= X-Google-Smtp-Source: ABdhPJyNQY//QaZNcqB0I6bWcwqCB/x1mwPAq/gl/YvPA2V/ZaNekykIyp+QBuBcRSF6kzgfi9i5nQ== X-Received: by 2002:a50:fe88:: with SMTP id d8mr13158716edt.36.1606038684940; Sun, 22 Nov 2020 01:51:24 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:68a:: with SMTP id u10ls4828817ejb.0.gmail; Sun, 22 Nov 2020 01:51:23 -0800 (PST) X-Received: by 2002:a17:906:c0d1:: with SMTP id bn17mr41619574ejb.114.1606038683774; Sun, 22 Nov 2020 01:51:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606038683; cv=none; d=google.com; s=arc-20160816; b=Xh8Hfy+Ph4dHEOQP2744oc2ptNtRSoeyJkru72srYnT3NFmmxHeFGhS1Nv4nGRIUAk uP5XZXLwwTueLb0mZ8ZFnLV2uhCDm+1XZU5REkIi00GyFXbxQNlzrI5W+UOcXavj7e91 66qVHu7rKb/LynsBiBBnl7C6urxau1cgI+pwmQxGVaCqaiN0ol2lNpv67xcNPBvvDXOw ehW1ApIUkMRD6lXhKWeabTM83ncMKuJkSJrCYbvMqSJUfVEoZ8lQZnv4VuDV1es6uNwx zbLpnu9n9DIJsLn+Vs++b5afPvLxNbDq5ZvBcDbBv7ojLe15BsLIfM0kISoQhaMSx7xC oY2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=VrcqeSceLG8ICYqezMl8aQQJFXWAducVKopvIZcyRJs=; b=mXuUVQsdbyaWI91FKL4QmoAsZw+aTl5mf5qZCzeZ86XJRnVvyDapw2owKoOHwCjWmt /x+vTUrrbaBRU2HJWc88gFweqC6Rfyu80vdICTtBOgBBr8bADfoGuMd+6l02zRH7BW99 QOpBP4MM1oA9Qz3QgMLrkQiBO4ULGCr4iiFVhD+Tk2IWZzKSzTccdGXtm//BnxhLhQuZ 6MAtwx3df1Tw9SDpYQR+t6wptzivC4ROmFSTauNzpanlxOWAshmkI4XIyVVEOY6QMLKL 27dDyT6k+VzjyZFAVN+z3iPkL10srXqsMh2JD7HBI5i0A6nyyfCRopbnZZ0cAgCkTrzo YRpw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 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. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id v7si435703edj.5.2020.11.22.01.51.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Nov 2020 01:51:23 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Cf5CH3s28z1rtN6; Sun, 22 Nov 2020 10:51:23 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Cf5CH3cZHz1qwlJ; Sun, 22 Nov 2020 10:51:23 +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 KwCf5rHMGcjV; Sun, 22 Nov 2020 10:51:22 +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; Sun, 22 Nov 2020 10:51:22 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 56C9A4540445; Sun, 22 Nov 2020 10:51:22 +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 k4I9pzhJ7Hpn; Sun, 22 Nov 2020 10:51:19 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id 994F84540210; Sun, 22 Nov 2020 10:51:19 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] dry-run option overwritten by IPC request Date: Sun, 22 Nov 2020 10:51:18 +0100 Message-Id: <20201122095118.78296-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 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: , An IPC request can contain if the install should run in dry-run mode, but this overwrites the same option issued with command line parameter. Store --dry-run into SWUpdate's structure and use it if the request does not have set any value for dry-run. A request should indicate if dry-run is set or if the default value (from --dry-run) should be taken. Signed-off-by: Stefano Babic --- core/stream_interface.c | 11 +++++++++-- core/swupdate.c | 3 ++- doc/source/swupdate-ipc.rst | 4 ++-- include/network_ipc.h | 8 +++++++- include/swupdate.h | 1 + ipc/network_ipc-if.c | 1 + tools/swupdate-client.c | 3 ++- 7 files changed, 24 insertions(+), 7 deletions(-) diff --git a/core/stream_interface.c b/core/stream_interface.c index 3f8a168..39fa64e 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -504,10 +504,17 @@ void *network_initializer(void *data) /* * Check if the dry run flag is overwritten */ - if (req->dry_run) + switch (req->dry_run){ + case RUN_DRYRUN: software->globals.dry_run = 1; - else + break; + case RUN_INSTALL: software->globals.dry_run = 0; + break; + case RUN_DEFAULT: + default: + software->globals.dry_run = software->globals.default_dry_run; + } /* * Find the selection to be installed diff --git a/core/swupdate.c b/core/swupdate.c index 5099abd..0684de4 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -390,6 +390,7 @@ static int install_from_file(char *fname, int check) save_state_string((char*)BOOTVAR_TRANSACTION, STATE_IN_PROGRESS); } + swcfg.globals.dry_run = swcfg.globals.default_dry_run; ret = install_images(&swcfg, fdsw, 1); swupdate_progress_end(ret == 0 ? SUCCESS : FAILURE); @@ -799,7 +800,7 @@ int main(int argc, char **argv) loglevel = strtoul(optarg, NULL, 10); break; case 'n': - swcfg.globals.dry_run = 1; + swcfg.globals.default_dry_run = 1; break; case 'L': swcfg.globals.syslog_enabled = 1; diff --git a/doc/source/swupdate-ipc.rst b/doc/source/swupdate-ipc.rst index 31aa8d4..f506215 100644 --- a/doc/source/swupdate-ipc.rst +++ b/doc/source/swupdate-ipc.rst @@ -105,7 +105,7 @@ the update process: struct swupdate_request { unsigned int apiversion; sourcetype source; - bool dry_run; + int dry_run; size_t len; char info[512]; char software_set[256]; @@ -123,7 +123,7 @@ other fields as: - *sourcetype* : one of SOURCE_UNKNOWN, SOURCE_WEBSERVER, SOURCE_SURICATTA, SOURCE_DOWNLOADER, SOURCE_LOCAL - - *dry_run* : true if the update must run without installing on the hardware + - *dry_run* : one of RUN_DEFAULT (set from command line), RUN_DRYRUN, RUN_INSTALL. - *info, len* : a variable length data that can be forwarded to the progress interface. The installer in SWUpdate does not evaluate it. - *software_set* and *running_mode* : this allows to set the `selection` fot the update. diff --git a/include/network_ipc.h b/include/network_ipc.h index 2e6f75d..22ecb9a 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -48,6 +48,12 @@ enum { CMD_ENABLE /* Enable or disable suricatta mode */ }; +enum run_type { + RUN_DEFAULT, + RUN_DRYRUN, + RUN_INSTALL +}; + #define SWUPDATE_API_VERSION 0x1 /* * Install structure to be filled before calling @@ -56,7 +62,7 @@ enum { struct swupdate_request { unsigned int apiversion; sourcetype source; - bool dry_run; + enum run_type dry_run; size_t len; char info[512]; char software_set[256]; diff --git a/include/swupdate.h b/include/swupdate.h index 2b554b6..720868c 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -137,6 +137,7 @@ struct swupdate_global_cfg { char preupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; char default_software_set[SWUPDATE_GENERAL_STRING_SIZE]; char default_running_mode[SWUPDATE_GENERAL_STRING_SIZE]; + int default_dry_run; char minimum_version[SWUPDATE_GENERAL_STRING_SIZE]; char current_version[SWUPDATE_GENERAL_STRING_SIZE]; int cert_purpose; diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index fb59339..f09c417 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -177,5 +177,6 @@ void swupdate_prepare_req(struct swupdate_request *req) { return; memset(req, 0, sizeof(struct swupdate_request)); req->apiversion = SWUPDATE_API_VERSION; + req->dry_run = RUN_DEFAULT; return; } diff --git a/tools/swupdate-client.c b/tools/swupdate-client.c index f6bff6b..3e29bad 100644 --- a/tools/swupdate-client.c +++ b/tools/swupdate-client.c @@ -134,7 +134,8 @@ static int send_file(const char* filename) { struct swupdate_request req; swupdate_prepare_req(&req); - req.dry_run = dry_run; + if (dry_run) + req.dry_run = RUN_DRYRUN; if (software_set && strlen(software_set)) { strncpy(req.software_set, software_set, sizeof(req.software_set) - 1); strncpy(req.running_mode, running_mode, sizeof(req.running_mode) - 1);