Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
+84
View File
@@ -0,0 +1,84 @@
#!/bin/sh
if [ $# -ne 2 ]
then
echo "usage: $0 <start|stop> <config>" >&2
exit 1
fi
action=$1
config=$2
gadget_name=mass-storage
gadget_dir=/sys/kernel/config/usb_gadget/$gadget_name
case "$config" in
0)
nbd_device=/dev/nbd0
;;
1)
nbd_device=/dev/nbd1
;;
*)
echo "invalid config $config" >&2
exit 1
;;
esac
set -e
GADGET_BASE=/sys/kernel/config/usb_gadget
which_dev()
{
in_use="$(cat $GADGET_BASE/*/UDC)"
cd /sys/class/udc
for dev in *; do
case "$in_use" in
*"$dev"*) ;;
*) echo "$dev"; return 0;;
esac
done
return 1
}
case "$action" in
start)
mkdir -p $gadget_dir
(
cd $gadget_dir
# http://www.linux-usb.org/usb.ids
# |-> 1d6b Linux Foundation
# |-> 0104 Multifunction Composite Gadget
echo "0x1d6b" > idVendor
echo "0x0104" > idProduct
mkdir -p strings/0x409
echo "OpenBMC" > strings/0x409/manufacturer
echo "Virtual Media Device" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "config 1" > configs/c.1/strings/0x409/configuration
mkdir -p functions/mass_storage.usb0
ln -s functions/mass_storage.usb0 configs/c.1
echo 1 > functions/mass_storage.usb0/lun.0/removable
echo 1 > functions/mass_storage.usb0/lun.0/ro
echo 0 > functions/mass_storage.usb0/lun.0/cdrom
echo $nbd_device > functions/mass_storage.usb0/lun.0/file
device=$(which_dev)
echo "$device" > UDC
)
;;
stop)
(
cd $gadget_dir
rm configs/c.1/mass_storage.usb0
rmdir functions/mass_storage.usb0
rmdir configs/c.1/strings/0x409
rmdir configs/c.1
rmdir strings/0x409
)
rmdir $gadget_dir
;;
*)
echo "invalid action $action" >&2
exit 1
esac
@@ -0,0 +1,30 @@
SUMMARY = "Network Block Device Proxy"
HOMEPAGE = "https://github.com/openbmc/jsnbd"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENCE;md5=3b83ef96387f14655fc854ddc3c6bd57"
DEPENDS += "json-c"
DEPENDS += "udev"
SRCREV = "9b322cb38172985e67d755660167befe8b650ba6"
PV = "1.0+git${SRCPV}"
PR = "r1"
SRC_URI = " \
git://github.com/openbmc/jsnbd;branch=master;protocol=https \
file://state_hook \
"
S = "${WORKDIR}/git"
inherit meson pkgconfig
do_install:append() {
install -d ${D}${sysconfdir}/nbd-proxy/
install -m 0644 ${NBD_PROXY_CONFIG_JSON} ${D}${sysconfdir}/nbd-proxy/config.json
install -m 0755 ${WORKDIR}/state_hook ${D}${sysconfdir}/nbd-proxy/state
}
FILES:${PN} += "${sysconfdir}/nbd-proxy/state"
RDEPENDS:${PN} += "nbd-client"
NBD_PROXY_CONFIG_JSON ??= "${S}/config.sample.json"
@@ -0,0 +1,4 @@
# Don't create an empty openssh-dev package. That would pull in openssh-sshd
# even it we are only depending on openssh-sftp, which causes conflicts
# with dropbear
ALLOW_EMPTY:${PN}-dev = "0"
@@ -0,0 +1,23 @@
# General config settings.
EXTRA_OECONF:append:class-target = " shared no-hw no-err no-psk no-srp "
# Disable SSL (keep TLS only).
EXTRA_OECONF:append:class-target = " no-ssl2 no-ssl3 "
# Disable various algorithms.
EXTRA_OECONF:append:class-target = " \
no-rmd160 \
no-whirlpool \
no-rc2 \
no-rc4 \
no-bf \
no-cast \
no-gost \
"
do_configure:append() {
oe_runmake depend
}
# We don't want to depend on perl in our image
RDEPENDS:${PN}-bin:remove = "perl"
FILES:${PN}-misc:append = " ${bindir}/c_rehash"