From patchwork Tue Jul 11 19:52:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9835439 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 4BEB5602A0 for ; Tue, 11 Jul 2017 19:52:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C75828553 for ; Tue, 11 Jul 2017 19:52:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 313E82856A; Tue, 11 Jul 2017 19:52:03 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 B5EF128553 for ; Tue, 11 Jul 2017 19:52:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933427AbdGKTwC (ORCPT ); Tue, 11 Jul 2017 15:52:02 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34818 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934185AbdGKTwB (ORCPT ); Tue, 11 Jul 2017 15:52:01 -0400 Received: by mail-wr0-f196.google.com with SMTP id z45so624442wrb.2; Tue, 11 Jul 2017 12:52:00 -0700 (PDT) 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=XZWGRa2kyQgz2XjTE/u6VrkGWLquyiY4mp+a7xkN6tM=; b=SQjpLKtv3iY7+b+RvSFJKp24WCJTaOK8eK+j9b9l1/a/GfWNW5xOU+chfOvzvFzP0z bcVnv1ZPkjsK+Y4DPaH0OYu2yulW+ZaLkXGR+IsUmGTzPbazjHugXSLsG8DIp6S4GN0M fehhcSMPxODYWenv4bDlTI8H1V/afrCB9YhCJu12XjWLGpe8GnGmCf7iwAjoocgCwu6b vNeKQ/OPpVW3BHwCKFbwc9Jbsxc/Za8etdG6oHjEFf3Cy98GLpfdA4G++5LY25CzeD2W Pdtzv/S2AAhFlrrxE1liMDbCsL+48zKl9e4Tc3QrRsC/EJYP3iXaq6FMiApoang6n613 wc3A== 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=XZWGRa2kyQgz2XjTE/u6VrkGWLquyiY4mp+a7xkN6tM=; b=hdagiIRPEagdKJseaMGTm3oUyI50rRT4BX0ApKw0tJIfC2VBVReFjM7dXfQIT3M9ga i46pa7IJmPi6aPKyVNBORUXSvrsiK3TOs5UF3CrZOXjQMqJx7Cwc/205qipnQgjqlgxM 9XztzCT87fYfp2yS82rFaRDslORLDj5cOW9q5OagYmAr/AtT/og/OyqRG0c6InV+Z1nh vGpr1rAAWKZ6XbyEQQoBgVmH9A+ZEuR2HX/NvkinQ7amYXO0VYLNOlLGrBaLXcler0gn +B8K0VCW7mytHKb5AoYzZFjewvp60hs4M/U5EpgYbYtwvtGe6n+CEQZfDKx+lRnhfZwL 9RxA== X-Gm-Message-State: AIVw1113QmuEcG7pJWObMl5VXktgV5Cskh0k7lMHcIvOAdBHnFbQKnk/ HfA+tU2ZJfUWIhql X-Received: by 10.28.0.6 with SMTP id 6mr27443wma.37.1499802719670; Tue, 11 Jul 2017 12:51:59 -0700 (PDT) Received: from localhost.localdomain (bzq-79-182-137-119.red.bezeqint.net. [79.182.137.119]) by smtp.gmail.com with ESMTPSA id q2sm302581wmg.3.2017.07.11.12.51.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Jul 2017 12:51:59 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 4/5] overlay: test cases that force read-only mount Date: Tue, 11 Jul 2017 22:52:05 +0300 Message-Id: <1499802726-11045-5-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499802726-11045-1-git-send-email-amir73il@gmail.com> References: <1499802726-11045-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 - Mount with no upper dir - Failure to create work dir Verify that overlay is mounted read-only and that it cannot be remounted rw. Signed-off-by: Amir Goldstein --- tests/overlay/035 | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/035.out | 5 +++ tests/overlay/group | 1 + 3 files changed, 93 insertions(+) create mode 100755 tests/overlay/035 create mode 100644 tests/overlay/035.out diff --git a/tests/overlay/035 b/tests/overlay/035 new file mode 100755 index 0000000..e3fbed7 --- /dev/null +++ b/tests/overlay/035 @@ -0,0 +1,87 @@ +#! /bin/bash +# FS QA Test 035 +# +# Test cases that force read-only mount +# +# - No upper dir +# - Failure to create work dir +# +#----------------------------------------------------------------------- +# Copyright (C) 2017 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + $CHATTR_PROG -i $workdir + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch +_require_chattr i + +# Remove all files from previous tests +_scratch_mkfs + +# Create multiple lowerdirs and upperdir, workdir +lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1 +lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2 +upperdir=$OVL_BASE_SCRATCH_MNT/upper +workdir=$OVL_BASE_SCRATCH_MNT/workdir +mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir + +# Mount overlay with lower layers only. +# Verify that overlay is mounted read-only and that it cannot be remounted rw. +$MOUNT_PROG -t overlay -o"lowerdir=$lowerdir2:$lowerdir1" \ + $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch +$MOUNT_PROG $SCRATCH_MNT -o"remount,rw" 2>&1 | _filter_scratch +$UMOUNT_PROG $SCRATCH_MNT + +# Make workdir immutable to prevent workdir re-create on mount +$CHATTR_PROG +i $workdir + +# Mount overlay with upper and wordir and expect failure to re-create workdir. +# Verify that overlay is mounted read-only and that it cannot be remounted rw. +_overlay_mount_dirs $lowerdir2 $upperdir $workdir \ + $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT +touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch +$MOUNT_PROG $SCRATCH_MNT -o"remount,rw" 2>&1 | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/overlay/035.out b/tests/overlay/035.out new file mode 100644 index 0000000..5a5f677 --- /dev/null +++ b/tests/overlay/035.out @@ -0,0 +1,5 @@ +QA output created by 035 +touch: cannot touch 'SCRATCH_MNT/foo': Read-only file system +mount: cannot remount SCRATCH_DEV read-write, is write-protected +touch: cannot touch 'SCRATCH_MNT/bar': Read-only file system +mount: cannot remount SCRATCH_DEV read-write, is write-protected diff --git a/tests/overlay/group b/tests/overlay/group index 356a322..87e3aaf 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -37,3 +37,4 @@ 032 auto quick copyup hardlink 033 auto quick copyup hardlink 034 auto quick copyup hardlink +035 auto quick mount