All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] common/rc: introduce _overlay_mount_dirs helper
@ 2016-08-09 11:16 Eryu Guan
  2016-08-09 11:16 ` [PATCH v2 2/2] overlay: copy-up lowerdir which has opaque xattr set Eryu Guan
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Eryu Guan @ 2016-08-09 11:16 UTC (permalink / raw)
  To: fstests; +Cc: linux-unionfs, Eryu Guan

Introduce a new _overlay_mount_dirs() helper to do the actual
overlay mount operation and factor _overlay_scratch_mount and
_overlay_mount code to use a single implemention of
_overlay_mount_dirs(). Also convert all bare mount of overlay in
tests to use it.

Suggested-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 common/rc         | 21 +++++++++++++++------
 tests/overlay/005 |  6 ++----
 tests/overlay/010 |  5 ++---
 3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/common/rc b/common/rc
index b19b698..6c1c3ff 100644
--- a/common/rc
+++ b/common/rc
@@ -266,6 +266,18 @@ _scratch_mount_options()
 					$SCRATCH_DEV $SCRATCH_MNT
 }
 
+# helper function to do the actual overlayfs mount operation
+_overlay_mount_dirs()
+{
+	local lowerdir=$1
+	local upperdir=$2
+	local workdir=$3
+	shift 3
+
+	$MOUNT_PROG -t overlay -o lowerdir=$lowerdir -o upperdir=$upperdir \
+		    -o workdir=$workdir $*
+}
+
 # Given a dir, set up 3 subdirectories and mount on the given mnt.
 # The dir is used as the mount device so it can be seen from df or mount
 _overlay_mount()
@@ -293,12 +305,9 @@ _overlay_mount()
 	mkdir -p $dir/$OVERLAY_LOWER_DIR
 	mkdir -p $dir/$OVERLAY_WORK_DIR
 
-	$MOUNT_PROG -t overlay $SELINUX_MOUNT_OPTIONS \
-		    -o lowerdir=$dir/$OVERLAY_LOWER_DIR \
-		    -o upperdir=$dir/$OVERLAY_UPPER_DIR \
-		    -o workdir=$dir/$OVERLAY_WORK_DIR   \
-		    $OVERLAY_MOUNT_OPTIONS $* \
-		    $dir $mnt
+	_overlay_mount_dirs $dir/$OVERLAY_LOWER_DIR $dir/$OVERLAY_UPPER_DIR \
+			    $dir/$OVERLAY_WORK_DIR $OVERLAY_MOUNT_OPTIONS $* \
+			    $dir $mnt
 }
 
 _overlay_test_mount()
diff --git a/tests/overlay/005 b/tests/overlay/005
index 495e7b5..522c6f0 100755
--- a/tests/overlay/005
+++ b/tests/overlay/005
@@ -93,10 +93,8 @@ $XFS_IO_PROG -f -c "truncate 48m" ${lowerd}/test_file \
 	>>$seqres.full 2>&1
 
 # mount new overlayfs
-$MOUNT_PROG -t overlay $SELINUX_MOUNT_OPTIONS \
-	    -o lowerdir=$lowerd -o upperdir=$upperd \
-	    -o workdir=$workd \
-	    $SCRATCH_DEV $SCRATCH_MNT
+_overlay_mount_dirs $lowerd $upperd $workd $SELINUX_MOUNT_OPTIONS \
+		    $SCRATCH_DEV $SCRATCH_MNT
 
 # the open call triggers copy-up and it will fail ENOSPC
 $XFS_IO_PROG -f -c "o" ${SCRATCH_MNT}/test_file \
diff --git a/tests/overlay/010 b/tests/overlay/010
index 5d1c2bd..a302d74 100755
--- a/tests/overlay/010
+++ b/tests/overlay/010
@@ -67,9 +67,8 @@ touch $lowerdir1/testdir/a $lowerdir1/testdir/b
 mknod $lowerdir2/testdir/a c 0 0
 
 # Mount overlayfs and remove testdir, which led to kernel crash
-$MOUNT_PROG -t overlay -o lowerdir=$lowerdir2:$lowerdir1 \
-	    -o upperdir=$upperdir,workdir=$workdir \
-	    $SCRATCH_DEV $SCRATCH_MNT
+_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \
+		    $SCRATCH_DEV $SCRATCH_MNT
 rm -rf $SCRATCH_MNT/testdir
 
 # success, all done
-- 
2.7.4

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

end of thread, other threads:[~2016-09-01  3:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-09 11:16 [PATCH 1/2] common/rc: introduce _overlay_mount_dirs helper Eryu Guan
2016-08-09 11:16 ` [PATCH v2 2/2] overlay: copy-up lowerdir which has opaque xattr set Eryu Guan
2016-09-01  0:22   ` Dave Chinner
2016-09-01  3:56     ` Eryu Guan
2016-08-12  3:33 ` [PATCH 1/2] common/rc: introduce _overlay_mount_dirs helper Eryu Guan
2016-08-19  3:05   ` Eryu Guan
2016-08-25  4:11     ` Eryu Guan
2016-08-31  9:44       ` Eryu Guan
2016-09-01  0:16 ` Dave Chinner
2016-09-01  3:33   ` Eryu Guan

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.