The usb-gadget
interface permits snaps to access the USB Gadget API using configfs.
USB gadget is a feature of the Linux kernel that allows USB connected devices to identify as USB peripherals, such as USB keyboards or storage devices. They are unrelated to Ubuntu Core gadget snaps.
For some USB gadgets, such as those using the FunctionalFS (Function Filesystem), additional interfaces may be required, such as mount-control to mount a FunctionFS, and system-files to read and write to the location.
Requires snapd version 2.71+
Developer details
Auto-connect: no
The USB Gadget API, through configfs, can be loaded through libcomposite which then provides /sys/kernel/config/usb_gadget/
. This can then be used to create and discover new USB gadgets. This interface allows snaps to read and write to those paths.
Code examples
The test code can be found in the snapd repository:
snapd/interfaces/builtin/usb_gadget_test.go at master · canonical/snapd · GitHub
The source code for the interface is in the snapd repository:
snapd/interfaces/builtin/usb_gadget.go at master · canonical/snapd · GitHub