Function crosvm_control::crosvm_client_usb_attach
source · #[no_mangle]
pub unsafe extern "C" fn crosvm_client_usb_attach(
socket_path: *const c_char,
_bus: u8,
_addr: u8,
_vid: u16,
_pid: u16,
dev_path: *const c_char,
out_port: *mut u8
) -> bool
Expand description
Attaches an USB device to crosvm instance whose control socket is listening on socket_path
.
The function returns the amount of entries written.
§Arguments
socket_path
- Path to the crosvm control socketbus
- USB device bus ID (unused)addr
- USB device address (unused)vid
- USB device vendor ID (unused)pid
- USB device product ID (unused)dev_path
- Path to the USB device (Most likely/dev/bus/usb/<bus>/<addr>
).out_port
- (optional) internal port will be written here if provided.
The function returns true on success or false if an error occurred.
§Safety
Function is unsafe due to raw pointer usage. Trivial !raw_pointer.is_null() checks prevent some unsafe behavior, but the caller should ensure no null pointers are passed into the function.
The safety requirements for socket_path
and dev_path
are the same as the ones from
CStr::from_ptr()
. out_port
should be a non-null pointer that points to a writable 1byte
region.