nbd-netlink

Crates.ionbd-netlink
lib.rsnbd-netlink
version0.3.0
sourcesrc
created_at2020-08-11 03:48:36.039353
updated_at2022-07-03 04:05:03.888454
descriptionSet up an NBD device for a specified socket and parameters, using the Linux netlink interface
homepage
repositoryhttps://github.com/joshtriplett/nbd-netlink
max_upload_size
id275237
size8,829
Josh Triplett (joshtriplett)

documentation

README

nbd-netlink supports setting up an NBD device for a specified socket and parameters, using the Linux kernel's netlink interface to NBD. Unlike the ioctl-based interface, the netlink interface can hand off a socket to the kernel without leaving a thread or process running.

Example

use std::net::{Ipv4Addr, TcpStream};
use nbd_netlink::{NBD, NBDConnect};
let nbd_socket = TcpStream::connect((Ipv4Addr::LOCALHOST, 10809))?;
nbd_socket.set_nodelay(true);
let mut nbd = NBD::new()?;
let index = NBDConnect::new()
    .size_bytes(1048576)
    .read_only(true)
    .connect(&mut nbd, &[nbd_socket])?;
Commit count: 4

cargo fmt