#nbd #netlink #linux #network-block-device #sockets #neli #api-bindings

nbd-netlink

Set up an NBD device for a specified socket and parameters, using the Linux netlink interface

4 releases (2 breaking)

0.3.0 Jul 3, 2022
0.2.0 Jan 4, 2021
0.1.1 Aug 25, 2020
0.1.0 Aug 11, 2020

#698 in Unix APIs

MIT/Apache

9KB
162 lines

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])?;

lib.rs:

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])?;

Dependencies

~1–1.7MB
~37K SLoC