Skip to content

Commit a7a193b

Browse files
committed
Encapsulate FAT filesystem detection in FilesystemType.is_fat()
1 parent 70a9797 commit a7a193b

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

archinstall/lib/bootloader/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
from pathlib import Path
44

55
from archinstall.lib.models.bootloader import Bootloader, BootloaderConfiguration
6-
from archinstall.lib.models.device import DiskLayoutConfiguration, FilesystemType
7-
8-
_FAT_FILESYSTEMS = (FilesystemType.FAT12, FilesystemType.FAT16, FilesystemType.FAT32)
6+
from archinstall.lib.models.device import DiskLayoutConfiguration
97

108

119
class BootloaderValidationFailureKind(Enum):
@@ -39,7 +37,7 @@ def validate_bootloader_layout(
3937

4038
# Limine reads its config and kernels from the boot partition, which
4139
# must be FAT.
42-
if boot_part and boot_part.fs_type not in _FAT_FILESYSTEMS:
40+
if boot_part and (boot_part.fs_type is None or not boot_part.fs_type.is_fat()):
4341
return BootloaderValidationFailure(
4442
kind=BootloaderValidationFailureKind.LimineNonFatBoot,
4543
description='Limine does not support booting with a non-FAT boot partition.',

archinstall/lib/disk/device_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def format(
250250
case FilesystemType.EXT2 | FilesystemType.EXT3 | FilesystemType.EXT4:
251251
# Force create
252252
options.append('-F')
253-
case FilesystemType.FAT12 | FilesystemType.FAT16 | FilesystemType.FAT32:
253+
case _ if fs_type.is_fat():
254254
mkfs_type = 'fat'
255255
# Set FAT size
256256
options.extend(('-F', fs_type.value.removeprefix(mkfs_type)))

archinstall/lib/global_menu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from archinstall.lib.models.application import ApplicationConfiguration, ZramConfiguration
1919
from archinstall.lib.models.authentication import AuthenticationConfiguration
2020
from archinstall.lib.models.bootloader import Bootloader, BootloaderConfiguration
21-
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, FilesystemType, PartitionModification
21+
from archinstall.lib.models.device import DiskLayoutConfiguration, DiskLayoutType, PartitionModification
2222
from archinstall.lib.models.locale import LocaleConfiguration
2323
from archinstall.lib.models.mirrors import MirrorConfiguration
2424
from archinstall.lib.models.network import NetworkConfiguration, NicType
@@ -487,7 +487,7 @@ def _validate_bootloader(self) -> str | None:
487487
if efi_partition is None:
488488
return 'EFI system partition (ESP) not found'
489489

490-
if efi_partition.fs_type not in [FilesystemType.FAT12, FilesystemType.FAT16, FilesystemType.FAT32]:
490+
if efi_partition.fs_type is None or not efi_partition.fs_type.is_fat():
491491
return 'ESP must be formatted as a FAT filesystem'
492492

493493
if bootloader == Bootloader.Refind and not self._uefi:

archinstall/lib/models/device.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,9 @@ class FilesystemType(StrEnum):
802802
def is_crypto(self) -> bool:
803803
return self == FilesystemType.CRYPTO_LUKS
804804

805+
def is_fat(self) -> bool:
806+
return self in (FilesystemType.FAT12, FilesystemType.FAT16, FilesystemType.FAT32)
807+
805808
@property
806809
def parted_value(self) -> str:
807810
return self.value + '(v1)' if self == FilesystemType.LINUX_SWAP else self.value

0 commit comments

Comments
 (0)