mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 01:30:31 +08:00
renamed config_path to profile_path
This commit is contained in:
parent
984ae4fa37
commit
ab09f88d80
@ -106,9 +106,9 @@ def _check_config(config: Section) -> None:
|
||||
|
||||
# =====
|
||||
class _GadgetConfig:
|
||||
def __init__(self, gadget_path: str, config_path: str, meta_path: str) -> None:
|
||||
def __init__(self, gadget_path: str, profile_path: str, meta_path: str) -> None:
|
||||
self.__gadget_path = gadget_path
|
||||
self.__config_path = config_path
|
||||
self.__profile_path = profile_path
|
||||
self.__meta_path = meta_path
|
||||
self.__hid_instance = 0
|
||||
self.__msd_instance = 0
|
||||
@ -118,7 +118,7 @@ class _GadgetConfig:
|
||||
func = "acm.usb0"
|
||||
func_path = join(self.__gadget_path, "functions", func)
|
||||
_mkdir(func_path)
|
||||
_symlink(func_path, join(self.__config_path, func))
|
||||
_symlink(func_path, join(self.__profile_path, func))
|
||||
self.__create_meta(func, "Serial Port")
|
||||
|
||||
def add_ethernet(self, driver: str, host_mac: str, kvm_mac: str) -> None:
|
||||
@ -147,8 +147,8 @@ class _GadgetConfig:
|
||||
# a Microsoft-specific extension of USB.
|
||||
_write(join(func_path, "os_desc/interface.rndis/compatible_id"), "RNDIS")
|
||||
_write(join(func_path, "os_desc/interface.rndis/sub_compatible_id"), "5162001")
|
||||
_symlink(self.__config_path, join(self.__gadget_path, "os_desc/c.1"))
|
||||
_symlink(func_path, join(self.__config_path, func))
|
||||
_symlink(self.__profile_path, join(self.__gadget_path, "os_desc/c.1"))
|
||||
_symlink(func_path, join(self.__profile_path, func))
|
||||
self.__create_meta(func, "Ethernet")
|
||||
|
||||
def add_keyboard(self, remote_wakeup: bool) -> None:
|
||||
@ -169,7 +169,7 @@ class _GadgetConfig:
|
||||
_write(join(func_path, "subclass"), str(hid.subclass))
|
||||
_write(join(func_path, "report_length"), str(hid.report_length))
|
||||
_write_bytes(join(func_path, "report_desc"), hid.report_descriptor)
|
||||
_symlink(func_path, join(self.__config_path, func))
|
||||
_symlink(func_path, join(self.__profile_path, func))
|
||||
self.__create_meta(func, name)
|
||||
self.__hid_instance += 1
|
||||
|
||||
@ -186,7 +186,7 @@ class _GadgetConfig:
|
||||
_chown(join(func_path, "lun.0/cdrom"), user)
|
||||
_chown(join(func_path, "lun.0/ro"), user)
|
||||
_chown(join(func_path, "lun.0/file"), user)
|
||||
_symlink(func_path, join(self.__config_path, func))
|
||||
_symlink(func_path, join(self.__profile_path, func))
|
||||
name = ("Mass Storage Drive" if self.__msd_instance == 0 else f"Extra Drive #{self.__msd_instance}")
|
||||
self.__create_meta(func, name)
|
||||
self.__msd_instance += 1
|
||||
@ -229,16 +229,16 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
|
||||
_write(join(lang_path, "product"), config.otg.product)
|
||||
_write(join(lang_path, "serialnumber"), config.otg.serial)
|
||||
|
||||
config_path = join(gadget_path, "configs/c.1")
|
||||
_mkdir(config_path)
|
||||
_mkdir(join(config_path, "strings/0x409"))
|
||||
_write(join(config_path, "strings/0x409/configuration"), f"Config 1: {config.otg.config}")
|
||||
_write(join(config_path, "MaxPower"), "250")
|
||||
profile_path = join(gadget_path, "configs/c.1")
|
||||
_mkdir(profile_path)
|
||||
_mkdir(join(profile_path, "strings/0x409"))
|
||||
_write(join(profile_path, "strings/0x409/configuration"), f"Config 1: {config.otg.config}")
|
||||
_write(join(profile_path, "MaxPower"), "250")
|
||||
if config.otg.remote_wakeup:
|
||||
# XXX: Should we use MaxPower=100 with Remote Wakeup?
|
||||
_write(join(config_path, "bmAttributes"), "0xA0")
|
||||
_write(join(profile_path, "bmAttributes"), "0xA0")
|
||||
|
||||
gc = _GadgetConfig(gadget_path, config_path, config.otg.meta)
|
||||
gc = _GadgetConfig(gadget_path, profile_path, config.otg.meta)
|
||||
|
||||
if config.otg.devices.serial.enabled:
|
||||
logger.info("===== Serial =====")
|
||||
@ -292,12 +292,12 @@ def _cmd_stop(config: Section) -> None:
|
||||
|
||||
_unlink(join(gadget_path, "os_desc/c.1"), True)
|
||||
|
||||
config_path = join(gadget_path, "configs/c.1")
|
||||
for func in os.listdir(config_path):
|
||||
profile_path = join(gadget_path, "configs/c.1")
|
||||
for func in os.listdir(profile_path):
|
||||
if re.search(r"\.usb\d+$", func):
|
||||
_unlink(join(config_path, func))
|
||||
_rmdir(join(config_path, "strings/0x409"))
|
||||
_rmdir(config_path)
|
||||
_unlink(join(profile_path, func))
|
||||
_rmdir(join(profile_path, "strings/0x409"))
|
||||
_rmdir(profile_path)
|
||||
|
||||
funcs_path = join(gadget_path, "functions")
|
||||
for func in os.listdir(funcs_path):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user