]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
common/rc: introduce _overlay_mount_dirs helper
authorEryu Guan <eguan@redhat.com>
Tue, 9 Aug 2016 07:28:47 +0000 (15:28 +0800)
committerEryu Guan <eguan@redhat.com>
Thu, 8 Sep 2016 05:54:43 +0000 (13:54 +0800)
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>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc
tests/overlay/005
tests/overlay/010

index 04039a42168c08fc8a9b703518f18c8cfecf12fb..899bef49c61e346c503027737b855aff758df8d3 100644 (file)
--- 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 \
+                           $SELINUX_MOUNT_OPTIONS $* $dir $mnt
 }
 
 _overlay_test_mount()
index 495e7b53d093443ee128a32446aed4403a6ea027..baadb6964d707897c2cc81749919a3c0347cc357 100755 (executable)
@@ -93,10 +93,7 @@ $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 $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 \
index 5d1c2bd28db5bf3c2c3d28d72706ca7048127240..a302d749ebccf103d47b5dbb88592391083a5a76 100755 (executable)
@@ -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