summaryrefslogtreecommitdiffstats
path: root/src/utils/fstab.py
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-07 13:54:35 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-08 10:07:45 +0200
commite8ddbbd0757efc81fd1fafa3fd98c0bae169bdcb (patch)
tree1ab7b479f9f747ce72d226ba1e209a45b2c75023 /src/utils/fstab.py
parent97c836e0e4a1de72b4020387392ea8564d13dc02 (diff)
src: isolate libfdisk operations to enable mount operationsv1.3.2-20
python-libfdisk does not close file descriptor until the cxt object goes out of scope. Define get_partition_data and get_disk_data functions to isolate the python-libfdisk logic and return the data as an object. Improve error handling of libfdisk operaions in refresh.
Diffstat (limited to 'src/utils/fstab.py')
-rw-r--r--src/utils/fstab.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/fstab.py b/src/utils/fstab.py
index b419aa2..05b94bc 100644
--- a/src/utils/fstab.py
+++ b/src/utils/fstab.py
@@ -158,11 +158,11 @@ def configure_swap(disk, mountpoint, fstab):
swap_entry = entry
diskname = get_disks()[disk-1]
- cxt = fdisk.Context(f'/dev/{diskname}')
+ partitions = get_partition_data(device=f'/dev/{diskname}')
swap_device = ''
- for pa in cxt.partitions:
- if cxt.partition_to_string(pa, fdisk.FDISK_FIELD_FSTYPE) == 'swap':
+ for pa in partitions:
+ if pa.fstype == 'swap':
swap_device = get_formatted_device(disk, pa.partno + 1)
break