From: Amir Goldstein <amir73il@gmail.com>
To: Eryu Guan <eguan@redhat.com>
Cc: Dave Chinner <david@fromorbit.com>,
Christoph Hellwig <hch@infradead.org>,
"Darrick J . Wong" <darrick.wong@oracle.com>,
Miklos Szeredi <miklos@szeredi.hu>,
fstests@vger.kernel.org
Subject: [PATCH v2 1/3] common/rc: factor out _supports_filetype() helper
Date: Tue, 20 Dec 2016 15:17:33 +0200 [thread overview]
Message-ID: <1482239855-791-2-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1482239855-791-1-git-send-email-amir73il@gmail.com>
_overlay_mount_dirs() checks for the filetype feature
on upper dir fs.
factor out that feature test to a helper.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
common/rc | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/common/rc b/common/rc
index 2639fbd..288517f 100644
--- a/common/rc
+++ b/common/rc
@@ -264,6 +264,23 @@ _scratch_mount_options()
$SCRATCH_DEV $SCRATCH_MNT
}
+_supports_filetype()
+{
+ local dir=$1
+ shift 1
+
+ local upper_fst=$(df --output=fstype $dir | tail -1)
+ case "$upper_fst" in
+ xfs)
+ xfs_info $dir | grep -q "ftype=1"
+ ;;
+ ext2|ext3|ext4)
+ tune2fs -l $(df --output=source $dir | tail -1) | \
+ grep -q filetype
+ ;;
+ esac
+}
+
# helper function to do the actual overlayfs mount operation
_overlay_mount_dirs()
{
@@ -284,20 +301,8 @@ _overlay_mount()
local mnt=$2
shift 2
- local upper_fst=$(df --output=fstype $dir | tail -1)
- case "$upper_fst" in
- xfs)
- if ! xfs_info $dir | grep -q "ftype=1" ; then
- _notrun "upper fs needs to support d_type"
- fi
- ;;
- ext2|ext3|ext4)
- if ! tune2fs -l $(df --output=source $dir | tail -1) | \
- grep -q filetype ; then
- _notrun "upper fs needs to support d_type"
- fi
- ;;
- esac
+ _supports_filetype $dir || \
+ _notrun "upper fs needs to support d_type"
mkdir -p $dir/$OVERLAY_UPPER_DIR
mkdir -p $dir/$OVERLAY_LOWER_DIR
--
2.7.4
next prev parent reply other threads:[~2016-12-20 13:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-20 13:17 [PATCH v2 0/3] fstests: dirent file type tests Amir Goldstein
2016-12-20 13:17 ` Amir Goldstein [this message]
2016-12-20 13:17 ` [PATCH v2 2/3] common/rc: add generic file type support check Amir Goldstein
2016-12-20 13:17 ` [PATCH v2 3/3] generic/396: test correct d_type values Amir Goldstein
2016-12-21 13:50 ` [PATCH v3 " Amir Goldstein
2016-12-24 12:20 ` Eryu Guan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1482239855-791-2-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=eguan@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=hch@infradead.org \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox