From patchwork Sun Feb 12 20:43:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9568509 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 19DD360476 for ; Sun, 12 Feb 2017 20:44:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B2FB281C3 for ; Sun, 12 Feb 2017 20:44:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0005528249; Sun, 12 Feb 2017 20:43:59 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 A249A281C3 for ; Sun, 12 Feb 2017 20:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750999AbdBLUn7 (ORCPT ); Sun, 12 Feb 2017 15:43:59 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:32918 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751278AbdBLUn6 (ORCPT ); Sun, 12 Feb 2017 15:43:58 -0500 Received: by mail-wr0-f194.google.com with SMTP id i10so21474093wrb.0; Sun, 12 Feb 2017 12:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=04NJMlEPSzF4y9OrVZ4P0S9QYCoGbduyQQEJfkVm98k=; b=et+9VJSbN80uYfpO9kTySb4RGXQ3vWJUEwOIJoNDCwigx/IDbUhRVoNEZv/SWK1BCu /MMioKudRPLxzIudQW0daOfaB6O2Ju2fAnVdcIGV1nqdM2cOcGh850mGQALhWdFHdzcx hVxhzLR3Iv8mABAWDK7T58c2stb/RI2Adtzs78GCzs+u9xFQgQLsjslNsvt2wLxzifdF RvrFxFnof0l0bHWcoi+bv5FPV+KzCrJVORk0zCKaSLDPnhMzIUMVr+CyAt4Oa7om3ikb vY7+/uthOQWY/gJmPsQa/+RstBXU8ozXqXmm8W5wEET9yZI56rrJerkHZbxyH+9/Ofk/ 3zcA== 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:in-reply-to :references; bh=04NJMlEPSzF4y9OrVZ4P0S9QYCoGbduyQQEJfkVm98k=; b=jpK7beYQv+QS7UI9AweXrXlahYG783wZ5EZcz+SQ+5sa99AEzpJYfhJnBCvw8YSHBV X4V4qCPe2O2E38+qy0iI4ZqRSei6XZCdf+Y9Zn2ly/NQDwiark1n844UrU07VakrZIO8 SKkkfKdfF8FDTbH4+VtPTOQPEFVSKbIhOzBUomJdBMeXxa6+q7r94S3lEhN7FwazoZeB mehlB8tLdrpwO8YI+z528CFRrho7mYUedG20fPFc0CqlDIfey2jJTwoLNG006iNbzjwA BmO5v0mY3tJwzH+Jyrh/P5cu+GeB/NTf7i8W0tTsSqU2fmHwpwIAK7p1pAUN0iIgdXbG 0L9Q== X-Gm-Message-State: AMke39lY6kwIZB8EFaFP2vMNCr0ChmsPpJ74vsQt3lAN4zKxMrgEWFWHRm4RHxOOiOFCrQ== X-Received: by 10.223.165.1 with SMTP id i1mr16564420wrb.82.1486932237066; Sun, 12 Feb 2017 12:43:57 -0800 (PST) Received: from localhost.localdomain (bzq-79-176-143-83.red.bezeqint.net. [79.176.143.83]) by smtp.gmail.com with ESMTPSA id o59sm8040404wrc.56.2017.02.12.12.43.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Feb 2017 12:43:56 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v3 3/9] fstests: canonicalize mount points on every config section Date: Sun, 12 Feb 2017 22:43:38 +0200 Message-Id: <1486932224-17075-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486932224-17075-1-git-send-email-amir73il@gmail.com> References: <1486932224-17075-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create helper _canonicalize_mountpoint() to check and canonicalize a mount point path. Use helper to canonicalize TEST_DIR and SCRATCH_MNT after parse of every config section. This is needed for overlay base fs mount. Signed-off-by: Amir Goldstein --- common/config | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/common/config b/common/config index fa89f42..bfd6429 100644 --- a/common/config +++ b/common/config @@ -454,6 +454,20 @@ _check_device() fi } +# check and return a canonical mount point path +_canonicalize_mountpoint() +{ + local name=$1 + local dir=$2 + + if [ ! -d "$dir" ]; then + _fatal "common/config: $name ($dir) is not a directory" + fi + + # this follows symlinks and removes all trailing "/"s + readlink -e "$dir" +} + # Parse config section options. This function will parse all the configuration # within a single section which name is passed as an argument. For section # name format see comments in get_config_sections(). @@ -542,10 +556,7 @@ get_next_config() { fi _check_device TEST_DEV required $TEST_DEV - if [ ! -d "$TEST_DIR" ]; then - echo "common/config: Error: \$TEST_DIR ($TEST_DIR) is not a directory" - exit 1 - fi + export TEST_DIR=`_canonicalize_mountpoint TEST_DIR $TEST_DIR` # a btrfs tester will set only SCRATCH_DEV_POOL, we will put first of its dev # to SCRATCH_DEV and rest to SCRATCH_DEV_POOL to maintain the backward compatibility @@ -560,10 +571,7 @@ get_next_config() { fi _check_device SCRATCH_DEV optional $SCRATCH_DEV - if [ ! -z "$SCRATCH_MNT" -a ! -d "$SCRATCH_MNT" ]; then - echo "common/config: Error: \$SCRATCH_MNT ($SCRATCH_MNT) is not a directory" - exit 1 - fi + export SCRATCH_MNT=`_canonicalize_mountpoint SCRATCH_MNT $SCRATCH_MNT` if [ -n "$USE_EXTERNAL" ]; then _check_device TEST_RTDEV optional $TEST_RTDEV @@ -590,12 +598,12 @@ if [ -z "$CONFIG_INCLUDED" ]; then [ -z "$TEST_FS_MOUNT_OPTS" ] && _test_mount_opts [ -z "$MKFS_OPTIONS" ] && _mkfs_opts [ -z "$FSCK_OPTIONS" ] && _fsck_opts +else + # canonicalize the mount points + # this follows symlinks and removes all trailing "/"s + export TEST_DIR=`_canonicalize_mountpoint TEST_DIR $TEST_DIR` + export SCRATCH_MNT=`_canonicalize_mountpoint SCRATCH_MNT $SCRATCH_MNT` fi -# canonicalize the mount points -# this follows symlinks and removes all trailing "/"s -export TEST_DIR=`readlink -e "$TEST_DIR"` -export SCRATCH_MNT=`readlink -e "$SCRATCH_MNT"` - # make sure this script returns success /bin/true