Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8E1EC433F5 for ; Thu, 3 Mar 2022 21:17:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E361083D45; Thu, 3 Mar 2022 22:16:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SCJkdsnq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7C54883CA4; Thu, 3 Mar 2022 22:16:18 +0100 (CET) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0933683D38 for ; Thu, 3 Mar 2022 22:16:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ej1-x633.google.com with SMTP id r13so13395977ejd.5 for ; Thu, 03 Mar 2022 13:16:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :references:content-language:in-reply-to:content-transfer-encoding; bh=lVX7PW/w2T/DNE0ppiF2kq6k3shn499jusZuZcccdpI=; b=SCJkdsnqB29kiqqsrGOrj3iYZI+AbQw/zffaBKHi+8mVH8I1y2j4GJKkpEun3dn8/d bEOs/sifPOtEoWN63CU1aNSAv39Ao1Hvd6QNafGGwmDOj4mE39UyY2baQCBck2G8gy3l Middtxu1U3li6IEAIhOKdLAoLNID9oAntF1iT+5cVwoM3SBcleUUJpe99xUz6FStwfBh xclnBE0WKqGVFJT4AudCmKXDLvQHWVxiBg+XP3brlKdh4BE9wXHXHlXqEbjojXCWJ8n+ mWYkyhoDQgo2ihvZrYNnxx/QhscMdHdFAic1EEhJssxT9ChTEOLY8R8K4hdNK2+I4TH2 7kKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:references:content-language:in-reply-to :content-transfer-encoding; bh=lVX7PW/w2T/DNE0ppiF2kq6k3shn499jusZuZcccdpI=; b=E+qPOZxIpsYTlH7ljV/M/Vi2NDJ637n0QKVqqisqLadDXJ3nhVrSf/bV7AGd17lnMX Ay0F2vUYgm3nymJjPclzrgiKbdyzLBiscoPupRTJBXICu2GwwT1KtHL3tZa9ms4fI0HB IB9fqBA1MySc9WaciHIy50/ICbRo8Loa5HkMxx6DSmYVCK/NUPwF4kToVo5wTELeYFeh aIGxr/VjxALfgxyfIY02UJtE+dBJeT+DzukCHFb7745/iWWQ8y4ypE3i7CETChB2GelS 1NVlWcMt+0whB4dm3x/NFc5I0XMWFBKi8DwVIe57VV92knrcgmWlntu7hzQMxhNwVFOg VbKw== X-Gm-Message-State: AOAM533aXtiBwZ+FsQEKWUE3A84LDew+lsS4YzRGbYkrC0tO5c5A6lUf 2WNUaXInQMM6Jr4D4tfwdyI= X-Google-Smtp-Source: ABdhPJxUZKcxrz4f+wnf548ktTOVNdlyhRyE0NyOgq/i3LueabfR+S2cDh5WrvZt/W/faSjScSg7Fg== X-Received: by 2002:a17:907:1687:b0:6b5:a9f7:4eca with SMTP id hc7-20020a170907168700b006b5a9f74ecamr11372458ejc.535.1646342173582; Thu, 03 Mar 2022 13:16:13 -0800 (PST) Received: from [192.168.0.74] ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id lb14-20020a170907784e00b006d5c0baa503sm1055203ejc.110.2022.03.03.13.16.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Mar 2022 13:16:13 -0800 (PST) Message-ID: <22d5d296-65b4-2a97-5879-d038d400efc5@gmail.com> Date: Fri, 4 Mar 2022 00:09:31 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 From: Alper Nebi Yasak Subject: Re: [PATCH v2 12/25] binman: Change how faked blobs are created To: Simon Glass Cc: Ivan Mikhaylov , Tom Rini , Philippe Reynes , huang lin , Jeffy Chen , Kever Yang , U-Boot Mailing List References: <20220223230040.159317-1-sjg@chromium.org> <20220223230040.159317-13-sjg@chromium.org> Content-Language: en-US In-Reply-To: <20220223230040.159317-13-sjg@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 24/02/2022 02:00, Simon Glass wrote: > At present fake blobs are created but internally an empty blob is used. > Change it to use the contents of the faked file. Also return whether the > blob was faked, in case the caller needs to know that. > > Add a TODO to put fake blobs in their own directory. > > Signed-off-by: Simon Glass > --- > > Changes in v2: > - Add a patch to change how faked blobs are created > > tools/binman/binman.rst | 3 ++- > tools/binman/entry.py | 9 ++++++--- > tools/binman/etype/blob.py | 7 ++++--- > tools/binman/etype/blob_ext_list.py | 2 +- > 4 files changed, 13 insertions(+), 8 deletions(-) I feel a bit uneasy about all this fake file stuff, but can't figure out exactly why. I guess the patch doesn't make it that worse. Reviewed-by: Alper Nebi Yasak > diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst > index 85f8337a31..a90364f2fb 100644 > --- a/tools/binman/binman.rst > +++ b/tools/binman/binman.rst > @@ -1500,7 +1500,8 @@ Some ideas: > - Figure out how to make Fdt support changing the node order, so that > Node.AddSubnode() can support adding a node before another, existing node. > Perhaps it should completely regenerate the flat tree? > - > +- Put faked files into a separate subdir and remove them on start-up, to avoid > + seeing them as 'real' files on a subsequent run Do we need to create actual files, or is it a convenience thing for blob entry types (because they already read their contents from files)? Also, maybe it's better to create them somewhere in the /tmp/binman.* directories so they disappear without effort. > > -- > Simon Glass > diff --git a/tools/binman/entry.py b/tools/binman/entry.py > index 00a13c5839..2fb0050da5 100644 > --- a/tools/binman/entry.py > +++ b/tools/binman/entry.py > @@ -997,15 +997,18 @@ features to produce new behaviours. > fname (str): Filename to check > > Returns: > - fname (str): Filename of faked file > + tuple: > + fname (str): Filename of faked file > + bool: True if the blob was faked, False if not > """ > if self.allow_fake and not pathlib.Path(fname).is_file(): > outfname = tools.get_output_filename(os.path.basename(fname)) > with open(outfname, "wb") as out: > out.truncate(1024) > self.faked = True > - return outfname > - return fname > + tout.info(f"Entry '{self._node.path}': Faked file '{outfname}'") > + return outfname, True > + return fname, False Can't callers use self.faked for this? I think I see an edge case when calling this multiple times for the same filename, only the first call would recognize it being a fake file and only the first-entry-to-call would consider itself faked. > > def CheckFakedBlobs(self, faked_blobs_list): > """Check if any entries in this section have faked external blobs > diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py > index 25ec5d26c9..89f089e740 100644 > --- a/tools/binman/etype/blob.py > +++ b/tools/binman/etype/blob.py > @@ -41,10 +41,11 @@ class Entry_blob(Entry): > self.external and self.section.GetAllowMissing()) > # Allow the file to be missing > if not self._pathname: > - self._pathname = self.check_fake_fname(self._filename) > - self.SetContents(b'') > + self._pathname, faked = self.check_fake_fname(self._filename) > self.missing = True > - return True > + if not faked: > + self.SetContents(b'') > + return True > > self.ReadBlobContents() > return True > > [...]