Expand description
§libublk-rs-sys
Low-level FFI bindings for the Linux ublk (userspace block device) kernel interface.
This crate provides raw, unsafe bindings to the ublk kernel API. These bindings are automatically generated from the kernel headers using bindgen.
§Usage
This is a -sys crate, which means it provides low-level FFI bindings without safe
wrappers. If you’re looking for a safe, high-level API, consider using the libublk
crate instead.
These bindings allow you to:
- Issue ublk control commands to create/delete/manage ublk devices
- Handle I/O operations on ublk queues
- Configure device parameters
- Use your own io_uring instance for handling ublk operations
§Example
use libublk_rs_sys::*;
use std::os::fd::AsRawFd;
// Open the ublk control device
let ctrl_fd = unsafe {
libc::open(
b"/dev/ublk-control\0".as_ptr() as *const i8,
libc::O_RDWR,
)
};
// Use the raw bindings with your own io_uring instance...§Safety
All functions and types in this crate are unsafe to use and require careful attention to the ublk kernel API documentation. Improper use can lead to undefined behavior, kernel panics, or data corruption.
See the Linux kernel documentation and the ublk header file for more information.
Structs§
- __
Incomplete Array Field - blk_
zone - blk_
zone_ range - blk_
zone_ report - ublk_
auto_ buf_ reg - ublk_
param_ basic - ublk_
param_ devt - ublk_
param_ discard - ublk_
param_ dma_ align - ublk_
param_ segment - ublk_
param_ zoned - ublk_
params - ublksrv_
ctrl_ cmd - ublksrv_
ctrl_ dev_ info - ublksrv_
io_ cmd - ublksrv_
io_ desc
Constants§
- BLK_
ZONE_ COND_ CLOSED - BLK_
ZONE_ COND_ EMPTY - BLK_
ZONE_ COND_ EXP_ OPEN - BLK_
ZONE_ COND_ FULL - BLK_
ZONE_ COND_ IMP_ OPEN - BLK_
ZONE_ COND_ NOT_ WP - BLK_
ZONE_ COND_ OFFLINE - BLK_
ZONE_ COND_ READONLY - BLK_
ZONE_ REP_ CAPACITY - BLK_
ZONE_ TYPE_ CONVENTIONAL - BLK_
ZONE_ TYPE_ SEQWRITE_ PREF - BLK_
ZONE_ TYPE_ SEQWRITE_ REQ - UBLKSRV_
CMD_ BUF_ OFFSET - UBLKSRV_
IO_ BUF_ OFFSET - UBLKSRV_
IO_ BUF_ TOTAL_ BITS - UBLKSRV_
IO_ BUF_ TOTAL_ SIZE - UBLK_
ATTR_ FUA - UBLK_
ATTR_ READ_ ONLY - UBLK_
ATTR_ ROTATIONAL - UBLK_
ATTR_ VOLATILE_ CACHE - UBLK_
AUTO_ BUF_ REG_ FALLBACK - UBLK_
AUTO_ BUF_ REG_ F_ MASK - UBLK_
CMD_ ADD_ DEV - UBLK_
CMD_ DEL_ DEV - UBLK_
CMD_ END_ USER_ RECOVERY - UBLK_
CMD_ GET_ DEV_ INFO - UBLK_
CMD_ GET_ DEV_ INFO2 - UBLK_
CMD_ GET_ PARAMS - UBLK_
CMD_ GET_ QUEUE_ AFFINITY - UBLK_
CMD_ SET_ PARAMS - UBLK_
CMD_ START_ DEV - UBLK_
CMD_ START_ USER_ RECOVERY - UBLK_
CMD_ STOP_ DEV - UBLK_
FEATURES_ LEN - UBLK_
F_ AUTO_ BUF_ REG - UBLK_
F_ CMD_ IOCTL_ ENCODE - UBLK_
F_ NEED_ GET_ DATA - UBLK_
F_ SUPPORT_ ZERO_ COPY - UBLK_
F_ UNPRIVILEGED_ DEV - UBLK_
F_ URING_ CMD_ COMP_ IN_ TASK - UBLK_
F_ USER_ COPY - UBLK_
F_ USER_ RECOVERY - UBLK_
F_ USER_ RECOVERY_ REISSUE - UBLK_
F_ ZONED - UBLK_
IO_ BUF_ BITS - UBLK_
IO_ BUF_ BITS_ MASK - UBLK_
IO_ BUF_ OFF - UBLK_
IO_ COMMIT_ AND_ FETCH_ REQ - UBLK_
IO_ FETCH_ REQ - UBLK_
IO_ F_ FAILFAST_ DEV - UBLK_
IO_ F_ FAILFAST_ DRIVER - UBLK_
IO_ F_ FAILFAST_ TRANSPORT - UBLK_
IO_ F_ FUA - UBLK_
IO_ F_ META - UBLK_
IO_ F_ NEED_ REG_ BUF - UBLK_
IO_ F_ NOUNMAP - UBLK_
IO_ F_ SWAP - UBLK_
IO_ NEED_ GET_ DATA - UBLK_
IO_ OP_ DISCARD - UBLK_
IO_ OP_ FLUSH - UBLK_
IO_ OP_ READ - UBLK_
IO_ OP_ REPORT_ ZONES - UBLK_
IO_ OP_ WRITE - UBLK_
IO_ OP_ WRITE_ SAME - UBLK_
IO_ OP_ WRITE_ ZEROES - UBLK_
IO_ OP_ ZONE_ APPEND - UBLK_
IO_ OP_ ZONE_ CLOSE - UBLK_
IO_ OP_ ZONE_ FINISH - UBLK_
IO_ OP_ ZONE_ OPEN - UBLK_
IO_ OP_ ZONE_ RESET - UBLK_
IO_ OP_ ZONE_ RESET_ ALL - UBLK_
IO_ RES_ ABORT - UBLK_
IO_ RES_ NEED_ GET_ DATA - UBLK_
IO_ RES_ OK - UBLK_
MAX_ NR_ QUEUES - UBLK_
MAX_ QUEUE_ DEPTH - UBLK_
MIN_ SEGMENT_ SIZE - UBLK_
PARAM_ TYPE_ BASIC - UBLK_
PARAM_ TYPE_ DEVT - UBLK_
PARAM_ TYPE_ DISCARD - UBLK_
PARAM_ TYPE_ DMA_ ALIGN - UBLK_
PARAM_ TYPE_ SEGMENT - UBLK_
PARAM_ TYPE_ ZONED - UBLK_
QID_ BITS - UBLK_
QID_ BITS_ MASK - UBLK_
QID_ OFF - UBLK_
S_ DEV_ DEAD - UBLK_
S_ DEV_ LIVE - UBLK_
S_ DEV_ QUIESCED - UBLK_
TAG_ BITS - UBLK_
TAG_ BITS_ MASK - UBLK_
TAG_ OFF - UBLK_
U_ CMD_ ADD_ DEV - UBLK_
U_ CMD_ DEL_ DEV - UBLK_
U_ CMD_ DEL_ DEV_ ASYNC - UBLK_
U_ CMD_ END_ USER_ RECOVERY - UBLK_
U_ CMD_ GET_ DEV_ INFO - UBLK_
U_ CMD_ GET_ DEV_ INFO2 - UBLK_
U_ CMD_ GET_ FEATURES - UBLK_
U_ CMD_ GET_ PARAMS - UBLK_
U_ CMD_ GET_ QUEUE_ AFFINITY - UBLK_
U_ CMD_ SET_ PARAMS - UBLK_
U_ CMD_ START_ DEV - UBLK_
U_ CMD_ START_ USER_ RECOVERY - UBLK_
U_ CMD_ STOP_ DEV - UBLK_
U_ IO_ COMMIT_ AND_ FETCH_ REQ - UBLK_
U_ IO_ FETCH_ REQ - UBLK_
U_ IO_ NEED_ GET_ DATA - UBLK_
U_ IO_ REGISTER_ IO_ BUF - UBLK_
U_ IO_ UNREGISTER_ IO_ BUF
Functions§
- ublk_
auto_ buf_ reg_ to_ sqe_ addr - Convert an
ublk_auto_buf_regstructure to a packed u64 sqe address. - ublk_
sqe_ addr_ to_ auto_ buf_ reg - Convert a packed u64 sqe address to an
ublk_auto_buf_regstructure.