mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
dvd support
This commit is contained in:
parent
0202a3c2d1
commit
2acd613a38
2
PKGBUILD
2
PKGBUILD
@ -210,7 +210,7 @@ for _variant in "${_variants[@]}"; do
|
|||||||
cd \"kvmd-\$pkgver\"
|
cd \"kvmd-\$pkgver\"
|
||||||
|
|
||||||
pkgdesc=\"PiKVM platform configs - $_platform for $_board\"
|
pkgdesc=\"PiKVM platform configs - $_platform for $_board\"
|
||||||
depends=(kvmd=$pkgver-$pkgrel \"linux-rpi-pikvm>=6.6.45-1\" \"raspberrypi-bootloader-pikvm>=20240818-1\")
|
depends=(kvmd=$pkgver-$pkgrel \"linux-rpi-pikvm>=6.6.45-10\" \"raspberrypi-bootloader-pikvm>=20240818-1\")
|
||||||
|
|
||||||
backup=(
|
backup=(
|
||||||
etc/sysctl.d/99-kvmd.conf
|
etc/sysctl.d/99-kvmd.conf
|
||||||
|
|||||||
@ -595,6 +595,18 @@ def _get_config_scheme() -> dict:
|
|||||||
"rw": Option(False, type=valid_bool),
|
"rw": Option(False, type=valid_bool),
|
||||||
"removable": Option(True, type=valid_bool),
|
"removable": Option(True, type=valid_bool),
|
||||||
"fua": Option(True, type=valid_bool),
|
"fua": Option(True, type=valid_bool),
|
||||||
|
"inquiry_string": {
|
||||||
|
"cdrom": {
|
||||||
|
"vendor": Option("PiKVM", type=valid_stripped_string),
|
||||||
|
"product": Option("Optical Drive", type=valid_stripped_string),
|
||||||
|
"revision": Option("1.00", type=valid_stripped_string),
|
||||||
|
},
|
||||||
|
"flash": {
|
||||||
|
"vendor": Option("PiKVM", type=valid_stripped_string),
|
||||||
|
"product": Option("Flash Drive", type=valid_stripped_string),
|
||||||
|
"revision": Option("1.00", type=valid_stripped_string),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -626,6 +638,18 @@ def _get_config_scheme() -> dict:
|
|||||||
"rw": Option(True, type=valid_bool),
|
"rw": Option(True, type=valid_bool),
|
||||||
"removable": Option(True, type=valid_bool),
|
"removable": Option(True, type=valid_bool),
|
||||||
"fua": Option(True, type=valid_bool),
|
"fua": Option(True, type=valid_bool),
|
||||||
|
"inquiry_string": {
|
||||||
|
"cdrom": {
|
||||||
|
"vendor": Option("PiKVM", type=valid_stripped_string),
|
||||||
|
"product": Option("Optical Drive", type=valid_stripped_string),
|
||||||
|
"revision": Option("1.00", type=valid_stripped_string),
|
||||||
|
},
|
||||||
|
"flash": {
|
||||||
|
"vendor": Option("PiKVM", type=valid_stripped_string),
|
||||||
|
"product": Option("Flash Drive", type=valid_stripped_string),
|
||||||
|
"revision": Option("1.00", type=valid_stripped_string),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -186,7 +186,19 @@ class _GadgetConfig:
|
|||||||
self.__create_meta(func, desc, eps)
|
self.__create_meta(func, desc, eps)
|
||||||
self.__hid_instance += 1
|
self.__hid_instance += 1
|
||||||
|
|
||||||
def add_msd(self, start: bool, user: str, stall: bool, cdrom: bool, rw: bool, removable: bool, fua: bool) -> None:
|
def add_msd(
|
||||||
|
self,
|
||||||
|
start: bool,
|
||||||
|
user: str,
|
||||||
|
stall: bool,
|
||||||
|
cdrom: bool,
|
||||||
|
rw: bool,
|
||||||
|
removable: bool,
|
||||||
|
fua: bool,
|
||||||
|
inquiry_string_cdrom: str,
|
||||||
|
inquiry_string_flash: str,
|
||||||
|
) -> None:
|
||||||
|
|
||||||
# Endpoints number depends on transport_type but we can consider that this is 2
|
# Endpoints number depends on transport_type but we can consider that this is 2
|
||||||
# because transport_type is always USB_PR_BULK by default if CONFIG_USB_FILE_STORAGE_TEST
|
# because transport_type is always USB_PR_BULK by default if CONFIG_USB_FILE_STORAGE_TEST
|
||||||
# is not defined. See drivers/usb/gadget/function/storage_common.c
|
# is not defined. See drivers/usb/gadget/function/storage_common.c
|
||||||
@ -198,6 +210,8 @@ class _GadgetConfig:
|
|||||||
_write(join(func_path, "lun.0/ro"), int(not rw))
|
_write(join(func_path, "lun.0/ro"), int(not rw))
|
||||||
_write(join(func_path, "lun.0/removable"), int(removable))
|
_write(join(func_path, "lun.0/removable"), int(removable))
|
||||||
_write(join(func_path, "lun.0/nofua"), int(not fua))
|
_write(join(func_path, "lun.0/nofua"), int(not fua))
|
||||||
|
_write(join(func_path, "lun.0/inquiry_string_cdrom"), inquiry_string_cdrom)
|
||||||
|
_write(join(func_path, "lun.0/inquiry_string"), inquiry_string_flash)
|
||||||
if user != "root":
|
if user != "root":
|
||||||
_chown(join(func_path, "lun.0/cdrom"), user)
|
_chown(join(func_path, "lun.0/cdrom"), user)
|
||||||
_chown(join(func_path, "lun.0/ro"), user)
|
_chown(join(func_path, "lun.0/ro"), user)
|
||||||
@ -293,11 +307,23 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements,
|
|||||||
|
|
||||||
if config.kvmd.msd.type == "otg":
|
if config.kvmd.msd.type == "otg":
|
||||||
logger.info("===== MSD =====")
|
logger.info("===== MSD =====")
|
||||||
gc.add_msd(cod.msd.start, config.otg.user, **cod.msd.default._unpack())
|
gc.add_msd(
|
||||||
|
start=cod.msd.start,
|
||||||
|
user=config.otg.user,
|
||||||
|
inquiry_string_cdrom=usb.make_inquiry_string(**cod.msd.default.inquiry_string.cdrom._unpack()),
|
||||||
|
inquiry_string_flash=usb.make_inquiry_string(**cod.msd.default.inquiry_string.flash._unpack()),
|
||||||
|
**cod.msd.default._unpack(ignore="inquiry_string"),
|
||||||
|
)
|
||||||
if cod.drives.enabled:
|
if cod.drives.enabled:
|
||||||
for count in range(cod.drives.count):
|
for count in range(cod.drives.count):
|
||||||
logger.info("===== MSD Extra: %d =====", count + 1)
|
logger.info("===== MSD Extra: %d =====", count + 1)
|
||||||
gc.add_msd(cod.drives.start, "root", **cod.drives.default._unpack())
|
gc.add_msd(
|
||||||
|
start=cod.drives.start,
|
||||||
|
user="root",
|
||||||
|
inquiry_string_cdrom=usb.make_inquiry_string(**cod.drives.default.inquiry_string.cdrom._unpack()),
|
||||||
|
inquiry_string_flash=usb.make_inquiry_string(**cod.drives.default.inquiry_string.flash._unpack()),
|
||||||
|
**cod.drives.default._unpack(ignore="inquiry_string"),
|
||||||
|
)
|
||||||
|
|
||||||
if cod.ethernet.enabled:
|
if cod.ethernet.enabled:
|
||||||
logger.info("===== Ethernet =====")
|
logger.info("===== Ethernet =====")
|
||||||
|
|||||||
@ -68,7 +68,7 @@ def main(argv: (list[str] | None)=None) -> None:
|
|||||||
parser.add_argument("-i", "--instance", default=0, type=valid_int_f0,
|
parser.add_argument("-i", "--instance", default=0, type=valid_int_f0,
|
||||||
metavar="<N>", help="Drive instance (0 for KVMD drive)")
|
metavar="<N>", help="Drive instance (0 for KVMD drive)")
|
||||||
parser.add_argument("--set-cdrom", default=None, type=valid_bool,
|
parser.add_argument("--set-cdrom", default=None, type=valid_bool,
|
||||||
metavar="<1|0|yes|no>", help="Set CD-ROM flag")
|
metavar="<1|0|yes|no>", help="Set CD/DVD flag")
|
||||||
parser.add_argument("--set-rw", default=None, type=valid_bool,
|
parser.add_argument("--set-rw", default=None, type=valid_bool,
|
||||||
metavar="<1|0|yes|no>", help="Set RW flag")
|
metavar="<1|0|yes|no>", help="Set RW flag")
|
||||||
parser.add_argument("--set-image", default=None, type=valid_abs_path,
|
parser.add_argument("--set-image", default=None, type=valid_abs_path,
|
||||||
@ -101,5 +101,5 @@ def main(argv: (list[str] | None)=None) -> None:
|
|||||||
set_param("file", options.set_image)
|
set_param("file", options.set_image)
|
||||||
|
|
||||||
print("Image file: ", (get_param("file") or "<none>"))
|
print("Image file: ", (get_param("file") or "<none>"))
|
||||||
print("CD-ROM flag:", ("yes" if int(get_param("cdrom")) else "no"))
|
print("CD/DVD flag:", ("yes" if int(get_param("cdrom")) else "no"))
|
||||||
print("RW flag: ", ("no" if int(get_param("ro")) else "yes"))
|
print("RW flag: ", ("no" if int(get_param("ro")) else "yes"))
|
||||||
|
|||||||
@ -55,3 +55,11 @@ G_PROFILE = f"configs/{G_PROFILE_NAME}"
|
|||||||
|
|
||||||
def get_gadget_path(gadget: str, *parts: str) -> str:
|
def get_gadget_path(gadget: str, *parts: str) -> str:
|
||||||
return os.path.join(f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget", gadget, *parts)
|
return os.path.join(f"{env.SYSFS_PREFIX}/sys/kernel/config/usb_gadget", gadget, *parts)
|
||||||
|
|
||||||
|
|
||||||
|
# =====
|
||||||
|
def make_inquiry_string(vendor: str, product: str, revision: str) -> str:
|
||||||
|
# Vendor: 8 ASCII chars
|
||||||
|
# Product: 16
|
||||||
|
# Revision: 4
|
||||||
|
return "%-8.8s%-16.16s%-4.4s" % (vendor, product, revision)
|
||||||
|
|||||||
@ -525,15 +525,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden" id="msd-message-too-big-for-cdrom">
|
<div class="hidden" id="msd-message-too-big-for-dvd">
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="2"><img class="sign " src="/share/svg/warning.svg"></td>
|
<td rowspan="2"><img class="sign " src="/share/svg/warning.svg"></td>
|
||||||
<td style="line-height:1.5"><b>Current image is too big for CD-ROM!</b></td>
|
<td style="line-height:1.5"><b>Current image is too big for DVD!</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><sup style="line-height:1">The device filesystem will be truncated to 2.2GiB</sup></td>
|
<td><sup style="line-height:1">The maximum is 31.6GiB. Please switch to the Flash mode.</sup></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -603,7 +603,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<div class="radio-box">
|
<div class="radio-box">
|
||||||
<input checked type="radio" id="msd-mode-radio-cdrom" name="msd-mode-radio" value="1">
|
<input checked type="radio" id="msd-mode-radio-cdrom" name="msd-mode-radio" value="1">
|
||||||
<label for="msd-mode-radio-cdrom">CD-ROM</label>
|
<label for="msd-mode-radio-cdrom">CD/DVD</label>
|
||||||
<input type="radio" id="msd-mode-radio-flash" name="msd-mode-radio" value="0">
|
<input type="radio" id="msd-mode-radio-flash" name="msd-mode-radio" value="0">
|
||||||
<label for="msd-mode-radio-flash">Flash</label>
|
<label for="msd-mode-radio-flash">Flash</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -15,9 +15,9 @@ li(id="msd-dropdown" class="right feature-disabled")
|
|||||||
+menu_message("warning", "Current image is broken!")
|
+menu_message("warning", "Current image is broken!")
|
||||||
| Perhaps uploading was interrupted#[br]
|
| Perhaps uploading was interrupted#[br]
|
||||||
hr
|
hr
|
||||||
div(id="msd-message-too-big-for-cdrom" class="hidden")
|
div(id="msd-message-too-big-for-dvd" class="hidden")
|
||||||
+menu_message("warning", "Current image is too big for CD-ROM!")
|
+menu_message("warning", "Current image is too big for DVD!")
|
||||||
| The device filesystem will be truncated to 2.2GiB
|
| The maximum is 31.6GiB. Please switch to the Flash mode.
|
||||||
hr
|
hr
|
||||||
div(id="msd-message-out-of-storage" class="hidden")
|
div(id="msd-message-out-of-storage" class="hidden")
|
||||||
+menu_message("warning", "Current image is out of storage")
|
+menu_message("warning", "Current image is out of storage")
|
||||||
@ -45,7 +45,7 @@ li(id="msd-dropdown" class="right feature-disabled")
|
|||||||
td
|
td
|
||||||
div(class="radio-box")
|
div(class="radio-box")
|
||||||
input(checked type="radio" id="msd-mode-radio-cdrom" name="msd-mode-radio" value="1")
|
input(checked type="radio" id="msd-mode-radio-cdrom" name="msd-mode-radio" value="1")
|
||||||
label(for="msd-mode-radio-cdrom") CD-ROM
|
label(for="msd-mode-radio-cdrom") CD/DVD
|
||||||
input(type="radio" id="msd-mode-radio-flash" name="msd-mode-radio" value="0")
|
input(type="radio" id="msd-mode-radio-flash" name="msd-mode-radio" value="0")
|
||||||
label(for="msd-mode-radio-flash") Flash
|
label(for="msd-mode-radio-flash") Flash
|
||||||
td
|
td
|
||||||
|
|||||||
@ -120,7 +120,7 @@ export function Msd() {
|
|||||||
|
|
||||||
tools.hidden.setVisible($("msd-message-offline"), (state && !state.online));
|
tools.hidden.setVisible($("msd-message-offline"), (state && !state.online));
|
||||||
tools.hidden.setVisible($("msd-message-image-broken"), (o && d.image && !d.image.complete && !s.uploading));
|
tools.hidden.setVisible($("msd-message-image-broken"), (o && d.image && !d.image.complete && !s.uploading));
|
||||||
tools.hidden.setVisible($("msd-message-too-big-for-cdrom"), (o && d.cdrom && d.image && d.image.size >= 2359296000));
|
tools.hidden.setVisible($("msd-message-too-big-for-dvd"), (o && d.cdrom && d.image && d.image.size >= 33957083136));
|
||||||
tools.hidden.setVisible($("msd-message-out-of-storage"), (o && d.image && !d.image.in_storage));
|
tools.hidden.setVisible($("msd-message-out-of-storage"), (o && d.image && !d.image.in_storage));
|
||||||
tools.hidden.setVisible($("msd-message-rw-enabled"), (o && d.rw));
|
tools.hidden.setVisible($("msd-message-rw-enabled"), (o && d.rw));
|
||||||
tools.hidden.setVisible($("msd-message-another-user-uploads"), (o && s.uploading && !__http));
|
tools.hidden.setVisible($("msd-message-another-user-uploads"), (o && s.uploading && !__http));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user