From patchwork Thu Sep 6 11:40:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 966923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=209.85.208.62; helo=mail-ed1-f62.google.com; envelope-from=swupdate+bncbcxploxj6ikrbqneytoakgqe3vy4fca@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.b="BiEiBuQw"; dkim-atps=neutral Received: from mail-ed1-f62.google.com (mail-ed1-f62.google.com [209.85.208.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 425dtY14H1z9s55 for ; Thu, 6 Sep 2018 21:40:52 +1000 (AEST) Received: by mail-ed1-f62.google.com with SMTP id g29-v6sf3594513edb.1 for ; Thu, 06 Sep 2018 04:40:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1536234049; cv=pass; d=google.com; s=arc-20160816; b=cebtoQjo95Aplh59oj5LMlmXVfeTDyTGpi4GZpGs3TgwOjiD0kXVKuFwXBBUgMQtNl it15l5QDD/J0bMKt1S0Uj49ziSosYb63DXMsky33iT2QkZPpDH+IufHW2Dniv0z4NalX v9otEeWVhzvcfJvatVnUM8QZY8VsG3brstD/WnZk6NaPmtnIlY39qO2j8VomBy9n9GYa nxsTqV835eOw1S4OOeqZ8TDVYLIPSrbfRkGjsYcxpRxOoUIj435nSKFm/7iILFKsDWoU 8zR3/FVkH6R3xIJeXiWGzDnuht6Ha4sGygBfTFSUIRKbMXxkIrn6IhVXVULManKCIQyB 6Etw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:mime-version:sender:dkim-signature; bh=JDcRcSfW+0W84HZ/rWqGWYz4Shc4PCJZzvTjzHJnzbE=; b=QS8d51kyEcJx6JnSLMUpIraRLlI2o2M2DE2J8f5mW8bJNorJtueG8qOnZef0kkmTVy vK/I5KyyUAoSr7sol0B93AndMailuXzcjnVUUaogtxDfw8GiShSFDasnFCG0A4WG0IDv PvzdfzG6NkW2WRu6+lbESd9N6PjRmWAMHfpNmqf++q5z9EozR6ZfwK/aqyeNJZnAhNd1 OgeFNY9oB3eSZFNp6ZwSoIMEWesm7iRN72NJF1e5pus6r8FK5m/yFqqLT5xsZIMdUBz7 v54yOqL5xz+SRDC1EzXzszMSlyFlbCQNQShFYIhyyaZKMiuOWlFu4KhJ6PNOkxXJGuRV H26Q== 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:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=JDcRcSfW+0W84HZ/rWqGWYz4Shc4PCJZzvTjzHJnzbE=; b=BiEiBuQwXQzO4C/nvLoP9eyI3nP5X1V9ldHMYAmZWiKR9Prd/yj7EHeV7WPDaxUAbb KNQyZwEirNz2rR9NHxRidSrRe7Lc2QPLLgdhPNCMZFLsEW/cbQjhRic7ZrtzWJcv4s03 O59PZ4q6egrtV2VkcOks4YPorqC2SEqoX6Q8kZNLmc4S+G1kAlaFpEpnSPa42v3IVd5X q9znwKL4dfPC55JVyHg+cOmJpm6Evy9p4Pc1tTvOCBgD7kZODQ2d2kvawdbSV79voB1i L+Y78Evdqi5UgrXUErtsKx7FMycKMcnnBKf8HxiuEKcXwMpVbkSY96ctGzzYzEUh8jkY z1tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references: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=JDcRcSfW+0W84HZ/rWqGWYz4Shc4PCJZzvTjzHJnzbE=; b=dZJcECySEPFzA8X4d7+d2vohS7TfDDhcHE/jj+2CtxfIb0JX5H717VOX6l1GTHXqYV W5u9wNu4qcXLMdr8ZaXg3RcSeMk9fyeid0xB3h0DHDYeItSvEyVaXAWjMuZW/ujZTnkE kCyBdpz6RNCyW5u/tw5L4/n52ijuvFQZPMP6MtQlykvNhxvvzUCZ88/idFqlqDB3Pavj 1aVGBWTkDLZe5n0Tj6w1LqhY7XsX456ROiLv/xkTl9GySR2TCSt4BrkWlmBuN7fdGPaP ikH4gNt4I6OfiuyQu4hVKPc4u4xHRhKlja7NwF/YbElSdHap7c/fhw9JlZp1RvjZqmSJ MvkA== Sender: swupdate@googlegroups.com X-Gm-Message-State: APzg51CnEle/bGjBWkZkEKnlolwtO6iRKU1CVRHgV1QX/1NFZMpJ/7iw 1aJMzJ9acj2pz9Eeoo4r7CI= X-Google-Smtp-Source: ANB0VdbZmd2EHH4CMbJKK2IJgLpg9Y+4xRUSl4Hg3rKfLb3A0A2Bd3ZlzOTC/DXEqWldQHwRduwKPA== X-Received: by 2002:a50:ab12:: with SMTP id s18-v6mr16721edc.5.1536234049927; Thu, 06 Sep 2018 04:40:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a50:c985:: with SMTP id w5-v6ls2343997edh.5.gmail; Thu, 06 Sep 2018 04:40:49 -0700 (PDT) X-Received: by 2002:a50:b1db:: with SMTP id n27-v6mr649028edd.10.1536234049465; Thu, 06 Sep 2018 04:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536234049; cv=none; d=google.com; s=arc-20160816; b=SxEgWKqD/uO5HelyUtOhiWcu5qY7/y9/ZPiE1JdqEBRB0VdobeO/HMnFIgS8UT1pFe x9UGBYDsXV5a5zeE2cVBAZryc1aNAHb6jnl7YvlY9RtGew5laZbDpeaHuO2XHij7EqRl PmEy8jCeAfyYNkkmhlAXy8lmBh30HZuq+0d7Ela/zmeVNOrJJYAQ/F08dUHnzKPWsEBg aJxSe3lMh5s4QVDtNK76jp0EDOUA404l0PxdG3o2cvtYrgIleIn5PgZ78UGM8SBRuZJN BJAc4MgJEO+WjRT0txRVoZ1xDiArgNGPP9YipsT0Jf3oWtJd0rVuwlE3nEHQ6Opdespg 7YJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=3ZVLsbS17BVnI34TstDpWR3y9qrl3KV+QWv0ptwdMiI=; b=M2aHatIf9/0uQOoaAMlprRI7Nj96mKRxG8sWAZYV+cY0jxXZaRPbQ6kwTCwTZ5Ks/X 50B1PiofPHA0UeFcsqHAshtYFN6LRuCNwSpSmKbIdW1932ZlzO0bwtPQUirkbyWrzWmi PhyhYXbFFTV/x88HCI+09RBr99ABjKhIryhN8o45D0N4XlnCZvkX6nKG4Ja07wW81EzL oHxwnau4AiJbGPVcZ3TKT0GoHtOvcq0E8dyQtuyhmYAKMlUuoec6EyH+4wF0UhohpG6L 2t9KYY0c2OwZ+KJyabbdGwZ2GKeTNd2kyoJomPa8FzHlnluNyDI0e5/QAhn8Q0M3Us9y MUIQ== 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 o55-v6si221664edo.3.2018.09.06.04.40.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 04:40:49 -0700 (PDT) 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 425dtT1TKrz1qvfq; Thu, 6 Sep 2018 13:40:49 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 425dtT1Fw3z1qrVp; Thu, 6 Sep 2018 13:40:49 +0200 (CEST) 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 h9COMkGVYsVi; Thu, 6 Sep 2018 13:40:48 +0200 (CEST) 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; Thu, 6 Sep 2018 13:40:48 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 26DAF4540360; Thu, 6 Sep 2018 13:40:48 +0200 (CEST) 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 LPx5bKfgbVZW; Thu, 6 Sep 2018 13:40:46 +0200 (CEST) Received: from papero.fritz.box (papero.fritz.box [192.168.178.132]) by babic.homelinux.org (Postfix) with ESMTP id B53E14540361; Thu, 6 Sep 2018 13:40:43 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 3/9] bootloader: change "none" in RAM mode Date: Thu, 6 Sep 2018 13:40:35 +0200 Message-Id: <20180906114041.21828-3-sbabic@denx.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180906114041.21828-1-sbabic@denx.de> References: <20180906114041.21828-1-sbabic@denx.de> 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: , Instead of doing nothing, the "none" bootloader maintains a list of environment in RAM. This allows full test when a variable is set and then read back from code. Signed-off-by: Stefano Babic --- bootloader/Config.in | 6 ++++-- bootloader/none.c | 24 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/bootloader/Config.in b/bootloader/Config.in index 9e33dba..c71a143 100644 --- a/bootloader/Config.in +++ b/bootloader/Config.in @@ -27,9 +27,11 @@ comment "U-Boot support needs libubootenv, libz" depends on !HAVE_LIBUBOOTENV || !HAVE_ZLIB config BOOTLOADER_NONE - bool "None" + bool "Environment in RAM" help - No interface to a bootloader + This simulates the interface to a bootloader. + Bootloader environment is just maitained in RAM + and lost when SWUpdate exits. config BOOTLOADER_GRUB bool "GRUB" diff --git a/bootloader/none.c b/bootloader/none.c index a061ca0..57ff121 100644 --- a/bootloader/none.c +++ b/bootloader/none.c @@ -6,24 +6,40 @@ */ #include +#include #include "bootloader.h" +#include "swupdate_dict.h" + +static struct dict environment; + int bootloader_env_set(const char __attribute__ ((__unused__)) *name, const char __attribute__ ((__unused__)) *value) { + dict_set_value(&environment, name, value); + return 0; } -int bootloader_env_unset(const char __attribute__ ((__unused__)) *name) +int bootloader_env_unset(const char *name) { + dict_remove(&environment, name); + return 0; } char *bootloader_env_get(const char __attribute__ ((__unused__)) *name) { - return NULL; + char *value = NULL, *var; + + var = dict_get_value(&environment, name); + + if (var) + value = strdup(var); + + return value; } -int bootloader_apply_list(const char __attribute__ ((__unused__)) *filename) +int bootloader_apply_list(const char *filename) { - return 0; + return dict_parse_script(&environment, filename); }