From patchwork Tue Jun 11 16:08:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10987657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9A9314BB for ; Tue, 11 Jun 2019 16:08:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB5621FFCA for ; Tue, 11 Jun 2019 16:08:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF22527FA1; Tue, 11 Jun 2019 16:08:50 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 4EB1B1FFCA for ; Tue, 11 Jun 2019 16:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391880AbfFKQIt (ORCPT ); Tue, 11 Jun 2019 12:08:49 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36514 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391878AbfFKQIs (ORCPT ); Tue, 11 Jun 2019 12:08:48 -0400 Received: by mail-wm1-f66.google.com with SMTP id u8so3559031wmm.1; Tue, 11 Jun 2019 09:08:47 -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=13N4Ag9KCv4dGo80Rtk1TpuZs5X9rJWOgPG6ZRw49Qw=; b=YEGRXUMdZb2akUAQHdQ9SgQU97ytflxLVqF7/Co2m9ieD1C7dSwpdI1YldcJwB4c8f +ZWGmbIbmdjzOM8b6TwtcaALHSEdPLb4QZbaMHIoKnSvd/FGBkcED5A1XxkjCyyAn1Mg I8JBvRXL07SaiBJAIvkLuqzidTFgSNIFsmohTNmAaIVEBIhGW6xIdG1Vzj9Xhy+PdC9c KIjZmDBhfoW9MQt7N6eYDhzTs8NDwO+X58pWpw5SdlqiRbrsPatWJ9Rn9lREPyRAH/iL eMMPFjsNckNnWqfXbQN0EvJjlWqjUmVxd8pZ8x4V/cxZ6RXbdqA2wanTv/8JjD/lkZl9 083g== 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=13N4Ag9KCv4dGo80Rtk1TpuZs5X9rJWOgPG6ZRw49Qw=; b=J4cjranJwQaskZfbfTlTSOoOMjKTN1kB9UrQ5v161RomJf5xNVpan/Y6Trw5DUWlGE JIEy10mMG6KpDjGpTLxZDc/7gOqYLcx9glRAb1e81X3fj4xxJj1Yi4bHsJ+AlLSnUPLw 27QqwoxDntOfIjwbUJ5rXk34p73xHu2f5HBKKwlqoq2EF8fZ86h29+Ol7PsR8+nVZ6Sr eUZbL8oX4puus1LggDp+nbpRi+u1J5FQjPip4N1FS7VVd/tOl9FxD70KB3RFZUxZRm0m hdbliQbXOeXbJJ0ChJGYckmy4QeAz+GHkN/eVF/zYii10B5MzjzNWuycazxpRKVfXfqE cUiw== X-Gm-Message-State: APjAAAXO5Sed+bzpS2eQcWuuEp3vFVY86j3onQ2uJAI8ABRZrucZJJAm GvFbfWkQ+/dVuc64j4CV3/o= X-Google-Smtp-Source: APXvYqyY/ioOd7xjQB9mN4O7OIvNiIIgozZIYAzqngnDHyLcTM0d6Za07540a77AIVYRWVh1v/JuUg== X-Received: by 2002:a05:600c:28d:: with SMTP id 13mr6373119wmk.5.1560269326954; Tue, 11 Jun 2019 09:08:46 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id u11sm10942873wrn.1.2019.06.11.09.08.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 09:08:46 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , "Darrick J . Wong" , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 1/3] fstests: print out xfs_io parameter when command fails Date: Tue, 11 Jun 2019 19:08:37 +0300 Message-Id: <20190611160839.14777-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190611160839.14777-1-amir73il@gmail.com> References: <20190611160839.14777-1-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 In _require_xfs_io_command, when command fails for one of the generic reasons, if command was tested with params, print out the params of the failed command. Signed-off-by: Amir Goldstein --- common/rc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/rc b/common/rc index d0aa36a0..85330de2 100644 --- a/common/rc +++ b/common/rc @@ -2084,7 +2084,7 @@ _require_xfs_io_command() local command=$1 shift local param="$*" - local param_checked=0 + local param_checked="" local opts="" local testfile=$TEST_DIR/$$.xfs_io @@ -2101,7 +2101,7 @@ _require_xfs_io_command() ;; "falloc" ) testio=`$XFS_IO_PROG -F -f -c "falloc $param 0 1m" $testfile 2>&1` - param_checked=1 + param_checked="$param" ;; "fpunch" | "fcollapse" | "zero" | "fzero" | "finsert" | "funshare") local blocksize=$(_get_block_size $TEST_DIR) @@ -2119,7 +2119,7 @@ _require_xfs_io_command() fi testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \ -c "fiemap -v $param" $testfile 2>&1` - param_checked=1 + param_checked="$param" ;; "flink") local testlink=$TEST_DIR/$$.link.xfs_io @@ -2159,7 +2159,7 @@ _require_xfs_io_command() fi testio=`$XFS_IO_PROG -f $opts -c \ "pwrite $pwrite_opts $param 0 4k" $testfile 2>&1` - param_checked=1 + param_checked="$pwrite_opts $param" ;; "scrub"|"repair") testio=`$XFS_IO_PROG -x -c "$command probe" $TEST_DIR 2>&1` @@ -2179,19 +2179,19 @@ _require_xfs_io_command() rm -f $testfile 2>&1 > /dev/null echo $testio | grep -q "not found" && \ - _notrun "xfs_io $command support is missing" + _notrun "xfs_io $command $param_checked support is missing" echo $testio | grep -q "Operation not supported\|Inappropriate ioctl" && \ - _notrun "xfs_io $command failed (old kernel/wrong fs?)" + _notrun "xfs_io $command $param_checked failed (old kernel/wrong fs?)" echo $testio | grep -q "Invalid" && \ - _notrun "xfs_io $command failed (old kernel/wrong fs/bad args?)" + _notrun "xfs_io $command $param_checked failed (old kernel/wrong fs/bad args?)" echo $testio | grep -q "foreign file active" && \ - _notrun "xfs_io $command not supported on $FSTYP" + _notrun "xfs_io $command $param_checked not supported on $FSTYP" echo $testio | grep -q "Function not implemented" && \ - _notrun "xfs_io $command support is missing (missing syscall?)" + _notrun "xfs_io $command $param_checked support is missing (missing syscall?)" [ -n "$param" ] || return - if [ $param_checked -eq 0 ]; then + if [ -z "$param_checked" ]; then $XFS_IO_PROG -c "help $command" | grep -q "^ $param --" || \ _notrun "xfs_io $command doesn't support $param" else From patchwork Tue Jun 11 16:08:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10987661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7BB176 for ; Tue, 11 Jun 2019 16:08:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98E211FFCA for ; Tue, 11 Jun 2019 16:08:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D26B28389; Tue, 11 Jun 2019 16:08:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 2CE2F1FFCA for ; Tue, 11 Jun 2019 16:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391882AbfFKQIv (ORCPT ); Tue, 11 Jun 2019 12:08:51 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53413 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391873AbfFKQIu (ORCPT ); Tue, 11 Jun 2019 12:08:50 -0400 Received: by mail-wm1-f66.google.com with SMTP id x15so3573919wmj.3; Tue, 11 Jun 2019 09:08:48 -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=bNFR7niArjzEiYRwqofbjXTdRAsYaLCBdJcgFSYXXD4=; b=fKA9bciDfV4/r1ttJXJ+KD4hFaCvq6DTRa0WuTKQLBhEwbDnnXmVjBW/pnci+hjoM5 1hdRCLzaObug3Po2VsQt12VucdxTpfT04hBjz+o/5zpB+RyS40Yr8eTcpPwf5sn0n+y+ sqcuBUqJMkSKzPR8WWjAfKtoMkmsjFzrEGu6mEb9vfvzK7CwFLa6HgTvNk/E7NlBEj6W qgK7fqI3UXzMXsZz9bxz0owDJvZoNSHY4U/g6XABJPOnmx1khSa1gvmTNYuWkjItGkqO bVSapN4JrOUVThPgL1YJny9tqmwDwchtt+lLkH6H/eEE+VjU5y1WFkrOesInXge4nY0v O8hg== 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=bNFR7niArjzEiYRwqofbjXTdRAsYaLCBdJcgFSYXXD4=; b=GS3Y+AN+7KRbOKCe4fhLwTxmddvw963Xtb+Ibi3kU2B+MAKCaGxIy60reubfHUPmrq 2dOj0sVds7hb90Wvc2Rj6tJALfWUcfMQ/MqkH2DD8tWZXUwWlmQ08OHmfluF60ZsZ4vZ e6B4R7geUvmrEe+6ddpxZUfJZO4fmXcRc2mPhusyWRH6wq2fXdDlb+5YuRLjI6OCl2i+ avY3CXr+AiyjCSt+HpKsYSN6Q0XaH30gthwL9dcyI24TL6pV0rZx98Gt+JjuTNiWYb+k qfsmGwDBEM+qkZPkfRv+07IrbLrL0e1uYBblRHQ6o3MpRJk7XcfbU6VNlujXkKTz3tVg Fp6A== X-Gm-Message-State: APjAAAVfXydmn8LIEpOCD+aepHz64KidpQEgG5P/ygWG1Wnms8zDRspW KTeAwGVH35Ayf59A/bE4IaBs9bD+ X-Google-Smtp-Source: APXvYqyMGGEO3qi1ZZnasj94FoaBEBVq9J76+tgZKUpF0gJEvXyGx9GFjHSe1T9+A2WVSdRigY+ieg== X-Received: by 2002:a7b:cd84:: with SMTP id y4mr19016561wmj.41.1560269328205; Tue, 11 Jun 2019 09:08:48 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id u11sm10942873wrn.1.2019.06.11.09.08.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 09:08:47 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , "Darrick J . Wong" , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 2/3] fstests: check for filesystem FS_IOC_FSSETXATTR support Date: Tue, 11 Jun 2019 19:08:38 +0300 Message-Id: <20190611160839.14777-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190611160839.14777-1-amir73il@gmail.com> References: <20190611160839.14777-1-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 With "_require_xfs_io_command chattr ", check that flag can be set/cleared using FS_IOC_FSSETXATTR ioctl, similar to "_require_chattr " and FS_IOC_SETFLAGS ioctl. Update the documentation and the tests that use "_require_xfs_io_command chattr" to test filesystem support and not only xfs_io support. Signed-off-by: Amir Goldstein --- common/rc | 10 ++++++++++ doc/requirement-checking.txt | 2 +- tests/generic/553 | 3 +-- tests/xfs/260 | 2 +- tests/xfs/431 | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/common/rc b/common/rc index 85330de2..25203bb4 100644 --- a/common/rc +++ b/common/rc @@ -2090,6 +2090,16 @@ _require_xfs_io_command() local testfile=$TEST_DIR/$$.xfs_io local testio case $command in + "chattr") + if [ -z "$param" ]; then + param=s + fi + # Test xfs_io chattr support AND + # filesystem FS_IOC_FSSETXATTR support + testio=`$XFS_IO_PROG -F -f -c "chattr +$param" $testfile 2>&1` + $XFS_IO_PROG -F -f -r -c "chattr -$param" $testfile 2>&1 + param_checked="+$param" + ;; "chproj") testio=`$XFS_IO_PROG -F -f -c "chproj 0" $testfile 2>&1` ;; diff --git a/doc/requirement-checking.txt b/doc/requirement-checking.txt index 1ec04d4b..45d2756b 100644 --- a/doc/requirement-checking.txt +++ b/doc/requirement-checking.txt @@ -69,7 +69,7 @@ _require_xfs_io_command [] switch. For example: _require_xfs_io_command "falloc" - _require_xfs_io_command "chattr" "+/-x" + _require_xfs_io_command "chattr" "x" The first requires that xfs_io support the falloc command and the second that it supports the chattr command and that the chattr command supports diff --git a/tests/generic/553 b/tests/generic/553 index efe25d84..98ef77cc 100755 --- a/tests/generic/553 +++ b/tests/generic/553 @@ -34,9 +34,8 @@ _supported_fs generic rm -f $seqres.full _require_test -_require_chattr i _require_xfs_io_command "copy_range" -_require_xfs_io_command "chattr" +_require_xfs_io_command "chattr" "i" rm -rf $workdir mkdir $workdir diff --git a/tests/xfs/260 b/tests/xfs/260 index ba606998..4956752c 100755 --- a/tests/xfs/260 +++ b/tests/xfs/260 @@ -33,7 +33,7 @@ _supported_os Linux _require_scratch_dax _require_test_program "feature" _require_test_program "t_mmap_dio" -_require_xfs_io_command "chattr" "+/-x" +_require_xfs_io_command "chattr" "x" _require_xfs_io_command "falloc" prep_files() diff --git a/tests/xfs/431 b/tests/xfs/431 index 63b45fd4..febc89d5 100755 --- a/tests/xfs/431 +++ b/tests/xfs/431 @@ -38,7 +38,7 @@ rm -f $seqres.full # Modify as appropriate. _supported_fs xfs _supported_os Linux -_require_xfs_io_command "chattr" +_require_xfs_io_command "chattr" "t" _require_xfs_io_command "fsync" _require_xfs_io_command "pwrite" _require_scratch From patchwork Tue Jun 11 16:08:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10987663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BA0414BB for ; Tue, 11 Jun 2019 16:08:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C04B1FFCA for ; Tue, 11 Jun 2019 16:08:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 803F927FA1; Tue, 11 Jun 2019 16:08:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 06339276D6 for ; Tue, 11 Jun 2019 16:08:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391881AbfFKQIv (ORCPT ); Tue, 11 Jun 2019 12:08:51 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54323 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391878AbfFKQIv (ORCPT ); Tue, 11 Jun 2019 12:08:51 -0400 Received: by mail-wm1-f67.google.com with SMTP id g135so3574737wme.4; Tue, 11 Jun 2019 09:08:50 -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=Ki6HzX+YKjMEcrusZ5tv0RltwNZY1Y8Nd9PWQp/oxvQ=; b=IVrkk2cM41oEx0eBa0Sra7ZvhoJL1eINYmL6gT4FJqI1OTe7Q2suF9DIhiylFKtMHI yxzqWptNqvCqd0qK6V5+CIsNPoRJGcGDhHBeSyYqZS/BSuq9sEXKBYoaqgYtriobkyAh bW/3KY6BKDRAjjtUP5DHfkVICXcm4thjznvaCu2o3RRACAA2KcFQrdRw4PQtDZf4umtl 0fbpQ1swCZLRkCUzAYEAhNBfgCI0WD+X00apprfHdf+TypNz+Kodvs8pzfnNSJGYU0Vl yEVGtaNv1wijmupEkTKfEqDi9xj3jlrEhTpOkweFnu/aC3Y01BXXSImP0H0IugMR4kNO A7rg== 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=Ki6HzX+YKjMEcrusZ5tv0RltwNZY1Y8Nd9PWQp/oxvQ=; b=BUSbl9gtyzTchJmbR/daLecxfXW0tvtKa6BhGnnDF4jnyU6B08XiHDQW4Ybm2IGGeV b3aJXL6S54yVscBS915Z+KTFgBFjAM4Ob4NLwn+xeqOvsQgh0tUo48vr26seRg5IW8WJ 8OfsXB/FjWGC2akEhWdMLnptWSHEDkKyGlI0EJiNq56V7enYpK2qk++M0TStgATujk62 I6dHpOO/w/5Om/fTpr5jQblpdr3sy5Ehd9DNdvW++U3z96n/OsCmCb8OaYuExnzoMb1I +Vw2gxAyJZ3hAi1e7kwAQrFuGe9LqlmvXM/6pq9ysGFr7LVSdcNgUzrlHTPBktLPp+yr +nuw== X-Gm-Message-State: APjAAAUPIT259f7z4oW0Kf/Phnht2ITRcSiAJHTh+UCKPnfu3VKLOv7D 9kxJVpG4hgz2Mr9YEoouma0= X-Google-Smtp-Source: APXvYqwJIjMAIfL9jy9PjEFI3ZHfj8JzKr1DU5yNKz3ljPT8ChR81N+8z9PZPnHc3Ss2c+d+RzvB3w== X-Received: by 2002:a1c:a7ca:: with SMTP id q193mr19838278wme.150.1560269329490; Tue, 11 Jun 2019 09:08:49 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id u11sm10942873wrn.1.2019.06.11.09.08.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 09:08:48 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , "Darrick J . Wong" , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 3/3] generic: check CAP_LINUX_IMMUTABLE capability with FS_IOC_FSSETXATTR Date: Tue, 11 Jun 2019 19:08:39 +0300 Message-Id: <20190611160839.14777-4-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190611160839.14777-1-amir73il@gmail.com> References: <20190611160839.14777-1-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 This is a flavor of test generic/545 with FS_IOC_FSSETXATTR ioctl instead of FS_IOC_SETFLAGS ioctl. Overlayfs gained support for FS_IOC_FSSETXATTR ioctl in v5.2-rc4 with buggy capability check. This change fixed the problem: ovl: fix wrong flags check in FS_IOC_FS[SG]ETXATTR ioctls Signed-off-by: Amir Goldstein --- tests/generic/555 | 74 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/555.out | 9 ++++++ tests/generic/group | 1 + 3 files changed, 84 insertions(+) create mode 100755 tests/generic/555 create mode 100644 tests/generic/555.out diff --git a/tests/generic/555 b/tests/generic/555 new file mode 100755 index 00000000..e100da97 --- /dev/null +++ b/tests/generic/555 @@ -0,0 +1,74 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2019 CTERA Networks. All Rights Reserved. +# +# FS QA Test No. 555 +# +# Check that we can't set FS_XFLAG_APPEND and FS_XFLAG_IMMUTABLE inode +# flags without capbility CAP_LINUX_IMMUTABLE. +# +# This test uses xfs_io chattr, rather than the (e2fsprogs) chattr +# program to exercise the FS_IOC_FSSETXATTR ioctl. +# +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() +{ + # Cleanup of flags on both file in case test is aborted + # (i.e. CTRL-C), so we have no immutable/append-only files + $XFS_IO_PROG -f -r -c "chattr -ia" $workdir/file1 >/dev/null 2>&1 + $XFS_IO_PROG -f -r -c "chattr -ia" $workdir/file2 >/dev/null 2>&1 + + cd / + rm -rf $tmp.* $workdir +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_os Linux +_supported_fs generic + +_require_test +_require_xfs_io_command "chattr" "ia" +_require_command "$CAPSH_PROG" "capsh" + +workdir="$TEST_DIR/test-$seq" +rm -rf $workdir +mkdir $workdir + +echo "Create the original files" +touch $workdir/file1 +touch $workdir/file2 + +do_filter_output() +{ + grep -o "Operation not permitted" +} + +echo "Try to xfs_io chattr +ia with capabilities CAP_LINUX_IMMUTABLE" +$XFS_IO_PROG -f -c "chattr +ia" $workdir/file1 + +echo "Try to xfs_io chattr +ia/-ia without capability CAP_LINUX_IMMUTABLE" +$CAPSH_PROG --drop=cap_linux_immutable -- -c "$XFS_IO_PROG -f -c 'chattr +a' $workdir/file2" 2>&1 | do_filter_output +$CAPSH_PROG --drop=cap_linux_immutable -- -c "$XFS_IO_PROG -f -c 'chattr +i' $workdir/file2" 2>&1 | do_filter_output + +$CAPSH_PROG --drop=cap_linux_immutable -- -c "$XFS_IO_PROG -f -r -c 'chattr -i' $workdir/file1" 2>&1 | do_filter_output +$CAPSH_PROG --drop=cap_linux_immutable -- -c "$XFS_IO_PROG -f -r -c 'chattr -a' $workdir/file1" 2>&1 | do_filter_output + +echo "Try to xfs_io chattr -ia with capability CAP_LINUX_IMMUTABLE" +$XFS_IO_PROG -f -r -c "chattr -ia" $workdir/file1 + +# success, all done +status=0 +exit diff --git a/tests/generic/555.out b/tests/generic/555.out new file mode 100644 index 00000000..c4f989d1 --- /dev/null +++ b/tests/generic/555.out @@ -0,0 +1,9 @@ +QA output created by 555 +Create the original files +Try to xfs_io chattr +ia with capabilities CAP_LINUX_IMMUTABLE +Try to xfs_io chattr +ia/-ia without capability CAP_LINUX_IMMUTABLE +Operation not permitted +Operation not permitted +Operation not permitted +Operation not permitted +Try to xfs_io chattr -ia with capability CAP_LINUX_IMMUTABLE diff --git a/tests/generic/group b/tests/generic/group index 44ce8eff..8262b09c 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -557,3 +557,4 @@ 552 auto quick log 553 auto quick copy_range 554 auto quick copy_range swap +555 auto quick cap