From patchwork Tue Oct 7 07:49:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 5043761 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9823B9F295 for ; Tue, 7 Oct 2014 07:50:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3BEA20148 for ; Tue, 7 Oct 2014 07:50:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 967642010B for ; Tue, 7 Oct 2014 07:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753035AbaJGHu2 (ORCPT ); Tue, 7 Oct 2014 03:50:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38430 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752794AbaJGHu1 (ORCPT ); Tue, 7 Oct 2014 03:50:27 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s977oN2W024062 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 7 Oct 2014 03:50:23 -0400 Received: from localhost (dhcp12-153.nay.redhat.com [10.66.12.153] (may be forged)) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s977oMRh003566; Tue, 7 Oct 2014 03:50:22 -0400 From: Eryu Guan To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Eryu Guan , Qu Wenruo Subject: [PATCH] btrfs: test mount btrfs subvolume with selinux context Date: Tue, 7 Oct 2014 15:49:09 +0800 Message-Id: <1412668149-16890-1-git-send-email-eguan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_RHS_DOB autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If one subvolume was mounted with selinux context, other subvolumes should be able to be mounted with the same selinux context too. Cc: Qu Wenruo Signed-off-by: Eryu Guan --- Note that this is based on my btrfs stress test patches. [PATCH v5 00/15] xfstests: new btrfs stress test cases tests/btrfs/075 | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/075.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 72 insertions(+) create mode 100755 tests/btrfs/075 create mode 100644 tests/btrfs/075.out diff --git a/tests/btrfs/075 b/tests/btrfs/075 new file mode 100755 index 0000000..b2fd3df --- /dev/null +++ b/tests/btrfs/075 @@ -0,0 +1,69 @@ +#! /bin/bash +# FSQA Test No. btrfs/075 +# +# If one subvolume was mounted with selinux context, other subvolumes +# should be able to be mounted with the same selinux context too. +# +#----------------------------------------------------------------------- +# Copyright (C) 2014 Red Hat Inc. All rights reserved. +# +# 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 +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* + $UMOUNT_PROG $subvol_mnt >/dev/null 2>&1 +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs btrfs +_supported_os Linux +_require_scratch + +# SELINUX_MOUNT_OPTIONS will be set in common/config if selinux is enabled +if [ "$SELINUX_MOUNT_OPTIONS" == "" ]; then + _notrun "Require selinux to be enabled" +fi + +echo "Silence is golden" + +# first mount default subvolume with selinux context set +_scratch_mkfs +_scratch_mount + +# create a new subvolume and mount it with the same selinux context +subvol_mnt=$TEST_DIR/$seq.mnt +mkdir -p $subvol_mnt +$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol >/dev/null 2>&1 +$MOUNT_PROG -o subvol=subvol $SELINUX_MOUNT_OPTIONS $SCRATCH_DEV $subvol_mnt +status=$? + +exit diff --git a/tests/btrfs/075.out b/tests/btrfs/075.out new file mode 100644 index 0000000..ded801b --- /dev/null +++ b/tests/btrfs/075.out @@ -0,0 +1,2 @@ +QA output created by 075 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index c8ac72c..00ae8ce 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -77,3 +77,4 @@ 072 auto scrub defrag compress 073 auto scrub remount compress 074 auto defrag remount compress +075 auto quick subvol