Skip to content

Commit cfb8d98

Browse files
committed
update mount kmod detection to look for mmc platform drivers
Signed-off-by: Zen <[email protected]>
1 parent 419253a commit cfb8d98

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/ugrd/fs/mounts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Union
77

88
from ugrd.exceptions import AutodetectError, ValidationError
9+
from ugrd.kmod.platform import _get_platform_mmc_drivers
910
from zenlib.util import colorize as c_
1011
from zenlib.util import contains, pretty_print
1112

@@ -1075,6 +1076,7 @@ def resolve_blkdev_kmod(self, device) -> list[str]:
10751076
kmods.append("virtio_scsi")
10761077
elif device_name.startswith("mmcblk"):
10771078
kmods.append("mmc_block")
1079+
kmods.extend(_get_platform_mmc_drivers(self, device_name))
10781080
elif device_name.startswith("sr"):
10791081
kmods.append("sr_mod")
10801082
elif device_name.startswith("md"):

src/ugrd/kmod/kmod.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ def _get_kmod_info(self, module: str) -> dict:
109109
"""
110110
Runs modinfo on a kernel module, parses the output and stored the results in self['_kmod_modinfo'].
111111
!!! Should be run after metadata is processed so the kver is set properly !!!
112+
113+
Returns the module info as a dictionary with the following keys:
114+
- filename: The path to the module file.
115+
- depends: A list of module dependencies.
116+
- softdep: A list of soft dependencies.
117+
- firmware: A list of firmware files required by the module.
118+
Raises:
119+
DependencyResolutionError: If the modinfo command fails, returns no output, or the module name can't be resolved.
112120
"""
113121
module = _normalize_kmod_name(self, module)
114122
if module in self["_kmod_modinfo"]:

src/ugrd/kmod/platform.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,34 @@ def autodetect_platform_bus_drivers(self):
101101
else:
102102
self.logger.info("No platform bus drivers detected.")
103103

104+
105+
def _get_platform_mmc_drivers(self, mmc_dev):
106+
"""Helper function to get MMC drivers from a given device.
107+
Strips the partition number from the device name if present.
108+
"""
109+
mmc_name = mmc_dev.split("p")[0].replace('blk', '') # Strip partition number if present, and 'blk' prefix
110+
mmc_path = Path(f"/sys/class/mmc_host/{mmc_name}/device")
111+
if not mmc_path.exists():
112+
self.logger.warning(f"[{c_(mmc_path, 'yellow')}] MMC device path does not exist, skipping detection.")
113+
return []
114+
115+
drivers = set()
116+
if driver := (mmc_path / "driver").resolve().name:
117+
self.logger.info(f"[{c_(mmc_dev, 'green', bright=True)}] Detected MMC driver: {c_(driver, 'magenta', bright=True)}")
118+
drivers.add(driver)
119+
120+
# Check for supplier drivers
121+
for supplier in mmc_path.iterdir():
122+
if not supplier.name.startswith("supplier:"):
123+
continue
124+
125+
supplier_driver = (supplier / "supplier" / "driver")
126+
if not supplier_driver.exists():
127+
self.logger.warning(f"[{c_(mmc_dev, 'yellow', bright=True)}] Supplier driver not found, skipping: {c_(supplier_driver, 'red', bright=True)}")
128+
continue
129+
130+
supplier_driver = supplier_driver.resolve()
131+
self.logger.debug(f"[{c_(mmc_dev, 'green', bright=True)}:{c_(supplier, 'blue')}] Detected MMC supplier driver: {c_(supplier_driver.name, 'magenta', bright=True)}")
132+
drivers.add(supplier_driver.name)
133+
134+
return list(drivers)

0 commit comments

Comments
 (0)