summaryrefslogtreecommitdiff
path: root/common/f2fs
blob: 1b39d8cebfc09bbbd80e196a3d941d0ebba3d8c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright 2020 Google LLC

# Require f2fs compression support on the scratch filesystem.
# Optionally, check for support for a specific compression algorithm.
_require_scratch_f2fs_compression()
{
	local algorithm=$1

	_require_scratch

	if [ ! -e /sys/fs/f2fs/features/compression ]; then
		_notrun "Kernel doesn't support f2fs compression"
	fi
	# Note: '-O compression' is only accepted when used in
	# combination with extra_attr.
	if ! _scratch_mkfs -O compression,extra_attr >> $seqres.full; then
		_notrun "f2fs-tools doesn't support compression"
	fi
	if [ -n "$algorithm" ]; then
		if ! _scratch_mount "-o compress_algorithm=$algorithm"; then
			_notrun "Kernel doesn't support $algorithm compression algorithm for f2fs"
		fi
		_scratch_unmount
	fi
}