mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +08:00
refactoring
This commit is contained in:
@@ -25,7 +25,7 @@ import errno
|
||||
|
||||
from typing import List
|
||||
|
||||
from .... import env
|
||||
from .... import usb
|
||||
|
||||
from .. import MsdOperationError
|
||||
|
||||
@@ -39,23 +39,16 @@ class MsdDriveLockedError(MsdOperationError):
|
||||
# =====
|
||||
class Drive:
|
||||
def __init__(self, gadget: str, instance: int, lun: int) -> None:
|
||||
self.__lun_path = os.path.join(
|
||||
f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget",
|
||||
gadget,
|
||||
f"functions/mass_storage.usb{instance}/lun.{lun}",
|
||||
)
|
||||
self.__configs_root_path = os.path.join(
|
||||
f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget",
|
||||
gadget,
|
||||
"configs/c.1",
|
||||
)
|
||||
self.__func_path = os.path.join(self.__configs_root_path, f"mass_storage.usb{instance}")
|
||||
func = f"mass_storage.usb{instance}"
|
||||
self.__profile_func_path = usb.get_gadget_path(gadget, usb.G_PROFILE, func)
|
||||
self.__profile_path = usb.get_gadget_path(gadget, usb.G_PROFILE)
|
||||
self.__lun_path = usb.get_gadget_path(gadget, usb.G_FUNCTIONS, func, f"lun.{lun}")
|
||||
|
||||
def is_enabled(self) -> bool:
|
||||
return os.path.exists(self.__func_path)
|
||||
return os.path.exists(self.__profile_func_path)
|
||||
|
||||
def get_watchable_paths(self) -> List[str]:
|
||||
return [self.__lun_path, self.__configs_root_path]
|
||||
return [self.__lun_path, self.__profile_path]
|
||||
|
||||
# =====
|
||||
|
||||
|
||||
Reference in New Issue
Block a user