| Crates.io | libublk-rs-sys |
| lib.rs | libublk-rs-sys |
| version | 0.1.0 |
| created_at | 2025-12-16 12:10:58.828894+00 |
| updated_at | 2025-12-16 12:10:58.828894+00 |
| description | Low-level FFI bindings for Linux ublk (userspace block device) kernel interface |
| homepage | |
| repository | https://github.com/ublk-org/libublk-rs |
| max_upload_size | |
| id | 1987622 |
| size | 41,465 |
Low-level FFI bindings for the Linux ublk (userspace block device) kernel interface.
This crate provides raw, unsafe bindings to the Linux ublk kernel API. These bindings are automatically generated from the kernel headers using bindgen and include serialization support via serde.
libublk-rs-sys 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.
This crate is ideal when you need:
libc and serdeCONFIG_BLK_DEV_UBLK enableduse 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,
)
};
if ctrl_fd < 0 {
panic!("Failed to open /dev/ublk-control");
}
// Create a control command structure
let mut cmd = ublksrv_ctrl_cmd {
dev_id: 0,
queue_id: !0u16, // -1 for device-level commands
len: 0,
addr: 0,
data: [0; 1],
dev_path_len: 0,
pad: 0,
reserved: 0,
};
// Use with your own io_uring instance for async operations...
⚠️ All functions and types in this crate are unsafe to use. ⚠️
Improper use can lead to:
Always refer to the Linux kernel ublk documentation when using these bindings.
| Feature | libublk-rs-sys | libublk |
|---|---|---|
| Safety | Unsafe, raw FFI | Safe Rust API |
| io_uring | Bring your own | Managed thread-local |
| Abstraction | None | High-level builder patterns |
| Use case | Custom integrations | Quick ublk device creation |
Licensed under either of:
at your option.
Contributions are welcome! Please see the main libublk-rs repository for contribution guidelines.