diff --git a/scripts/wk/clone/ddrescue.py b/scripts/wk/clone/ddrescue.py index 36e15e41..7e34d3d6 100644 --- a/scripts/wk/clone/ddrescue.py +++ b/scripts/wk/clone/ddrescue.py @@ -645,6 +645,11 @@ class State(): # Select source self.source = select_disk_obj('source', disk_menu, docopt_args['']) + if self.source.trim: + cli.print_error('Source device supports TRIM') + cli.print_warning('Continuing recovery is STRONGLY DISADVISED!') + if not cli.ask(' Proceed with recovery?'): + cli.abort() self.ui.set_title('Source', self.source.name) # Select destination diff --git a/scripts/wk/hw/disk.py b/scripts/wk/hw/disk.py index 7b06bbac..4530132f 100644 --- a/scripts/wk/hw/disk.py +++ b/scripts/wk/hw/disk.py @@ -56,6 +56,7 @@ class Disk: size: int = field(init=False) ssd: bool = field(init=False) tests: list[Test] = field(init=False, default_factory=list) + trim: bool = field(init=False) use_sat: bool = field(init=False, default=False) def __post_init__(self): @@ -213,6 +214,7 @@ class Disk: self.serial = self.raw_details.get('serial', 'Unknown Serial') self.size = self.raw_details.get('size', -1) self.ssd = self.raw_details.get('ssd', False) + self.trim = self.raw_details.get('trim', False) # Ensure certain attributes types ## NOTE: This is ugly, deal. @@ -226,6 +228,10 @@ class Disk: if attr == 'size': setattr(self, attr, -1) + # Add TRIM note + if self.trim: + self.add_note('TRIM support detected', 'YELLOW') + # Functions def get_disk_details_linux(disk_path, skip_children=True) -> dict[Any, Any]: @@ -249,10 +255,12 @@ def get_disk_details_linux(disk_path, skip_children=True) -> dict[Any, Any]: dev['bus'] = dev.pop('tran', '???') dev['parent'] = dev.pop('pkname', None) dev['ssd'] = not dev.pop('rota', True) + dev['trim'] = bool(dev.pop('disc-max', 0)) if 'loop' in str(disk_path) and dev['bus'] is None: dev['bus'] = 'Image' dev['model'] = '' dev['serial'] = '' + dev['trim'] = False # NOTE: This check is just for physical devices # Convert to dict details = dev_list.pop(0) @@ -310,6 +318,7 @@ def get_disk_details_macos(disk_path, skip_children=True) -> dict: dev['serial'] = get_disk_serial_macos(dev['path']) dev['size'] = dev.pop('Size', -1) dev['ssd'] = dev.pop('SolidState', False) + dev['trim'] = False # TODO: ACtually check for TRIM dev['vendor'] = '' if dev.get('WholeDisk', True): dev['parent'] = None