Skip to content

Commit e840c16

Browse files
committed
Support SD card readers appearing as USB mass storage
The mediacard_combo storage watcher was unable to detect SD card readers that appear as SCSI/USB mass storage devices (/dev/sda) instead of mmcblk devices. This caused insertion tests to timeout. This patch enhances MediacardComboStorage._parse_journal_line() to: - Detect insertions via 'detected capacity change from 0 to X' messages - Detect removals via 'detected capacity change from X to 0' messages - Extract partition names from 'sda: sda1' style journal entries - Label these devices as 'SD/MMC via USB reader' The fix allows the action state to be updated dynamically, properly handling multiple insert/remove cycles even when a card is already inserted at test start. Tested with USB SD card readers that enumerate as /dev/sda devices.
1 parent 364af1a commit e840c16

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

checkbox-support/checkbox_support/scripts/run_watcher.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,30 @@ def _parse_journal_line(self, line_str):
369369
MediacardStorage._parse_journal_line(self, line_str)
370370
USBStorage._parse_journal_line(self, line_str)
371371

372+
# Also handle SD card readers that appear as SCSI/USB mass storage (sd*)
373+
# Check for capacity change patterns first (for action detection)
374+
if (
375+
"detected capacity change from 0 to" in line_str
376+
and " to 0" not in line_str
377+
):
378+
# This is an insertion - always update to reflect current action
379+
self.action = "insertion"
380+
self.device = "SD/MMC via USB reader"
381+
elif (
382+
"detected capacity change from" in line_str and " to 0" in line_str
383+
):
384+
# This is a removal - always update to reflect current action
385+
self.action = "removal"
386+
387+
# Then extract partition name from patterns like "sda: sda1"
388+
if not self.mounted_partition:
389+
part_re = re.compile(r"sd\w+:.*(?P<part_name>sd\w+)")
390+
match = re.search(part_re, line_str)
391+
if match:
392+
self.mounted_partition = match.group("part_name")
393+
394+
return super()._parse_journal_line(line_str)
395+
372396

373397
class ThunderboltStorage(StorageWatcher):
374398
"""

0 commit comments

Comments
 (0)