Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk/validators.py
blob: e0ab6a862c02791139cc23ed5b630be869df4035 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def valid_parted_position(pos :str):
	if not len(pos):
		return False

	if pos.isdigit():
		return True

	if pos[-1] == '%' and pos[:-1].isdigit():
		return True

	if pos[-3:].lower() in ['mib', 'kib', 'b', 'tib'] and pos[:-3].replace(".", "", 1).isdigit():
		return True

	if pos[-2:].lower() in ['kb', 'mb', 'gb', 'tb'] and pos[:-2].replace(".", "", 1).isdigit():
		return True

	return False

def valid_fs_type(fstype :str) -> bool:
	# https://www.gnu.org/software/parted/manual/html_node/mkpart.html
	# Above link doesn't agree with `man parted` /mkpart documentation:
	"""
		fs-type can
		be  one  of  "btrfs",  "ext2",
		"ext3",    "ext4",    "fat16",
		"fat32",    "hfs",     "hfs+",
		"linux-swap",  "ntfs",  "reis‐
		erfs", "udf", or "xfs".
	"""

	return fstype.lower() in [
		"btrfs",
		"ext2",
		"ext3", "ext4", # `man parted` allows these
		"fat16", "fat32",
		"hfs", "hfs+", # "hfsx", not included in `man parted`
		"linux-swap",
		"ntfs",
		"reiserfs",
		"udf", # "ufs", not included in `man parted`
		"xfs", # `man parted` allows this
	]