aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-04-09 11:55:39 -0700
committerEryu Guan <guaneryu@gmail.com>2018-04-12 21:58:08 +0800
commitd7b767f90586290655c15acb6ba7375efa2236c1 (patch)
tree6bc4ed1a3df9de79afbd1edca04640e689afe81f
parent09c5e9bc89166ad96a22b256756aee9aefc743a7 (diff)
downloadxfstests-dev-d7b767f90586290655c15acb6ba7375efa2236c1.tar.gz
common/config: support f2fs-tools v1.9 and later
Pass the -f option to mkfs.f2fs when it appears to support it. This is required by f2fs-tools v1.9 and later in order to format the filesystem even when an existing filesystem is detected. But earlier versions did not accept this option. mkfs.f2fs doesn't yet have an option to print its version number. So, to detect a new enough version we grep for -f in the help output. This also works for mkfs.btrfs, so we switch that over to the same method rather than grepping for "force overwrite" in the binary. Signed-off-by: Eric Biggers <ebiggers@google.com> Acked-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rw-r--r--common/config17
1 files changed, 11 insertions, 6 deletions
diff --git a/common/config b/common/config
index 20f0e5f372..cc3180694e 100644
--- a/common/config
+++ b/common/config
@@ -94,11 +94,16 @@ set_prog_path()
type -P $1
}
-# Handle mkfs.btrfs which does (or does not) require -f to overwrite
-set_btrfs_mkfs_prog_path_with_opts()
+# Handle mkfs.$fstyp which does (or does not) require -f to overwrite
+set_mkfs_prog_path_with_opts()
{
- p=`set_prog_path mkfs.btrfs`
- if [ "$p" != "" ] && grep -q 'force overwrite' $p; then
+ local fstyp=$1
+ local p=`set_prog_path mkfs.$fstyp`
+
+ # Note: mkfs.f2fs doesn't support the --help option yet, but it doesn't
+ # matter since it also prints the help when an invalid option is given.
+ if [ "$p" != "" ] && \
+ $p --help |& grep -q "[[:space:]]-f[[:space:]|]"; then
echo "$p -f"
else
echo $p
@@ -223,8 +228,8 @@ case "$HOSTOS" in
export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
export MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
export MKFS_UDF_PROG="`set_prog_path mkudffs`"
- export MKFS_BTRFS_PROG="`set_btrfs_mkfs_prog_path_with_opts`"
- export MKFS_F2FS_PROG="`set_prog_path mkfs.f2fs`"
+ export MKFS_BTRFS_PROG="`set_mkfs_prog_path_with_opts btrfs`"
+ export MKFS_F2FS_PROG="`set_mkfs_prog_path_with_opts f2fs`"
export DUMP_F2FS_PROG="`set_prog_path dump.f2fs`"
export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
export BTRFS_SHOW_SUPER_PROG="`set_prog_path btrfs-show-super`"