From patchwork Tue Sep 11 06:58:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 146398 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3310033ljw; Mon, 10 Sep 2018 23:59:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYsW8P93/6YGokGFQ1B1Y7cYAkKAIPaL/ieunFeTxQAFycKUJRrC/2rPRww3zU9rtIyzn2W X-Received: by 2002:a50:f69b:: with SMTP id d27-v6mr26949995edn.103.1536649149533; Mon, 10 Sep 2018 23:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536649149; cv=none; d=google.com; s=arc-20160816; b=UK3cEFpmfh1YoqZgYMPNjh/RQHnoFiJBZzWGeLp20mOzVL63j4e3eGj+EULivwGMDc y0UcMxZUN2fFcPX2yMnQGhun5f1lZvvhy2xSg6HYFqLUx+wvQ7MIXUH08B3r8dvaTcXU pzclDZY5IGZ3KGSOfITvmJIbyjYT6yCnVkMds58O+L6UZ6rLvYlNWeLxUSRrmYhZPJrS 1DXs30KMlpQCZ0gDfftnhQYu85kTVbHoZkBNAW4cYibDYRPYc2rE58a4tbfaeA6Rn+3p fiDhOU/Gp7k2fcQsfW9KlKcPB8tK7/3T+MYwXaZtV5Z+mykFBjL2XnE1DkxcxnjIVWAk yDFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature; bh=LHc4U/1bztjx1Qt1oYLmb3QS1a0rwyQMCt9AD4Zchak=; b=pB4aX4z63JAcMgt2sCFADquCbj61CfT9h83vscfRMZnUy8w+bM4voL+7T0HzVFzBAi bsZR3I3G6CkVflVTWv6O9Z6+Kg9PCjnALG0jL04nzvmZV35sJc9rUBLAsWPiL9dANHk8 Bv6gGhrnXs8pKhYMhTARPZTVVDFcJXiXNw4xEp8g+mdctg/P32e80EceGeSq770llUFS vKyLMwNmIqiiYHese/9QKmS8MwiPYjdahPsIEAHtld2TJV7MqK6yG8053g3d4QUyul6M uuwj1yd5dXthKSGsDD1XTrQ3adW8w1mbjQrj1ylV9GM/7Q3Xd9YlA9cv4MtADUDT5+os iLQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kLBZLLJv; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id q40-v6si1184811edd.107.2018.09.10.23.59.09; Mon, 10 Sep 2018 23:59:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kLBZLLJv; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id D3C20C21E13; Tue, 11 Sep 2018 06:59:07 +0000 (UTC) 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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3A0A5C21E13; Tue, 11 Sep 2018 06:59:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E6F29C21C38; Tue, 11 Sep 2018 06:59:02 +0000 (UTC) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by lists.denx.de (Postfix) with ESMTPS id 3093CC21DFB for ; Tue, 11 Sep 2018 06:58:59 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id t84-v6so9903898pgb.5 for ; Mon, 10 Sep 2018 23:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=/KstwhsJisv4T8VzVXJ6uTlN9HHSt36pB5DKK65hW9k=; b=kLBZLLJv6J00rg6zeV0yaF3pIlAfi5E1zDjTjcHN/ulXGeo0ukCnm3Vrx+qZBTliIa aQDQlDG1qIH0aKuR1v7MmLU31cZAhzGYZX3oURDO0BM3wIs03m6ZiDOL0yLBdtGN41sj Pa3Sg3ufSMOZxCHEyUh4s2A9Q2o8FS7QzykZc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/KstwhsJisv4T8VzVXJ6uTlN9HHSt36pB5DKK65hW9k=; b=CD+bVJrBxGwUgHO1Hr9dqUQacPcbdhXNOQ2UsIU5JdM5hqv/xjhU9amHVOZefMk1wE zVR2YcklifVbQUm/PS4onl7yG4+NMkqkJ2z/iTtXxmi6y64m+HQSBR4LQg/EXKaU0834 yRRridxEVbJn/K9j/bASUnjPWkDqA3JFJAoHEskGTSrl7Mi083OrFtC/2SfY7iJAfKNg jyf2LLUoTy/DDujfxeyHkn1vQDLmuWHlYOds250I2lExrYtkOWhZt2Uqn1FuB0vBskvR HrIC4riO4MegQWBfXrMAQg0Q5KyGZGi9CcPJ4Th7mfK1O5e9Rz+KNRU10V/njlb7y1ek sgRQ== X-Gm-Message-State: APzg51BlSYE3wQXnqHphJt/ZStRbziIDHOyrqCtH47X50EVy0j61wqOO 2f3eoicLbf4uNqg14rTk8ooldw== X-Received: by 2002:a63:c60:: with SMTP id 32-v6mr26693822pgm.155.1536649135787; Mon, 10 Sep 2018 23:58:55 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z17-v6sm27160468pfl.146.2018.09.10.23.58.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 23:58:54 -0700 (PDT) From: "Akashi, Takahiro" To: trini@konsulko.com Date: Tue, 11 Sep 2018 15:58:56 +0900 Message-Id: <20180911065922.19141-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 Cc: u-boot@lists.denx.de, xypron.glpk@gmx.de, agraf@suse.de Subject: [U-Boot] [PATCH v3 00/26] subject: fs: fat: extend FAT write operations X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch series[1] is an attempt to address FAT write related issues in an effort of running UEFI SCT (Self-Certification Test) to verify UEFI support on u-boot. SCT is a test platform as well as an extensive collection of test cases for UEFI specification. It can run all the tests automatically and save test results to dedicated log files. AFAIK, what's missing in the current fat file system to safely run SCT without errors (I don't mean test case failures) are: * write a file located under sub-directories * write a file with non-zero offset * delete a file * create a directory What's more, this series contains a file system test; "basic" test is directly derived from test/test-fs.sh. The others, "ext" and "mkdir," are solely for newly added functionality in this patch series. Patch#1 to patch#7 are some sort of preparatory ones. Patch#8 implements write with sub-directories path. Patch#9 to patch#11 implement write with non-zero offset. Patch#12 to patch#16 are related to creating a directory. Patch#17 to patch#20 allows for deleting a file or directory. Patch#21 fixes a minor bug in fs-test.sh. Patch#22 updates a test result summary. Patch#23 to patch#26 add a file system test in U-boot pytest suite. I applied this patch series on top of v2018.09-rc along with a couple of yet-to--be-upstreamed UEFI-related patches, and could successfully run unmodified SCT[2] on qemu-arm(arm64). === future TODO list === 1. set creation (,access and modification) time 2. debug() vs. printf() 3. open()'s parameter checks 4. precisely detect and prevent write() beyond out-of-space 5. create an unique short name from a long file name 6. fat32's fsInfo support Without (5) or (6), fsck may issue warnings. [1] https://git.linaro.org/people/takahiro.akashi/u-boot.git fat_write [2] http://uefi.org/testtools Changes in v3 (Sep 11, 2018) * remove v2's patch#4 which tries to make iterator symbols global * add unlink operation along with a pytest script * use guestmount, if available, for non-root user * remove all the filesystem images created in tests Changes in v2 (Sep 4, 2018) * guard the whole content of fat.h with CONFIG_FS_FAT against a compiler warning * determine total_sect in struct fsdata correctly, depending on fat type (12/16 or 32) * explicitly revert "fs: fat: cannot write to subdirectories" * add test scripts with pytest, mostly the same as RFC, but removing "sudo" for ext4 case AKASHI Takahiro (25): fs: fat: guard the content of include/fat.h fs: fat: extend get_fs_info() for write use fs: fat: handle "." and ".." of root dir correctly with fat_itr_resolve() fs: fat: assure iterator's ->dent belongs to ->clust Revert "fs: fat: cannot write to subdirectories" fs: fat: check and normalize file name fs: fat: write returns error code instead of -1 fs: fat: support write with sub-directory path fs: fat: refactor write interface for a file offset fs: fat: support write with non-zero offset cmd: fat: add offset parameter to fatwrite fs: add mkdir interface fs: fat: remember the starting cluster number of directory fs: fat: support mkdir cmd: fat: add fatmkdir command efi_loader: file: support creating a directory fs: add unlink interface fs: fat: support unlink cmd: fat: add fatrm command efi_loader: implement a file delete fs-test: fix false positive error at Test Case 12 fs-test: update the test result as of v2018.09 test/py: convert fs-test.sh to pytest test/py: fs: add extended write operation test test/py: fs: add fstest/mkdir test Akashi, Takahiro (1): test/py: fs: add fstest/unlink test cmd/fat.c | 34 +- fs/fat/fat.c | 65 +- fs/fat/fat_write.c | 1183 +++++++++++++++++--------- fs/fs.c | 87 ++ include/fat.h | 7 + include/fs.h | 22 + lib/efi_loader/efi_file.c | 28 +- test/fs/fs-test.sh | 24 +- test/py/tests/test_fs/conftest.py | 392 +++++++++ test/py/tests/test_fs/fstest_defs.py | 13 + test/py/tests/test_fs/test_basic.py | 287 +++++++ test/py/tests/test_fs/test_ext.py | 224 +++++ test/py/tests/test_fs/test_mkdir.py | 112 +++ test/py/tests/test_fs/test_unlink.py | 109 +++ 14 files changed, 2136 insertions(+), 451 deletions(-) create mode 100644 test/py/tests/test_fs/conftest.py create mode 100644 test/py/tests/test_fs/fstest_defs.py create mode 100644 test/py/tests/test_fs/test_basic.py create mode 100644 test/py/tests/test_fs/test_ext.py create mode 100644 test/py/tests/test_fs/test_mkdir.py create mode 100644 test/py/tests/test_fs/test_unlink.py