From patchwork Tue Aug 10 15:00:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1515445 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::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbcxploxj6ikrbjnjzkeamgqex3k5oii@googlegroups.com; receiver=) 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=Kd9y8sRh; dkim-atps=neutral Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (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 4Gkbk33CTNz9sRR for ; Wed, 11 Aug 2021 01:00:58 +1000 (AEST) Received: by mail-lj1-x240.google.com with SMTP id u3-20020a2e9b030000b02901b787d7d260sf263137lji.3 for ; Tue, 10 Aug 2021 08:00:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1628607654; cv=pass; d=google.com; s=arc-20160816; b=ymyYlsLtpxu2hslzlZVklFd8fZzxGx5s/jVpWgLftUPs94Ay5uBPYxKQIB7jObYw5x 7dJaulO9Bc9w23i+veh/Ge02aQQ13m7FwtUEzlPCMwoJAeFL5MBMTlvzdTqYsVoP+5nf YzhCmogCuO5tZ7m3lPIJgrXRAIltd5q0ZqCTW+oKf/1On7b7Sw3B6bJbGCjFiEc0csyP Hh5RedHX3iBmku88uiTxlDH64sKT4rGtLfUEE3mlDTPVX7L5/5RaASwhlPZ3Uq/tGX2+ zZSg9W5zL78m/RPj7FIdjCoJSTRC7aNEfpU2+nQBGtfUk/aJlf4XjCZUwjq9zWMDwnmP rMvA== 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=yItB7ueJ07REN/41bqq8KW3E6kX0QZpoHdyn65Tl12Y=; b=Lkf6P3bc1ouOwIFbgcwZOX8+9t1sFfTT25pW2YnDiQPUJ6+XFuI0c/ZuU6cMjZgjJa UXpwmSz19nBliNP7ZQZ2aZMQSjQXKVLf0pIK/NBd4NhqWB/H3oeXNoqHkPJzs0mTV6tJ 5LED8YANAm/3ybhW8kAanECg/NpXLkYeQFtIstPDbSI+9f6gAZHXNzR2RstH6+GlAM3E F9gUMwoAbS+cqKk1LyLbNKMozunXIwNoRuhX3tdjdHODMdkLE6xwJHuhgvMPIfg+Yc/O h9oH1Df6gngwKzQlp2nays5GUJUg/La2E4/jcV1ZOWow8IKfqqshxAGfo57Ac80rDo01 50yw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by 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=yItB7ueJ07REN/41bqq8KW3E6kX0QZpoHdyn65Tl12Y=; b=Kd9y8sRhXkPbM5nmE4Gj/6LbkLoD1EmqwJTyN8HctlylyUxzzVbdYQ+jeIElAZS12c kUrrOE1jBHDlwztfcDu4xXkxhZpzjZRI6unrWNXxEjMdhHw0d1YvOFYyYF3iF+rj3x8K f5LdkP+8GemOivRB/+bRb/nHDQjBkF/HWKzhytOLWNltobNIQtYNAVlkJsaHMO2lZeR9 agBxaeKnU/4D1YbVNLo9YnzdIXOQkiK0H+8tKW+tHEE2jXHuzbqyw+9yWdU2BJUDKU3z TOe9Koon0I7Z/rkmextAWFkCHFKozgzLs2SdCBfFc4NqU7YfhjQPChM2bUHsnjIO1zCB qRlg== 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=yItB7ueJ07REN/41bqq8KW3E6kX0QZpoHdyn65Tl12Y=; b=ToZKq/3MQG9Sfls6/ImIHxfSRjoaJDKNsBi6JfZ4WaEOUM0ExTqU50S3IRtr+IwVnL 47ekq2LFSMZsxd40Baf5cuGwRPbzFdjrqFVW2QNRhLWlQhGR6irafVgCLdPBH70EeqGr YQF4uNt7LmuUeVOPFH53wW7/Dq1hr6U7gka0G3pPegOOt88oIlDZYGW2f9Ye6CLjLaKE aU9GH480Nj88czvMepmxbO3NmvbBNGIMrLLh0X9m1iAbA2REVsRW9Qcg2gafXz11n0E0 ivs123ny0YR2Uec6HttA2/n/PZyi3dIwVvUHtVMTY8ZjX/boeEmxcHXxMvm9i7FoxIPo Z19w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533w56DA3LzCfn4pNacb5sGdISsaT49c8wmHi2SxTgYs2Ab3laC0 Rqbsw0AV3yw0iyCp//dWHN0= X-Google-Smtp-Source: ABdhPJxogx9MDwxaAoNGABGG8SoDaAW001CvX45mQHZksjrgG6asBmCd2TCde+EVBvEUGJiuAY8LQQ== X-Received: by 2002:a2e:2f0f:: with SMTP id v15mr9825541ljv.203.1628607653881; Tue, 10 Aug 2021 08:00:53 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3f02:: with SMTP id y2ls662377lfa.3.gmail; Tue, 10 Aug 2021 08:00:52 -0700 (PDT) X-Received: by 2002:a05:6512:3708:: with SMTP id z8mr21458549lfr.418.1628607652770; Tue, 10 Aug 2021 08:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628607652; cv=none; d=google.com; s=arc-20160816; b=PpyFgPFeNwuUgwh2Dg80cZEhB8PZGvulE1AJg5oUm56r5t4/MUtJByrbpVXJwLqbFV YHe8pG6ifwhvLbaDRKgrSLrBn+VJ2Alz+04aI4juhd97RDzSSecNi6fiwWYOfZT3nZVj OEMzvqx1IOwvxsAy85TfY3HU6HiQqdFcrNcaEdv9tL/afygWj5pDlaEl53dMW0zLCY5V Dxdo7rvVydHmz+iGXHlyS2impu68GDKdJid+3AwVxX5h/YF1kvpwYwwO0IjHO/t+PPDw N+GqtuWmWblddB8Vt1gsUjVSS4SNOgPC73GEe5Ojq8uyWGFF56l/fLrp4FAa5QGF3sRz fLQA== 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=ZKoRnHBgwLL8sVO7hjS4BtoJi0mhuvAhKKmi50HBM8U=; b=Xy3jTc7hiVRyhBFOERS5pw3RnF/0+V0f+nUuqGAxK9WU8a8Cbqo0RVMBckk5Sb4+M2 hxevoFb2+FJsmbkkfN/8gadOuVMphBCIOlvHjh8OeTzaAmWLf7HTHCuSaMuuQ5cbGsaI z/S9hyA9+vCfVEQm0CKHvXL8Aw/Vjy/Nm3FDOAnZre274FyKYWuca+/e60J+4ZyxLgCz Y539r3rmUnJ0LXD4j2FaXaHdl8Jlo5+VD3mCgCmmnPt1Bfh1D2AtksMXSTOAxn2D5Iq/ nOQqgP30a5w63U74Wkjl3jX/zIjBQ5Xo3yUXYJNvtrNRGsyMV9TejyfgVC3S287KAYBd sefg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by 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 q8si151254ljm.2.2021.08.10.08.00.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Aug 2021 08:00:52 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by 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 4Gkbjw1RT2z1qwGj; Tue, 10 Aug 2021 17:00:52 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Gkbjw19mgz1qqyF; Tue, 10 Aug 2021 17:00:52 +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 ZkJLlbFlPz95; Tue, 10 Aug 2021 17:00:51 +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; Tue, 10 Aug 2021 17:00:51 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 546BC4541460; Tue, 10 Aug 2021 17:00:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ppnZkt0QL43W; Tue, 10 Aug 2021 17:00:47 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id D97E3454086D; Tue, 10 Aug 2021 17:00:47 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 1/3] util: add strtobool() function Date: Tue, 10 Aug 2021 17:00:44 +0200 Message-Id: <20210810150046.596033-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: 212.18.0.9 is neither permitted nor denied by 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: , Signed-off-by: Stefano Babic --- core/util.c | 7 +++++++ include/util.h | 1 + 2 files changed, 8 insertions(+) diff --git a/core/util.c b/core/util.c index 8651391..f640c7a 100644 --- a/core/util.c +++ b/core/util.c @@ -715,6 +715,13 @@ unsigned long long ustrtoull(const char *cp, unsigned int base) return result; } +bool strtobool(const char *s) +{ + if (s && (strcmp(s, "true") || strcmp(s, "TRUE"))) + return true; + return false; +} + int swupdate_mount(const char *device, const char *dir, const char *fstype) { #if defined(__linux__) diff --git a/include/util.h b/include/util.h index ad07b18..9f29f5f 100644 --- a/include/util.h +++ b/include/util.h @@ -171,6 +171,7 @@ int IsValidHash(const unsigned char *hash); _a < _b ? _a : _b; }) char *sdup(const char *str); +bool strtobool(const char *s); /* * Function to extract / copy images From patchwork Tue Aug 10 15:00:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1515446 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::139; helo=mail-lf1-x139.google.com; envelope-from=swupdate+bncbcxploxj6ikrbjvjzkeamgqe7s4kglq@googlegroups.com; receiver=) 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=axz8uuLu; dkim-atps=neutral Received: from mail-lf1-x139.google.com (mail-lf1-x139.google.com [IPv6:2a00:1450:4864:20::139]) (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 4Gkbk33GF0z9sRf for ; Wed, 11 Aug 2021 01:00:58 +1000 (AEST) Received: by mail-lf1-x139.google.com with SMTP id d16-20020ac25ed00000b02903c66605a591sf984156lfq.15 for ; Tue, 10 Aug 2021 08:00:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1628607655; cv=pass; d=google.com; s=arc-20160816; b=oZeMeohroBNRhg5m5bcvR4xMiqQqQ0INtZsiffblenSbMFSMwOykf697WL1HvcqKTK BAkZ5WQtUujyZmvH0hPbia2reFTnMHGz0w6x0fE8l21+4w6R2CvCezXyRsajIxAUlzyi 4L/uFFh2GE00WEf7kSlMNrvHPI1gA0fNScP84KXjuHKQ+qvIDvm+E3fqkdIsf5JrEnN0 5VROaYqSaigIdQ51mzkULqOwgRg0RCk1Bo3HlN4KoSQmp0oLwKIEynPAw/Ug6A7lw9TH pETiG0vFyxAnDToSUZB/v+p+FG8pOsV+aR11Ahx0cEshPEnI9p86x5RwUneqQSwZYNO6 NS5g== 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=VaTFL40xXFw2jXnVE/V+sVO2H4pzCNdhZie7pTGV6D8=; b=zLcQaGQjJuuLWjLiznve+h2/GJOv7D2fxlq6olkRMQWknO/+elYpAO6ZiFpqRYD6dk tKvAtGamgN4qjLhSJNf1iZu3w6f5LqIcSG7kaKNzJrzNZm1kDIcjGWnVsckl4YQRUW+y +HK1RrDHYd6VjTsvA/6HswlOEhkFTfVfw59Ww2pSizZ293s9g5TaTEo4eVRhZdY2O/yF aTqQdL7SoisOGq+DnXjXqg2sxcCpyXzcN2ZVk8icmc4QrXjD94mIutX/zkuus8SSGrY2 Q4WKJI5AyUTlHoOkZFj4JEtMsJzunkXsdUs3NwwdZzpEYcg848P+IiArxg+pOsK02B32 ci2g== 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 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=VaTFL40xXFw2jXnVE/V+sVO2H4pzCNdhZie7pTGV6D8=; b=axz8uuLum1VaSg14THZxqrUJnjI7ZK0hzg7DYwC4e65SsUbmBalfxau/H68zNjQvxl 1oJnIt4rlcHzi3ooRsomR/PzSPmH1AXhWT97OfLSZNUVj5W1X/yH8tbYSFWohK8Ht7u4 b1rPCO0peKhQ2dkAHcWT7Ckthr7a7oEQ6Zr6XDKYyNsP/3f1CLXVM5czE52hdSns+yZG A5rq4/1FNYlDd12QS4F/Bfy1QI1DZa0FSBA7I5M1iOwWwRAhZSmuMscuelFtG9Fi7fcX bzhkMwxYzDAXbzAGZzYe3cJQ/4iIOvDGFMn6T2O5Jnb6HzLGsskPBrsWyY0K5hdyDfzh xyeg== 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=VaTFL40xXFw2jXnVE/V+sVO2H4pzCNdhZie7pTGV6D8=; b=XVIGhzAiEYst6VTNutejlirs+Xos776ZkNkctLzX4ap5uOFkIZszOrgV/P/InILMZQ CyOCJpWTlQ6nK/I3OlS3wW1BOvqQos9Ah06OPk71FaMmyhAhri/nuIdlR4gTIK/7iWm/ dUCCNxGvPFlotqckKhGbfpm0gpTqxCsVcyUpFegKdk7tYmV0TiH5TrF1SWg59Yq+B8fz SKQDjwbDpqgP0S9O7A5g7M/3WfxnOIx5dSde3KNRvbOSQ2FEFMrBjb8Bk87H6/4HSgy+ UPR51uq/zmo52ZYmu+mFhQXBUrPzLiNZJjn+hlHuy0S32BzD3ccKL1EQEPl3r4TZqCCX lvRg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532sM9T+EKpBRiZ71mR3Tj3i8vhzdh3HZQUL5p7IsO6FvI+H528I w1eKUEqVKUph5biih6mX3AA= X-Google-Smtp-Source: ABdhPJxuKF0qZABKJ4HJelpG5H0l3xyzhvV8yVxzOuAipxbOMbD4BP9VYDFYtdTorwwJG03/+1HJLg== X-Received: by 2002:ac2:4422:: with SMTP id w2mr22743773lfl.185.1628607654450; Tue, 10 Aug 2021 08:00:54 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:160f:: with SMTP id f15ls3140761ljq.3.gmail; Tue, 10 Aug 2021 08:00:53 -0700 (PDT) X-Received: by 2002:a2e:300e:: with SMTP id w14mr16520471ljw.403.1628607653429; Tue, 10 Aug 2021 08:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628607653; cv=none; d=google.com; s=arc-20160816; b=c8eM8XjQpG5ywL5szsIGoxsm0uFAzeBoFekUh797J8L4dkaWI+Q1baqvkCd1O75qjj ze7SLeFmXKtFPXW6dC4KunqXij8qyN/TWdHt/H3p47INEJUUPXW5/ris2UMxfLoWrDDF NjO1H7dtajyOPRiD4htIDHuNg79IDJbqlT/Ev6MexFbYRG1ipLYUVmF9axJU1c//sIih 8HNGcJKCDpzJ9+gMwiTfV10bOjZi4761YPSytpAQhE4+OodLUrRcZPvcOL+hZDegMhad 0Yrg3DsXIpXsRdcXgXhwBM95QTICcKNjRzoJPM2Fcr0QcoJzqHILJSKFOood5VCEqV/n pxyw== 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=p//hgOYX1erhwTWcLrAbYQOxWjVhlcsKlZ4cIMYBsOw=; b=qYc3nRLIeCD/QTxssi9VG7AQtzb2CTJawO2JPzc20yonnb1xk005KN8x6egS0Dl5O6 344UFy6O8ZE98NR4PGWAms1bonXnSdgohC2Oj3Q8NhmVkEQcUE197vOCNeM+D6g4ivU4 jkg8WjIJo6081GGzxLweSk9dTJSdkixZc+CWdNy0lRXJJjeMeGAnze4FaddiMO2GSwAG hUHuO1r6fmC/bIo0Fzk3GtpVBSpJthelyCMMUHHq7Bv6iWXlp/7wBpdLMSnu19E/Axda +5KA0x26YozU+4BL5HbbY+m9EMwyTXWmNF8Bf9hVr8vv2MJj7BwHXyXzN8QnVeROe5ks VkxQ== 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 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 n8si622921lji.7.2021.08.10.08.00.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Aug 2021 08:00:53 -0700 (PDT) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by 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 4Gkbjw6l2Vz1sDRF; Tue, 10 Aug 2021 17:00:52 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Gkbjw67hhz1qqyF; Tue, 10 Aug 2021 17:00:52 +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 BaJrkh6Fy92t; Tue, 10 Aug 2021 17:00:52 +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; Tue, 10 Aug 2021 17:00:52 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 97D3B454086D; Tue, 10 Aug 2021 17:00:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 24SpnfBL2UG7; Tue, 10 Aug 2021 17:00:48 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id E71F14541345; Tue, 10 Aug 2021 17:00:47 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 2/3] diskpart: add a force mode to write table Date: Tue, 10 Aug 2021 17:00:45 +0200 Message-Id: <20210810150046.596033-2-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210810150046.596033-1-sbabic@denx.de> References: <20210810150046.596033-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: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by 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: , Writing table is conditioned to get the device in exclusively mode. There are cases where this is not possible, and blocking the device has broken these use cases. To get them back, add a flag "noblock" to the properties for the handler to ignore if locking the device fails. Signed-off-by: Stefano Babic --- Changes since V1: - add two separate flags for checking if device is in use or if should not be locked doc/source/handlers.rst | 8 ++++++++ handlers/diskpart_handler.c | 32 +++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst index 747e8ae..9410165 100644 --- a/doc/source/handlers.rst +++ b/doc/source/handlers.rst @@ -773,6 +773,14 @@ After writing the partition table it may create a file system on selected partit +=============+==========+====================================================+ | labeltype | string | "gpt" or "dos" | +-------------+----------+----------------------------------------------------+ + | nolock | string | "true" or "false" (default=true) | + | | | This is like a force. If it is set, it does not | + | | | try to lock the device. | + +-------------+----------+----------------------------------------------------+ + | noinuse | string | "true" or "false" (default=true) | + | | | If set, it does not check if the device is not | + | | | used (mounted, etc.) | + +-------------+----------+----------------------------------------------------+ | partition-X | array | Array of values belonging to the partition number X| +-------------+----------+----------------------------------------------------+ diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c index a0a47d0..1087c52 100644 --- a/handlers/diskpart_handler.c +++ b/handlers/diskpart_handler.c @@ -79,6 +79,8 @@ LIST_HEAD(listparts, partition_data); */ struct hnd_priv { enum fdisk_labeltype labeltype; + bool nolock; + bool noinuse; struct listparts listparts; /* list of partitions */ }; @@ -643,17 +645,18 @@ static int diskpart_compare_tables(struct fdisk_context *cxt, struct diskpart_ta return ret; } -static int diskpart_blkdev_lock(struct fdisk_context *cxt) +static int diskpart_blkdev_lock(struct fdisk_context *cxt, bool nolock, bool noinuse) { int oper = LOCK_EX; int ret = 0; - if (fdisk_device_is_used(cxt)) { + if (!noinuse && fdisk_device_is_used(cxt)) { ERROR("%s: device is in use", fdisk_get_devname(cxt)); return -EBUSY; - } + } else + TRACE("Skipping check for device in use"); - if (!fdisk_is_readonly(cxt)) { + if (!nolock && !fdisk_is_readonly(cxt)) { ret = flock(fdisk_get_devfd(cxt), oper); if (ret) { switch (errno) { @@ -665,17 +668,19 @@ static int diskpart_blkdev_lock(struct fdisk_context *cxt) } return -EBUSY; } - } + } else + TRACE("Skipping locking device"); + return ret; } -static int diskpart_write_table(struct fdisk_context *cxt, struct create_table *createtable) +static int diskpart_write_table(struct fdisk_context *cxt, struct create_table *createtable, bool nolock, bool noinuse) { int ret = 0; if (createtable->parent || createtable->child) { TRACE("Partitions on disk differ, write to disk;"); - ret = diskpart_blkdev_lock(PARENT(cxt)); + ret = diskpart_blkdev_lock(PARENT(cxt), nolock, noinuse); if (ret) return ret; } else { @@ -729,7 +734,7 @@ static int diskpart(struct img_type *img, int ret = 0; unsigned long i; unsigned long hybrid = 0; - struct hnd_priv priv = {FDISK_DISKLABEL_DOS}; + struct hnd_priv priv = {FDISK_DISKLABEL_DOS, false, false}; struct create_table *createtable = NULL; if (!lbtype || (strcmp(lbtype, "gpt") && strcmp(lbtype, "dos"))) { @@ -748,6 +753,15 @@ static int diskpart(struct img_type *img, return -ENOMEM; } + /* + * Reads flags: nolock and noinuse + */ + priv.nolock = strtobool(dict_get_value(&img->properties, "nolock")); + priv.noinuse = strtobool(dict_get_value(&img->properties, "noinuse")); + + /* + * Parse partitions + */ struct dict_entry *entry; LIST_FOREACH(entry, &img->properties, next) { parts = &entry->list; @@ -894,7 +908,7 @@ static int diskpart(struct img_type *img, if (ret) goto handler_exit; - ret = diskpart_write_table(cxt, createtable); + ret = diskpart_write_table(cxt, createtable, priv.nolock, priv.noinuse); handler_exit: if (tb) From patchwork Tue Aug 10 15:00:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1515447 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::23a; helo=mail-lj1-x23a.google.com; envelope-from=swupdate+bncbcxploxj6ikrblfjzkeamgqe2oa6fda@googlegroups.com; receiver=) 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=n2oI6rcS; dkim-atps=neutral Received: from mail-lj1-x23a.google.com (mail-lj1-x23a.google.com [IPv6:2a00:1450:4864:20::23a]) (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 4Gkbk82cq3z9sRR for ; Wed, 11 Aug 2021 01:01:04 +1000 (AEST) Received: by mail-lj1-x23a.google.com with SMTP id l12-20020a2ea80c0000b02900f5b2b52da7sf4692700ljq.8 for ; Tue, 10 Aug 2021 08:01:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1628607661; cv=pass; d=google.com; s=arc-20160816; b=x+k0WuGpVEBN/Vu8eeiZJHvjzQW+Lf9/eOkOREAfFffU/IjA0ntJ8CBNCCSDdRgkDe ZZ2cTSH6z8SZwsDKuJh429BQxXprhOvcN17IwMMHRWBNqss2L1jLrmBzEfVk0wHFfaDu QzxysydwVphNDSZsWprSsqA/rl0EW+xoMZ6tyXcZ+tjrD1DyVzdMU5+eECzOEGIiNHSn 1Z09hSMEr/lp+aYvQmJaXfT0TlndmC683CE3CdlvBdTdfc+peie2RR7S0KVkMHa1NWIh 9aeuJiwiFnuZtrwHdorxIhwMyptH45t6ejmtZcERGss9zcgHEhLbKB8i/ogGH+DSA0PI jRmg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:sender:dkim-signature; bh=DrIGqUzuUhtWasRGKU3z1fdUviGxr41nGKhmT/OWN6A=; b=i2vES4Awo+XlCmSI4csrtS0ATkD18sPl0ln5ot05JkymdM1bDhVhK2OFENG3+od5AX UzK7N0Q7ZFU4GpWp/b2RHF92xnC+nXQIwq48Z7DbZ5+6cZ3HP/AmR7LmO8Xtv47Wop6l fxief/YX26SYwiNIM5wAgL2hr3ooG9f0tiGEKjMTLlFubzPub2BxwAcX09ZG3wdn27gn ltzC8zqkPEaVgxF0qiG3twEfeMoH//egWMMfKRD1g1eR0TPlNgAFI2JC+Jj4fd/t4dzE Tm7U/R0uAo0LIw/kDF9DrfDJk4DRGrviUdW3wNo5b2Pm9k6raThmhcI2sN4SfZtw8AiG dJtQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by 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:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=DrIGqUzuUhtWasRGKU3z1fdUviGxr41nGKhmT/OWN6A=; b=n2oI6rcSL3YZ8lyFubwgSTFozCDbRsajTxauowc0qz1zIuilcCquUI+EXqRtBWcWeu nFObmQgduI31YwDyEuWr8p7Tzvjtp6ecGfgzXbcaKU5QZAfW55za3mkdxMHfNBfEMNW3 fmucFGiWEcZO79Nt9PfsbRsP6URK5MAZ9FfxCWkOEIRXzW0h3L2z28rOGhVy68OouzV4 z2Wt2DkR/Fnk+xgVpS9/Zm0czfwivnA6zuVEAguDAiZ5/G7X0sGuQbR6PWIBezjSXVIB Q1ZwhL4HNJZ+YMplNxXMef6ex06kkPHNsNXub826LxJCAVURmF0my/+sXGAJtW86cVym z9gw== 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:content-transfer-encoding :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=DrIGqUzuUhtWasRGKU3z1fdUviGxr41nGKhmT/OWN6A=; b=fxvwuUnxZzTt+99jkOTqRWk30HP2azT1EpBaJXvLHMuGkjztL3Diz1pVAE/UDTvLuM OVAMkOzBVAQUli18xGJgXvlPIqTD2eBuPZ1o95RsDH3Oj8+EnjYLlMgEmyNibqNsdmEU z3wpLxy+zssbzJN7dH7E1n/xxcZHzOeK7HKe0HeAATDKKt2wjfpd/JbuMOLqE1gI25XJ ZTuu8G30wIJuXMpI7dsZiScimknFvFPTfOqHd8Spo6XMSWNU7ejBQZNFxgUZ+mCukpe0 Dakk7FvPZWz19hF3kNgSD30yvNyAVpJ/NS6Ng1rmGkq0Fyk41BTzW7ZhBx9qU98a5ptr AFNQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532tKDFElvWFqVXkSiB5h0YKu1hdBGzhpiOtYNaXWh/wGU3j+K2I iEnWTeO7Z3dNtSSaaQ0lb30= X-Google-Smtp-Source: ABdhPJx1PSiv6ZrQvVa4fuOgZ5bAQgtCE6XncGa0Jnm3FjY0eeP9sv/G/6L9aUskd94HijDgU3fRjw== X-Received: by 2002:a2e:9798:: with SMTP id y24mr16322679lji.97.1628607660945; Tue, 10 Aug 2021 08:01:00 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3f02:: with SMTP id y2ls662960lfa.3.gmail; Tue, 10 Aug 2021 08:00:58 -0700 (PDT) X-Received: by 2002:a05:6512:23a6:: with SMTP id c38mr13107160lfv.268.1628607658736; Tue, 10 Aug 2021 08:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628607658; cv=none; d=google.com; s=arc-20160816; b=RsjOT6uervwACO/8UTi0F8Ku25Vb+UUy3sBpaWGrfpVljgC1K6nYYcFKDS8jhk14bH iEF7cv9C/OwQt4/x4AwpIuV/mEbovancYRljkCdDvkoJNqRq4Bkz9SQVEg9tXkHe208e iRxsUgRbJTt4qYq8expcyei+GW8H2o+ZtaxaalYogVaVCSJicPU5F30CsuOWNlvHoYqN Hnr5QKA7RQfxkF1E0P67ktabsqwWVStNiSLk5Vj9MQD0SLVt8p5ex5Oh4qFHs+Atqg5F XRdeSRiiwDWpoTHaZQc9/qDBt3Ac54oMvpAvLohkiI+wPUWZ6L/oe2HVwYtgwArgQ6G1 l3Fw== 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=P6nJfEyyWoLMWo5JTukLchLbweHoXN0oCyuUS+CvCyM=; b=sD7opcLuawLMTwOg+ro30tzeXh4lDQSU/93gsaMXo08BuaoUv36OItUdEudWeEi3hs RmM770hxfa/BWiw0XPNa6Qc6timTqhmx7VVF46zHAQCt2kQJ9IJMYTamHrBVU9ycyNxz MCbZu9LZsSKdllLkIZahhp3GbA7ms/skpdUy7VVrzJDHOFKQ3wV0QtviHkgj1TQLG8Ff crivI3zz7aCNYfj5ZleouXDbtKRvzOwxYTDFJyRg+V501LMolLrzaXBIYiwraj71pyEE FpA1XTs1fNsddbUvT8lCebFCx/qel+BhcfHvP6WohHJ1gjuPr2h4sQo9ZRWrMUGOUIJq JBfg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by 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 f25si405786ljp.5.2021.08.10.08.00.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Aug 2021 08:00:58 -0700 (PDT) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by 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 4Gkbk21rVhz1qwGb; Tue, 10 Aug 2021 17:00:58 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Gkbk21fH4z1qqyG; Tue, 10 Aug 2021 17:00:58 +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 gWUuiQavEvDO; Tue, 10 Aug 2021 17:00:57 +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; Tue, 10 Aug 2021 17:00:57 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 22A59454086D; Tue, 10 Aug 2021 17:00:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id oivMi3rchbTn; Tue, 10 Aug 2021 17:00:51 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 09770454142B; Tue, 10 Aug 2021 17:00:48 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 3/3] Kconfig: use DISKFORMAT as flag Date: Tue, 10 Aug 2021 17:00:46 +0200 Message-Id: <20210810150046.596033-3-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210810150046.596033-1-sbabic@denx.de> References: <20210810150046.596033-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 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: , The following warnings are generated if DISKFORMAT_HANDLER is set without setting DISKPART: scripts/kconfig/conf --silentoldconfig Kconfig warning: (DISKFORMAT_HANDLER) selects DISKFORMAT which has unmet direct dependencies (DISKPART) warning: (DISKFORMAT_HANDLER) selects DISKFORMAT which has unmet direct dependencies (DISKPART) This is due to a dependency between the handlers, that is not necessary because it is possible to link just one of them. Replace CONFIG_DISKFORMAT with CONFIG_DISKPART_FORMAT in diskpüart handler, and use CONFIG_DISKFORMAT as a flag to enable/disable the activation of the filesystems creators. Signed-off-by: Stefano Babic --- Kconfig | 4 ++++ fs/Config.in | 5 ++--- handlers/Config.in | 8 +++----- handlers/diskpart_handler.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Kconfig b/Kconfig index 93aee4e..dc86957 100644 --- a/Kconfig +++ b/Kconfig @@ -129,6 +129,10 @@ config CURL_SSL bool default n +config DISKFORMAT + bool + default n + config SYSTEMD bool "enable systemd support" depends on HAVE_LINUX diff --git a/fs/Config.in b/fs/Config.in index 682d952..dae855a 100644 --- a/fs/Config.in +++ b/fs/Config.in @@ -2,21 +2,20 @@ # # SPDX-License-Identifier: GPL-2.0-only +if DISKFORMAT config FAT_FILESYSTEM bool "FAT file system creation support" - depends on DISKFORMAT default n help Enable support for creating FAT file systems. config EXT_FILESYSTEM bool "EXT2 / EXT3 / EXT4 file system creation support" - depends on DISKFORMAT depends on HAVE_LIBEXT2FS default n help Enable support for creating EXT file systems. comment "EXT2 / EXT3 / EXT4 file system creation support needs libext2fs" - depends on DISKFORMAT depends on !HAVE_LIBEXT2FS +endif diff --git a/handlers/Config.in b/handlers/Config.in index 36f3ca4..14f8af9 100644 --- a/handlers/Config.in +++ b/handlers/Config.in @@ -106,9 +106,11 @@ config DISKPART comment "diskpart support needs libfdisk" depends on !HAVE_LIBFDISK -config DISKFORMAT +config DISKPART_FORMAT bool "diskpart extension for creating file systems" depends on DISKPART + select DISKFORMAT + default n help This extension allows formatting newly created partitions. @@ -120,12 +122,8 @@ config DISKFORMAT_HANDLER The diskformat handler allows creating filesystems on empty partitions. -if DISKFORMAT - source fs/Config.in -endif - config UNIQUEUUID bool "uniqueuuid" depends on HAVE_LIBBLKID diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c index 1087c52..b42e901 100644 --- a/handlers/diskpart_handler.c +++ b/handlers/diskpart_handler.c @@ -930,7 +930,7 @@ handler_release: sleep(2); -#ifdef CONFIG_DISKFORMAT +#ifdef CONFIG_DISKPART_FORMAT /* Create filesystems */ if (!ret && createtable->parent) { LIST_FOREACH(part, &priv.listparts, next) {