public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ernesto A. Fernández" <ernesto.mnd.fernandez@gmail.com>
To: fstests@vger.kernel.org
Cc: Eryu Guan <guaneryu@gmail.com>
Subject: [RFC PATCH] fstests: add support for hfsplus
Date: Fri, 31 Aug 2018 23:05:03 -0300	[thread overview]
Message-ID: <20180901020503.5i4hz4inqtfd3frg@eaf> (raw)

It is not possible to set file system size when running mkfs.hfsplus,
so use the device mapper as a workaround.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
---
I've been using this to test hfsplus patches. If there's a better way
please let me know.

 common/config |  7 +++++++
 common/rc     | 38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/common/config b/common/config
index 2f1f2720..32a1ccb8 100644
--- a/common/config
+++ b/common/config
@@ -229,6 +229,7 @@ case "$HOSTOS" in
 	export MKFS_CIFS_PROG="false"
 	export MKFS_OVERLAY_PROG="false"
 	export MKFS_REISER4_PROG=$(type -P mkfs.reiser4)
+	export MKFS_HFSPLUS_PROG=$(type -P mkfs.hfsplus)
 	export E2FSCK_PROG=$(type -P e2fsck)
 	export TUNE2FS_PROG=$(type -P tune2fs)
 	export FSCK_OVERLAY_PROG=$(type -P fsck.overlay)
@@ -313,6 +314,9 @@ _mount_opts()
 	ubifs)
 		export MOUNT_OPTIONS=$UBIFS_MOUNT_OPTIONS
 		;;
+	hfsplus)
+		export MOUNT_OPTIONS=$HFSPLUS_MOUNT_OPTIONS
+		;;
 	*)
 		;;
 	esac
@@ -380,6 +384,9 @@ _mkfs_opts()
 	f2fs)
 		export MKFS_OPTIONS="$F2FS_MKFS_OPTIONS"
 		;;
+	hfsplus)
+		export MKFS_OPTIONS=$HFSPLUS_MKFS_OPTIONS
+		;;
 	*)
 		;;
 	esac
diff --git a/common/rc b/common/rc
index ec631ad9..38f61944 100644
--- a/common/rc
+++ b/common/rc
@@ -158,6 +158,9 @@ case "$FSTYP" in
     ubifs)
 	[ "$UBIUPDATEVOL_PROG" = "" ] && _fatal "ubiupdatevol not found"
 	;;
+    hfsplus)
+	 [ "$MKFS_HFSPLUS_PROG" = "" ] && _fatal "mkfs.hfsplus not found"
+	 ;;
 esac
 
 if [ ! -z "$REPORT_LIST" ]; then
@@ -746,6 +749,12 @@ _scratch_mkfs()
 		mkfs_cmd="yes | $MKFS_PROG -t $FSTYP --"
 		mkfs_filter="grep -v -e ^mkfs\.ocfs2"
 		;;
+	hfsplus)
+		mkfs_cmd="yes | $MKFS_PROG -t $FSTYP --"
+		mkfs_filter="cat"
+		# a test may have been interrupted after _scratch_mkfs_sized()
+		rm -f ${RESULT_DIR}/hfsplus_sectors
+		;;
 	*)
 		mkfs_cmd="yes | $MKFS_PROG -t $FSTYP --"
 		mkfs_filter="cat"
@@ -995,6 +1004,17 @@ _scratch_mkfs_sized()
 	fi
 	export MOUNT_OPTIONS="-o size=$fssize $TMPFS_MOUNT_OPTIONS"
 	;;
+    hfsplus)
+	# mkfs.hfsplus does not allow setting the size of the filesystem
+	_require_dm_target linear
+	local sectors=`expr $fssize / 512`
+	local table="0 $sectors linear $SCRATCH_DEV 0"
+	_dmsetup_create hfsplus-tmp --table "$table" || _fatal "dmsetup failed"
+	${MKFS_PROG}.$FSTYP $MKFS_OPTIONS -b $blocksize /dev/mapper/hfsplus-tmp
+	_dmsetup_remove hfsplus-tmp
+	# remember the true size of the filesystem for fsck.hfsplus
+	echo -n $sectors > ${RESULT_DIR}/hfsplus_sectors
+	;;
     *)
 	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_sized"
 	;;
@@ -2661,6 +2681,22 @@ _check_scratch_fs()
     ubifs)
 	# there is no fsck program for ubifs yet
 	;;
+    hfsplus)
+	# fsck.hfsplus will always assume the filesystem fills the device
+	if [ -f ${RESULT_DIR}/hfsplus_sectors ]; then
+	    local sectors=`cat ${RESULT_DIR}/hfsplus_sectors`
+	    rm -f ${RESULT_DIR}/hfsplus_sectors
+	    local table="0 $sectors linear $SCRATCH_DEV 0"
+	    _dmsetup_create hfsplus-tmp --table "$table" || \
+						_fatal "dmsetup failed"
+	    _check_generic_filesystem /dev/mapper/hfsplus-tmp
+	    local fsck_status=$?
+	    _dmsetup_remove hfsplus-tmp
+	    return $fsck_status
+	else
+	    _check_generic_filesystem $device
+	fi
+	;;
     *)
 	_check_generic_filesystem $device
 	;;
@@ -3055,7 +3091,7 @@ _require_metadata_journaling()
 	fi
 
 	case "$FSTYP" in
-	ext2|vfat|msdos|udf)
+	ext2|vfat|msdos|udf|hfsplus)
 		_notrun "$FSTYP does not support metadata journaling"
 		;;
 	ext4)
-- 
2.11.0

             reply	other threads:[~2018-09-01  6:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-01  2:05 Ernesto A. Fernández [this message]
2018-09-01 17:09 ` [RFC PATCH] fstests: add support for hfsplus Eryu Guan
2018-09-02  4:03   ` Ernesto A. Fernández
     [not found]     ` <4445a65e-42b7-5e2e-36fa-45f116f99f33@sandeen.net>
2018-09-02 14:05       ` Eryu Guan
2018-09-02 23:45         ` Ernesto A. Fernández
2018-09-02 23:49         ` Dave Chinner

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=20180901020503.5i4hz4inqtfd3frg@eaf \
    --to=ernesto.mnd.fernandez@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    /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