[PATCHv2 6/9] common/rc: Add _mkfs_dev_blocksized functionality

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds _mkfs_dev_blocksized functionality.

Signed-off-by: Ritesh Harjani <riteshh@xxxxxxxxxxxxx>
---
 common/rc | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/common/rc b/common/rc
index d4b1f21f..b5fe5c71 100644
--- a/common/rc
+++ b/common/rc
@@ -722,6 +722,53 @@ _mkfs_dev()
     rm -f $tmp.mkfserr $tmp.mkfsstd
 }
 
+_set_mkfs_options_blocksized()
+{
+	local blocksize=$1
+	local re='^[0-9]+$'
+
+	if ! [[ $blocksize =~ $re ]]; then
+		_notrun "error _set_mkfs_options_blocksized: blocksize \"$blocksize\" not an integer"
+	fi
+
+	case $FSTYP in
+	btrfs)
+		test -f /sys/fs/btrfs/features/supported_sectorsizes || \
+		_notrun "Subpage sectorsize support is not found in $FSTYP"
+
+		grep -wq $blocksize /sys/fs/btrfs/features/supported_sectorsizes || \
+		_notrun "$FSTYP does not support sectorsize=$blocksize yet"
+
+		MKFS_OPTIONS=" --sectorsize=$blocksize"
+		;;
+	xfs)
+		MKFS_OPTIONS=" -b size=$blocksize"
+		;;
+	ext2|ext3|ext4)
+		MKFS_OPTIONS=" -b $blocksize"
+		;;
+	gfs2)
+		MKFS_OPTIONS=" -O -b $blocksize"
+		;;
+	ocfs2)
+		MKFS_OPTIONS=" -b $blocksize -C $blocksize"
+		;;
+	bcachefs)
+		MKFS_OPTIONS=" --block_size=$blocksize"
+		;;
+	*)
+		# do nothing for other FS.
+		;;
+	esac
+}
+
+_mkfs_dev_blocksized()
+{
+	_set_mkfs_options_blocksized $1
+	shift
+	_mkfs_dev $*
+}
+
 # remove all files in $SCRATCH_MNT, useful when testing on NFS/CIFS
 _scratch_cleanup_files()
 {
-- 
2.31.1




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux