Skip to main content

Crate libublk_rs_sys

Crate libublk_rs_sys 

Source
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§

__IncompleteArrayField
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_reg structure to a packed u64 sqe address.
ublk_sqe_addr_to_auto_buf_reg
Convert a packed u64 sqe address to an ublk_auto_buf_reg structure.

Type Aliases§

__s32
__u8
__u16
__u32
__u64
blk_zone_cond
blk_zone_report_flags
blk_zone_type