From patchwork Tue Sep 4 07:49:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 145851 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3362182ljw; Tue, 4 Sep 2018 00:49:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaUMul1Fsk84nuGPaTo+fbfjvepWWfwKOU5RypHNH839q89pZ/cZYzK8myosOk+xa3FFU/h X-Received: by 2002:aa7:c990:: with SMTP id c16-v6mr34948555edt.165.1536047387169; Tue, 04 Sep 2018 00:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536047387; cv=none; d=google.com; s=arc-20160816; b=NqN24Mu6SPcatye2M32DfoN9UJPzBImxbZInimaz4qtm7DYb8Hr/x4OdmTYriuj0DR ylPyxX3pFjWHX5DlYB1u8emI1kWEs0x8SOJu5NjLDoeAJifBLyg7IYO6WAFVkoeA/301 /sa4tHv0B2KdRfFeYYREzPtWQHj9LGvcfekh3VZlYwhcj7Mqm3LsVZunggo79F0R93O3 7fCb/CAXrv8ZzVYemB0FHjVsNEkctYqR2G1wxJN9mOyljoB0T5VS9RVINNSJdhzf2ffO 5Y1gT/k3NLDXYkFYkPcNtrhXV6TS7qqAkbp/igs8BT2jUS+bNACRAdt40tKkpn83YBcV zdXw== 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:arc-authentication-results; bh=jziJaArSHlIHlgK2u/w/hA311ERDZS5D9TnrN44UsY4=; b=l5o77oW3zBaTX3/e139bHKudy6Dt23WL1z+hLLMYoqSXGVrf0obv13Y61uj0zMf8Sg BRgT09Q32f1SPqflq4TtE7LPRz2GnlAHS7xBtgy6ejTBynn/zE4KOI7SZDT4s5C5Cq0G pASHGRp8DuZlIt4yuS852V+YSfnkWAJmVtJisz/yhwwS30zI4WuAZcU3cJ0gVn1pmPwa i7539BotJ/QEncz/NKEJyAQxsHknSxGwXksG4k03u9QyU4aP+gz5yOoXYTIMZEUvjn3t f/UiovcC7A7sAXt+XasUWgh6JbS04z7wKjm8M5TAMC6YvI12gGWDuOwFzYFhLV5exRna i/qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HKFyYdjT; 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 z6-v6si2392774edk.357.2018.09.04.00.49.46; Tue, 04 Sep 2018 00:49:47 -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=HKFyYdjT; 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 BDF25C21F00; Tue, 4 Sep 2018 07:49:46 +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 22580C21CB1; Tue, 4 Sep 2018 07:49:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1D096C21D8E; Tue, 4 Sep 2018 07:49:42 +0000 (UTC) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by lists.denx.de (Postfix) with ESMTPS id 2829FC21CB1 for ; Tue, 4 Sep 2018 07:49:41 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id x26-v6so1234136pge.12 for ; Tue, 04 Sep 2018 00:49:41 -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=k7y7B6wYdSZgxPJm10IBeyNUqlXoF6K0JKEYJ6+nq5E=; b=HKFyYdjTCvEj85md3vev9gXS8cSBaK4jZfJqXd60FppeOv5XMfWsIy79gp5pMzGK4T baqnkbNyFGBLejIhjOg8q5RBTrorDv4xFWgSnWhp3Pc9LQZgH0JgIr1dLQ30ixHNpHBJ pWC2T+AZZbOlXbnILuD6yE4v8k7jjBCKrLNVc= 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=k7y7B6wYdSZgxPJm10IBeyNUqlXoF6K0JKEYJ6+nq5E=; b=nVkax1DVwj74Kem+6XTMpH++TGiNA5VNCQ8R8nzV7OQp6himURcdWQd+qZBFYmSVYE g46Ry6gmjo3jxKlsgrux7+7P72VETyYpr8VofUoibsmNm2rDCiTGMxDWdFHMrx5QXnLp 7IpNsxqnAlxscSmaXZ1WAO0XgVNwFQrPNYZnpgwGtTgrq7jQ88dAhlD7WZkwjl1HLfG7 EqGUbqKv/T2eYhvnlyEoezYX+hyKLJg/WvVv50xL6nSNDg4kLfE1vBUqk0dlaMHygoFx oumnIAi1B1JIulJSZXIo1zxuRe8r9PknjQ/BLhFH+38QKEukPTpvwO4QiqXStgQ9kxBI DJQA== X-Gm-Message-State: APzg51D36//LMeSKr+00NFOPdmQ6CPFlseaBW17+Q9JoH7qxp4pBDgqc QQOL9sQm/dKIIqAVZC8ytuZQpQ== X-Received: by 2002:a63:c20:: with SMTP id b32-v6mr16921216pgl.400.1536047379572; Tue, 04 Sep 2018 00:49:39 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id i7-v6sm23735930pgs.17.2018.09.04.00.49.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 00:49:39 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Date: Tue, 4 Sep 2018 16:49:25 +0900 Message-Id: <20180904074948.18146-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 Cc: xypron.glpk@gmx.de, agraf@suse.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 00/23] 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 extentisive 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 This patch series addresses all of them and what's more, it contains a file system test; "basic" test is directly derived from test/test-fs.sh. The others, "ext" and "mkdir," are soly for newly added functionality in this patch series. Patch#1 to patch#8 are some sort of preparatory ones. Patch#9 implements write with sub-directories path. Patch#10 to patch#12 implement write with non-zero offset. Patch#13 to patch#17 are related to creating a directory. Patch#18 provides delete, but it doesn't actually delete a file but instead return 0 with purging a file content, which is good enough to run SCT for now. Patch#19 fixes a minor bug in fs-test.sh. Patch#20 updates a test result summary. Patch#21 to patch#23 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 modifcation) 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 7. remove "sudo" in pytest, if possible, for fat* case 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 v2 (Sep 4, 2018) * guard the whole content of fat.h with CONFIG_FS_FAT agaisnt 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 (23): 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: make directory iterator global for write use fs: fat: assure iterator's ->dent belongs to ->clust Revert "fs: fat: cannot write to subdirectories" fs: fat: check and normailze 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 efi_loader: implement a pseudo "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 cmd/fat.c | 22 +- fs/fat/fat.c | 102 +-- fs/fat/fat_write.c | 1063 ++++++++++++++++---------- fs/fs.c | 46 ++ include/fat.h | 40 + include/fs.h | 10 + lib/efi_loader/efi_file.c | 24 +- test/fs/fs-test.sh | 24 +- test/py/tests/test_fs/conftest.py | 331 ++++++++ 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 +++ 13 files changed, 1808 insertions(+), 490 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