1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! # 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
//!
//! ```rust,no_run
//! 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](https://docs.kernel.org/block/ublk.html) and
//! the ublk header file for more information.
include!;
/// Convert a packed u64 sqe address to an `ublk_auto_buf_reg` structure.
///
/// This function unpacks the automatic buffer registration data from the format
/// used in io_uring sqe->addr field.
///
/// # Format
/// - bits 0-15: buffer index
/// - bits 16-23: flags
/// - bits 24-31: reserved0
/// - bits 32-63: reserved1
/// Convert an `ublk_auto_buf_reg` structure to a packed u64 sqe address.
///
/// This function packs automatic buffer registration data into the format
/// used in io_uring sqe->addr field for `UBLK_F_AUTO_BUF_REG`.
///
/// # Format
/// - bits 0-15: buffer index
/// - bits 16-23: flags
/// - bits 24-31: reserved0
/// - bits 32-63: reserved1