summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/plugins/msd/otg/__init__.py10
-rw-r--r--kvmd/plugins/msd/otg/drive.py4
2 files changed, 8 insertions, 6 deletions
diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py
index 76ef7d07..d6d5a36f 100644
--- a/kvmd/plugins/msd/otg/__init__.py
+++ b/kvmd/plugins/msd/otg/__init__.py
@@ -137,6 +137,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
remount_cmd: List[str],
unlock_cmd: List[str],
+ sysfs_prefix: str,
gadget: str, # XXX: Not from options, see /kvmd/apps/kvmd/__init__.py for details
) -> None:
@@ -147,7 +148,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
self.__remount_cmd = remount_cmd
self.__unlock_cmd = unlock_cmd
- self.__drive = Drive(gadget, instance=0, lun=0)
+ self.__drive = Drive(sysfs_prefix, gadget, instance=0, lun=0)
self.__new_file: Optional[aiofiles.base.AiofilesContextManager] = None
self.__new_file_written = 0
@@ -164,9 +165,10 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
def get_plugin_options(cls) -> Dict:
sudo = ["/usr/bin/sudo", "--non-interactive"]
return {
- "storage": Option("/var/lib/kvmd/msd", type=valid_abs_dir, unpack_as="storage_path"),
- "remount_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-remount", "{mode}"], type=valid_command),
- "unlock_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-unlock", "unlock"], type=valid_command),
+ "storage": Option("/var/lib/kvmd/msd", type=valid_abs_dir, unpack_as="storage_path"),
+ "remount_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-remount", "{mode}"], type=valid_command),
+ "unlock_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-unlock", "unlock"], type=valid_command),
+ "sysfs_prefix": Option("", type=(lambda arg: str(arg).strip())),
}
async def get_state(self) -> Dict:
diff --git a/kvmd/plugins/msd/otg/drive.py b/kvmd/plugins/msd/otg/drive.py
index e6457527..ff91afcf 100644
--- a/kvmd/plugins/msd/otg/drive.py
+++ b/kvmd/plugins/msd/otg/drive.py
@@ -34,9 +34,9 @@ class MsdDriveLockedError(MsdOperationError):
# =====
class Drive:
- def __init__(self, gadget: str, instance: int, lun: int) -> None:
+ def __init__(self, prefix: str, gadget: str, instance: int, lun: int) -> None:
self.__path = os.path.join(
- "/sys/kernel/config/usb_gadget",
+ f"{prefix}/sys/kernel/config/usb_gadget",
gadget,
f"functions/mass_storage.usb{instance}/lun.{lun}",
)