All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] fstests: _require_chattr() must get an input arg
@ 2017-04-06  5:43 Amir Goldstein
  2017-04-06  5:43 ` [PATCH v3 2/3] generic/079: use _require_test_program Amir Goldstein
  2017-04-06  5:43 ` [PATCH v3 3/3] overlay/030: test immutable and append-only upper files Amir Goldstein
  0 siblings, 2 replies; 4+ messages in thread
From: Amir Goldstein @ 2017-04-06  5:43 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Miklos Szeredi, Xiong Zhou, linux-unionfs, fstests

_require_chattr() was never intended to be called without an input
argument (specifiying the required attribute to set).

However, calling it without input arguments did work and error
was silently discarded into full test output.

Fix the function to abort on missing input argument and fix the
only test that called _require_chattr() with no input argument.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 common/rc         | 25 ++++++++++++++-----------
 tests/generic/079 |  2 +-
 tests/overlay/027 |  2 +-
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/common/rc b/common/rc
index e1ab2c6..ae3add3 100644
--- a/common/rc
+++ b/common/rc
@@ -3134,18 +3134,21 @@ _require_test_lsattr()
 
 _require_chattr()
 {
-    attribute=$1
-
-    touch $TEST_DIR/syscalltest
-    chattr "+$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
-    status=$?
-    chattr "-$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
-    if [ "$status" -ne 0 ]; then
-      _notrun "file system doesn't support chattr +$attribute"
-    fi
-    cat $TEST_DIR/syscalltest.out >> $seqres.full
+	if [ -z "$1" ]; then
+		echo "Usage: _require_chattr <attr>"
+		exit 1
+	fi
+	local attribute=$1
 
-    rm -f $TEST_DIR/syscalltest.out
+	touch $TEST_DIR/syscalltest
+	chattr "+$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+	status=$?
+	chattr "-$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1
+	if [ "$status" -ne 0 ]; then
+		_notrun "file system doesn't support chattr +$attribute"
+	fi
+	cat $TEST_DIR/syscalltest.out >> $seqres.full
+	rm -f $TEST_DIR/syscalltest.out
 }
 
 _get_total_inode()
diff --git a/tests/generic/079 b/tests/generic/079
index 5cceeba..97b4812 100755
--- a/tests/generic/079
+++ b/tests/generic/079
@@ -48,7 +48,7 @@ _cleanup()
 _supported_fs generic
 _supported_os Linux
 
-_require_chattr i
+_require_chattr ia
 _require_scratch
 
 [ -x $timmutable ] || _notrun "t_immutable was not built for this platform"
diff --git a/tests/overlay/027 b/tests/overlay/027
index 10111b7..90da4e7 100755
--- a/tests/overlay/027
+++ b/tests/overlay/027
@@ -57,7 +57,7 @@ rm -f $seqres.full
 _supported_fs overlay
 _supported_os Linux
 _require_scratch
-_require_chattr
+_require_chattr i
 
 # Remove all files from previous tests
 _scratch_mkfs
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/3] generic/079: use _require_test_program
  2017-04-06  5:43 [PATCH v3 1/3] fstests: _require_chattr() must get an input arg Amir Goldstein
@ 2017-04-06  5:43 ` Amir Goldstein
  2017-04-06  5:43 ` [PATCH v3 3/3] overlay/030: test immutable and append-only upper files Amir Goldstein
  1 sibling, 0 replies; 4+ messages in thread
From: Amir Goldstein @ 2017-04-06  5:43 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Miklos Szeredi, Xiong Zhou, linux-unionfs, fstests

use _require_test_program helper and remove unneeded _scratch_unmount
from _cleanup.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/generic/079 | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tests/generic/079 b/tests/generic/079
index 97b4812..c2db6bf 100755
--- a/tests/generic/079
+++ b/tests/generic/079
@@ -37,7 +37,6 @@ _cleanup()
     cd /
     echo "*** cleaning up"
     $timmutable -r $SCRATCH_MNT/$seq
-    _scratch_unmount
 }
 
 # get standard environment, filters and checks
@@ -49,10 +48,9 @@ _supported_fs generic
 _supported_os Linux
 
 _require_chattr ia
+_require_test_program "t_immutable"
 _require_scratch
 
-[ -x $timmutable ] || _notrun "t_immutable was not built for this platform"
-
 # real QA test starts here
 _scratch_mkfs >/dev/null 2>&1 || _fail "mkfs failed"
 _scratch_mount || _fail "mount failed"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 3/3] overlay/030: test immutable and append-only upper files
  2017-04-06  5:43 [PATCH v3 1/3] fstests: _require_chattr() must get an input arg Amir Goldstein
  2017-04-06  5:43 ` [PATCH v3 2/3] generic/079: use _require_test_program Amir Goldstein
@ 2017-04-06  5:43 ` Amir Goldstein
  2017-04-07  9:15   ` [PATCH v4 4/4] t_immutable: add ftruncate to append only tests Amir Goldstein
  1 sibling, 1 reply; 4+ messages in thread
From: Amir Goldstein @ 2017-04-06  5:43 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Miklos Szeredi, Xiong Zhou, linux-unionfs, fstests

Run the t_immutable test program for immutable/append-only files
and directories in an overlayfs upper directory.

This test is similar and was derived from generic/079, but
the original test is _notrun on overlay mount because FS_IOC_GETFLAGS
FS_IOC_SETFLAGS ioctls fail on overlay directory inodes.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/overlay/030     | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/030.out |  5 ++++
 tests/overlay/group   |  1 +
 3 files changed, 79 insertions(+)
 create mode 100755 tests/overlay/030
 create mode 100644 tests/overlay/030.out

Eryu,

My previous statement that overlayfs does not enforce directory immutable
directory inodes was wrong. The directory tests do pass because overlayfs
does the right thing.

So only failures are for open(O_TRUNC) and truncate() of IS_APPEND
regular file inodes, which shouldn't be too hard to fix:

QA output created by 030
open(/mnt/scratch/ovl-mnt/t_immutable/append-only.f, O_RDWR) did not fail
open(/mnt/scratch/ovl-mnt/t_immutable/append-only.f, O_WRONLY) did not fail
open(/mnt/scratch/ovl-mnt/t_immutable/append-only.f, O_RDWR|O_TRUNC) did not fail
open(/mnt/scratch/ovl-mnt/t_immutable/append-only.f, O_WRONLY|O_TRUNC) did not fail
open(/mnt/scratch/ovl-mnt/t_immutable/append-only.f, O_RDWR|O_APPEND|O_TRUNC) did not fail
open(/mnt/scratch/ovl-mnt/t_immutable/append-only.f, O_WRONLY|O_APPEND|O_TRUNC) did not fail
truncate(/mnt/scratch/ovl-mnt/t_immutable/append-only.f, 0) did not fail
testing immutable...PASS.
testing append-only...FAILED! (7 tests failed)


diff --git a/tests/overlay/030 b/tests/overlay/030
new file mode 100755
index 0000000..bbce140
--- /dev/null
+++ b/tests/overlay/030
@@ -0,0 +1,73 @@
+#! /bin/bash
+# FS QA Test No. 030
+#
+# Run the t_immutable test program for immutable/append-only files
+# and directories in an overlayfs upper directory.
+#
+# This test is similar and was derived from generic/079, but
+# the original test is _notrun on overlay mount because FS_IOC_GETFLAGS
+# FS_IOC_SETFLAGS ioctls fail on overlay directory inodes.
+#
+#-----------------------------------------------------------------------
+# Copyright (C) 2017 CTERA Networks. All Rights Reserved.
+# Author: Amir Goldstein <amir73il@gmail.com>
+#
+# 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`
+timmutable=$here/src/t_immutable
+upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	$timmutable -r $upperdir/t_immutable &> /dev/null
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+_supported_fs overlay
+_supported_os Linux
+
+_require_chattr ia
+_require_test_program "t_immutable"
+_require_scratch
+
+_scratch_mkfs
+
+# Preparing immutable files in uppper dir
+mkdir -p $upperdir
+$timmutable -C $upperdir/t_immutable >$tmp.out 2>&1
+if grep -q -e 'Operation not supported' -e "Inappropriate ioctl" $tmp.out; then
+	_notrun "Setting immutable/append flag not supported"
+fi
+
+_scratch_mount
+
+# Test immutability of files in overlay
+$timmutable $SCRATCH_MNT/t_immutable 2>&1
+status=$?
+exit
diff --git a/tests/overlay/030.out b/tests/overlay/030.out
new file mode 100644
index 0000000..57ba0cd
--- /dev/null
+++ b/tests/overlay/030.out
@@ -0,0 +1,5 @@
+QA output created by 030
+testing immutable...PASS.
+testing append-only...PASS.
+testing immutable as non-root...PASS.
+testing append-only as non-root...PASS.
diff --git a/tests/overlay/group b/tests/overlay/group
index 7e72a30..c5048c4 100644
--- a/tests/overlay/group
+++ b/tests/overlay/group
@@ -32,3 +32,4 @@
 027 auto quick perms
 028 auto copyup quick
 029 auto quick
+030 auto quick perms
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v4 4/4] t_immutable: add ftruncate to append only tests
  2017-04-06  5:43 ` [PATCH v3 3/3] overlay/030: test immutable and append-only upper files Amir Goldstein
@ 2017-04-07  9:15   ` Amir Goldstein
  0 siblings, 0 replies; 4+ messages in thread
From: Amir Goldstein @ 2017-04-07  9:15 UTC (permalink / raw)
  To: Eryu Guan; +Cc: Miklos Szeredi, Xiong Zhou, linux-unionfs, fstests

The truncate and ftruncate syscalls check the IS_APPEND() flag
in 2 different vfs code paths and I had to fix both in order to
fix overlayfs IS_APPEND() violations.

Add the ftruncate test to t_immutable, so overlay/030 can verify
the fix.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 src/t_immutable.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Eryu,

Added another patch to the series.
It stands by itself regardless of test overlay/030, but
together with overlay/030 they provide full coverage of the
kernel fixes I posted.

Amir.

diff --git a/src/t_immutable.c b/src/t_immutable.c
index 8a12d2c..7a7195e 100644
--- a/src/t_immutable.c
+++ b/src/t_immutable.c
@@ -892,6 +892,21 @@ static int test_append(const char *dir)
      }
 
      errno = 0;
+     if ((fd = open(path, O_RDWR|O_APPEND)) == -1) {
+	  fprintf(stderr, "open(%s, O_RDWR|O_APPEND) failed: %s\n", path, strerror(errno));
+	  fail++;
+     } else {
+	     if (ftruncate(fd, 0) != -1) {
+		     fprintf(stderr, "ftruncate(%s, 0) did not fail\n", path);
+		     fail++;
+	     } else if (errno != EPERM) {
+		     fprintf(stderr, "ftruncate(%s, 0) did not set errno == EPERM\n", path);
+		     fail++;
+	     }
+	     close(fd);
+     }
+
+     errno = 0;
      if (truncate(path, 0) != -1) {
 	  fprintf(stderr, "truncate(%s, 0) did not fail\n", path);
 	  fail++;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-07  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06  5:43 [PATCH v3 1/3] fstests: _require_chattr() must get an input arg Amir Goldstein
2017-04-06  5:43 ` [PATCH v3 2/3] generic/079: use _require_test_program Amir Goldstein
2017-04-06  5:43 ` [PATCH v3 3/3] overlay/030: test immutable and append-only upper files Amir Goldstein
2017-04-07  9:15   ` [PATCH v4 4/4] t_immutable: add ftruncate to append only tests Amir Goldstein

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.