From patchwork Tue Sep 5 01:24:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9937665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2A67602B6 for ; Tue, 5 Sep 2017 01:24:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0B0C2879E for ; Tue, 5 Sep 2017 01:24:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3B4B28835; Tue, 5 Sep 2017 01:24:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 002822879E for ; Tue, 5 Sep 2017 01:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754087AbdIEBYX (ORCPT ); Mon, 4 Sep 2017 21:24:23 -0400 Received: from mout.gmx.net ([212.227.17.22]:53294 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754066AbdIEBYX (ORCPT ); Mon, 4 Sep 2017 21:24:23 -0400 Received: from localhost.localdomain ([45.32.39.184]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M9fLX-1ddAmD2nZ1-00D23B; Tue, 05 Sep 2017 03:24:19 +0200 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v2] btrfs-progs: test/mkfs: Add test case for rootdir parameter Date: Tue, 5 Sep 2017 10:24:15 +0900 Message-Id: <20170905012415.26687-1-quwenruo.btrfs@gmx.com> X-Mailer: git-send-email 2.13.3 X-Provags-ID: V03:K0:1zXgwtzCdy0nyN90m29DilmQjIvpJji8Z/OhvioQOIrNfA0QIwZ cO+qJ1XFX/8QSIqDLdA5K+IbF4znQFnkV/YrL7y3J+T8rDeaGvL3n07mb0DznR3JDLjvWaM jqURDRTEcj9pOhALkAsP+zevKwxCk87qfGpsqygW8GhN27AIqevVsXJh5l5cZZnDQJPkDU8 RcUqq5ICsNgB2YSrggIMQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:VE3znSUA0Fo=:zHzhuojn5BJfLXbIXuH0EK wKDVpRYehAzQ+tEC6aYSCKkOPCeiHxS4ODAqxBltjJGl/sAKR7R4vfQUn6u0nid3T8eL2zIMZ h17z0K5VT+DmUTO8GMzP1uZXKpYj/GgbfVngPtlVCAadS1VNOYBkJojcU2Juan2myY5emDYYU e5bW5vDKHH6a2clCOFuTE4aQ3NEGVMEkrBIz9n39FMF11SvZRoGvzX3dTqgQnTrAUItepU768 2ubhpF/SIG4b3skbby5swuUgjq/XZhVGcwCSm4RQYBwX1lYr7cagLZah+kVp2NBTvV2OS+2mq HsQS0aR6aYZUrkvTft5Minm2AIO6R4fy9CgAFxBQt/WoIBH7V+uanD3F4zyUgnFniriNKVGRb OYaG8jhgwngNpmmpoh6naJd3wWqAGiJgzuSqZU+jzAh97GYzCvWR6V5KuAYiNohIg13L5adje cgpCVszvx06b1Uua9c3bjPPgaWv6+USpvF3BuU3M8G5txwE8vfxB30U+nGGgurGQEmCHSp+ZO OeWwd7RCWjyULzw18SSiRpWO9C9/CiSfIwJIncGH3QZZAz9GSRkYaIPODIFTjZun2Z3PhANi1 EqPx4/DQgaF+JDMLOVVZ/AFgMpx66EFkkvVDzUhbtPCytdhSshvi1aj5t4Vb67wlZ/q9YFdPi uwHqHZpg8tHFOVuiCfBcxDKiXTeG9XptCWfPxDklTkpBhxoBbc/Qc7KN2lQcyqmdDH2XF4Y/H jH1XJN6tv6Oixdzt8zJjTfgFsRLxDEdeJIhAFKmr/fruLuuuszxT/6A+rMWYxsQVWyFB3MvE6 Rkm2ld+B/0rI9o/7bwdCShGQD6SJQ== Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add test case which checks if -r|--rootdir mount option can handle softlink/char/block/fifo files. Signed-off-by: Qu Wenruo --- changelog: v2: Use mktemp instead of $$ Use default test device size Remove unnecessary global prereq for basic tools like mkdir Put option before parameter for rm command All suggested by David. --- .../009-special-files-for-rootdir/test.sh | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 tests/mkfs-tests/009-special-files-for-rootdir/test.sh diff --git a/tests/mkfs-tests/009-special-files-for-rootdir/test.sh b/tests/mkfs-tests/009-special-files-for-rootdir/test.sh new file mode 100755 index 00000000..3cf91dee --- /dev/null +++ b/tests/mkfs-tests/009-special-files-for-rootdir/test.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Check if --rootdir can handle special files (socket/fifo/char/block) correctly +# +# --rootdir had a problem of filling dir items/indexes with wrong type +# and caused btrfs check to report such error + +source "$TOP/tests/common" + +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper # For mknod +prepare_test_dev + +# mknod can create FIFO/CHAR/BLOCK file but not SOCK. +# No neat tool to create socket file, unless using python or similar. +# So no SOCK is tested here +check_global_prereq mknod + +# Also check regular file +check_global_prereq dd + +tmp=$(mktemp -d --tmpdir btrfs-progs-mkfs.rootdirXXXXXXX) + +run_check mkdir $tmp/dir +run_check mkdir -p $tmp/dir/in/dir +run_check mknod $tmp/fifo p +run_check $SUDO_HELPER mknod $tmp/char c 1 1 +run_check $SUDO_HELPER mknod $tmp/block b 1 1 +run_check dd if=/dev/zero bs=1M count=1 of=$tmp/regular + +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -r "$tmp" $TEST_DEV + +rm -rf "$tmp" + +run_check $SUDO_HELPER "$TOP/btrfs" check $TEST_DEV