{"id":807715,"url":"http://patchwork.ozlabs.org/api/1.2/patches/807715/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170830163852.27454-1-dengler@linutronix.de/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170830163852.27454-1-dengler@linutronix.de>","list_archive_url":null,"date":"2017-08-30T16:38:52","name":"[U-Boot] cmd: set filesize variable in ubi read","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f846c5aef9080f1bcb76d8dc46c867c42800462c","submitter":{"id":72011,"url":"http://patchwork.ozlabs.org/api/1.2/people/72011/?format=json","name":"Holger Dengler","email":"dengler@linutronix.de"},"delegate":{"id":1691,"url":"http://patchwork.ozlabs.org/api/1.2/users/1691/?format=json","username":"hs","first_name":"Heiko","last_name":"Schocher","email":"hs@denx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170830163852.27454-1-dengler@linutronix.de/mbox/","series":[{"id":651,"url":"http://patchwork.ozlabs.org/api/1.2/series/651/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=651","date":"2017-08-30T16:38:52","name":"[U-Boot] cmd: set filesize variable in ubi read","version":1,"mbox":"http://patchwork.ozlabs.org/series/651/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/807715/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807715/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjBHj3DM1z9sNn\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 02:47:13 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 10810C2250C; Wed, 30 Aug 2017 16:46:02 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 88AC1C227E5;\n\tWed, 30 Aug 2017 16:44:26 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid BEE09C21E48; Wed, 30 Aug 2017 16:39:11 +0000 (UTC)","from Galois.linutronix.de (Galois.linutronix.de [146.0.238.70])\n\tby lists.denx.de (Postfix) with ESMTPS id 36CC7C21C73\n\tfor <u-boot@lists.denx.de>; Wed, 30 Aug 2017 16:39:11 +0000 (UTC)","from p548d276c.dip0.t-ipconnect.de ([84.141.39.108]\n\thelo=linutronix.de) by Galois.linutronix.de with esmtpsa\n\t(TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256)\n\t(Exim 4.80) (envelope-from <dengler@linutronix.de>)\n\tid 1dn5zv-0005X5-MA; Wed, 30 Aug 2017 18:37:47 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=none autolearn=unavailable\n\tautolearn_force=no version=3.4.0","From":"Holger Dengler <dengler@linutronix.de>","To":"Kyungmin Park <kmpark@infradead.org>,\n\tHeiko Schocher <hs@denx.de>","Date":"Wed, 30 Aug 2017 18:38:52 +0200","Message-Id":"<20170830163852.27454-1-dengler@linutronix.de>","X-Mailer":"git-send-email 2.14.1","X-Linutronix-Spam-Score":"-1.0","X-Linutronix-Spam-Level":"-","X-Linutronix-Spam-Status":"No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,\n\tSHORTCIRCUIT=-0.0001","X-Mailman-Approved-At":"Wed, 30 Aug 2017 16:44:19 +0000","Cc":"u-boot@lists.denx.de, Holger Dengler <dengler@linutronix.de>","Subject":"[U-Boot] [PATCH] cmd: set filesize variable in ubi read","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"After a successful read of a UBI volume, the variable filesize is set\nto the number of read bytes. To boot linux with a raw initramfs/initrd,\nyou must specify the exact size of the initramfs/initrd image in boot\ncommand. If the initramfs/inird is read from UBI volume, $filesize is\nrequired to access the number of read bytes.\n\nExample:\n  ubi read ${loadaddr} kernelvol\n  ubi read ${fdtaddr} dtbvol\n  ubi read ${initrd_addr} initrdvol\n  bootz ${loadaddr} ${initrd_addr}:${filesize} ${fdt_addr}\n\nSigned-off-by: Holger Dengler <dengler@linutronix.de>\n---\n cmd/ubi.c | 5 +++++\n 1 file changed, 5 insertions(+)","diff":"diff --git a/cmd/ubi.c b/cmd/ubi.c\nindex 222be5a357..c49c7f94df 100644\n--- a/cmd/ubi.c\n+++ b/cmd/ubi.c\n@@ -334,6 +334,7 @@ int ubi_volume_read(char *volume, char *buf, size_t size)\n \tunsigned long long tmp;\n \tstruct ubi_volume *vol;\n \tloff_t offp = 0;\n+\tsize_t len_read;\n \n \tvol = ubi_find_volume(volume);\n \tif (vol == NULL)\n@@ -373,6 +374,7 @@ int ubi_volume_read(char *volume, char *buf, size_t size)\n \ttmp = offp;\n \toff = do_div(tmp, vol->usable_leb_size);\n \tlnum = tmp;\n+\tlen_read = size;\n \tdo {\n \t\tif (off + len >= vol->usable_leb_size)\n \t\t\tlen = vol->usable_leb_size - off;\n@@ -398,6 +400,9 @@ int ubi_volume_read(char *volume, char *buf, size_t size)\n \t\tlen = size > tbuf_size ? tbuf_size : size;\n \t} while (size);\n \n+\tif (!size)\n+\t\tsetenv_hex(\"filesize\", len_read);\n+\n \tfree(tbuf);\n \treturn err;\n }\n","prefixes":["U-Boot"]}