From e6079c42ea48a401b4ef61eb103b3a0fba15a820 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 28 Apr 2022 16:05:01 +0200 Subject: live: detect cache partitions in new refresh Detects OpenGnsys cache partition when building the partition setup of a live system. OpenGnsys labels a Linux/ext4 partition as "CACHE". --- src/live/ogOperations.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/live/ogOperations.py') diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index c3ede91..a3c3836 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -18,7 +18,7 @@ from src.live.partcodes import GUID_MAP from src.utils.net import ethtool from src.utils.menu import generate_menu from src.utils.fs import mount_mkdir, umount, get_usedperc -from src.utils.probe import os_probe +from src.utils.probe import os_probe, cache_probe from src.utils.disk import get_disks @@ -49,10 +49,12 @@ class OgLiveOperations: def _refresh_payload_partition(self, cxt, pa, part_setup, disk): parttype = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_TYPEID) fstype = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_FSTYPE) + padev = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_DEVICE) size = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_SIZE) partnum = pa.partno + 1 - source = f'/dev/{disk}{partnum}' - target = f'/mnt/{disk}{partnum}/' + source = padev + target = padev.replace('dev', 'mnt') + if cxt.label.name == 'gpt': code = GUID_MAP.get(parttype, 0x0) else: @@ -75,6 +77,13 @@ class OgLiveOperations: part_setup['code'] = hex(code)[2:] part_setup['size'] = str(int(size) // 1024) + def _refresh_part_setup_cache(self, cxt, pa, part_setup, cache): + padev = cxt.partition_to_string(pa, fdisk.FDISK_FIELD_DEVICE) + if padev == cache: + part_setup['filesystem'] = 'CACHE' + part_setup['code'] = 'ca' + + def parseGetConf(self, out): parsed = {'serial_number': '', 'disk_setup': list(), @@ -314,6 +323,7 @@ class OgLiveOperations: def refresh(self, ogRest): self._restartBrowser(self._url_log) + cache = cache_probe() disks = get_disks() parsed = { 'serial_number': '', 'disk_setup': [], @@ -334,6 +344,7 @@ class OgLiveOperations: for pa in cxt.partitions: part_setup = part_setup.copy() self._refresh_payload_partition(cxt, pa, part_setup, disk) + self._refresh_part_setup_cache(cxt, pa, part_setup, cache) parsed['partition_setup'].append(part_setup) generate_menu(parsed['partition_setup']) -- cgit v1.2.3-18-g5258