Skip to content

Commit 7eb9e2c

Browse files
authored
Add loop.h api (#113)
1 parent 766c13b commit 7eb9e2c

21 files changed

Lines changed: 2531 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static_assertions = "1.1.0"
2121
libc = "0.2.100"
2222

2323
[package.metadata.docs.rs]
24-
features = ["default", "ioctl", "netlink", "io_uring", "if_arp", "if_ether", "if_packet", "net", "prctl", "elf", "xdp", "mempolicy", "system"]
24+
features = ["default", "ioctl", "netlink", "io_uring", "if_arp", "if_ether", "if_packet", "net", "prctl", "elf", "xdp", "mempolicy", "system", "loop_device"]
2525
targets = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
2626

2727
# The rest of this file is auto-generated!
@@ -33,6 +33,7 @@ if_ether = []
3333
if_packet = []
3434
io_uring = []
3535
ioctl = []
36+
loop_device = []
3637
mempolicy = []
3738
net = []
3839
netlink = []

gen/modules/loop_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <linux/loop.h>

src/aarch64/loop_device.rs

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/* automatically generated by rust-bindgen 0.66.1 */
2+
3+
pub type __kernel_old_uid_t = crate::ctypes::c_ushort;
4+
pub type __kernel_old_gid_t = crate::ctypes::c_ushort;
5+
pub type __kernel_long_t = crate::ctypes::c_long;
6+
pub type __kernel_ulong_t = crate::ctypes::c_ulong;
7+
pub type __kernel_ino_t = __kernel_ulong_t;
8+
pub type __kernel_mode_t = crate::ctypes::c_uint;
9+
pub type __kernel_pid_t = crate::ctypes::c_int;
10+
pub type __kernel_ipc_pid_t = crate::ctypes::c_int;
11+
pub type __kernel_uid_t = crate::ctypes::c_uint;
12+
pub type __kernel_gid_t = crate::ctypes::c_uint;
13+
pub type __kernel_suseconds_t = __kernel_long_t;
14+
pub type __kernel_daddr_t = crate::ctypes::c_int;
15+
pub type __kernel_uid32_t = crate::ctypes::c_uint;
16+
pub type __kernel_gid32_t = crate::ctypes::c_uint;
17+
pub type __kernel_old_dev_t = crate::ctypes::c_uint;
18+
pub type __kernel_size_t = __kernel_ulong_t;
19+
pub type __kernel_ssize_t = __kernel_long_t;
20+
pub type __kernel_ptrdiff_t = __kernel_long_t;
21+
pub type __kernel_off_t = __kernel_long_t;
22+
pub type __kernel_loff_t = crate::ctypes::c_longlong;
23+
pub type __kernel_old_time_t = __kernel_long_t;
24+
pub type __kernel_time_t = __kernel_long_t;
25+
pub type __kernel_time64_t = crate::ctypes::c_longlong;
26+
pub type __kernel_clock_t = __kernel_long_t;
27+
pub type __kernel_timer_t = crate::ctypes::c_int;
28+
pub type __kernel_clockid_t = crate::ctypes::c_int;
29+
pub type __kernel_caddr_t = *mut crate::ctypes::c_char;
30+
pub type __kernel_uid16_t = crate::ctypes::c_ushort;
31+
pub type __kernel_gid16_t = crate::ctypes::c_ushort;
32+
pub type __s8 = crate::ctypes::c_schar;
33+
pub type __u8 = crate::ctypes::c_uchar;
34+
pub type __s16 = crate::ctypes::c_short;
35+
pub type __u16 = crate::ctypes::c_ushort;
36+
pub type __s32 = crate::ctypes::c_int;
37+
pub type __u32 = crate::ctypes::c_uint;
38+
pub type __s64 = crate::ctypes::c_longlong;
39+
pub type __u64 = crate::ctypes::c_ulonglong;
40+
pub type __kernel_key_t = crate::ctypes::c_int;
41+
pub type __kernel_mqd_t = crate::ctypes::c_int;
42+
pub type __s128 = i128;
43+
pub type __u128 = u128;
44+
pub type __le16 = __u16;
45+
pub type __be16 = __u16;
46+
pub type __le32 = __u32;
47+
pub type __be32 = __u32;
48+
pub type __le64 = __u64;
49+
pub type __be64 = __u64;
50+
pub type __sum16 = __u16;
51+
pub type __wsum = __u32;
52+
pub type __poll_t = crate::ctypes::c_uint;
53+
#[repr(C)]
54+
#[derive(Debug, Copy, Clone)]
55+
pub struct loop_info {
56+
pub lo_number: crate::ctypes::c_int,
57+
pub lo_device: __kernel_old_dev_t,
58+
pub lo_inode: crate::ctypes::c_ulong,
59+
pub lo_rdevice: __kernel_old_dev_t,
60+
pub lo_offset: crate::ctypes::c_int,
61+
pub lo_encrypt_type: crate::ctypes::c_int,
62+
pub lo_encrypt_key_size: crate::ctypes::c_int,
63+
pub lo_flags: crate::ctypes::c_int,
64+
pub lo_name: [crate::ctypes::c_char; 64usize],
65+
pub lo_encrypt_key: [crate::ctypes::c_uchar; 32usize],
66+
pub lo_init: [crate::ctypes::c_ulong; 2usize],
67+
pub reserved: [crate::ctypes::c_char; 4usize],
68+
}
69+
#[repr(C)]
70+
#[derive(Debug, Copy, Clone)]
71+
pub struct loop_info64 {
72+
pub lo_device: __u64,
73+
pub lo_inode: __u64,
74+
pub lo_rdevice: __u64,
75+
pub lo_offset: __u64,
76+
pub lo_sizelimit: __u64,
77+
pub lo_number: __u32,
78+
pub lo_encrypt_type: __u32,
79+
pub lo_encrypt_key_size: __u32,
80+
pub lo_flags: __u32,
81+
pub lo_file_name: [__u8; 64usize],
82+
pub lo_crypt_name: [__u8; 64usize],
83+
pub lo_encrypt_key: [__u8; 32usize],
84+
pub lo_init: [__u64; 2usize],
85+
}
86+
#[repr(C)]
87+
#[derive(Debug, Copy, Clone)]
88+
pub struct loop_config {
89+
pub fd: __u32,
90+
pub block_size: __u32,
91+
pub info: loop_info64,
92+
pub __reserved: [__u64; 8usize],
93+
}
94+
pub const LO_NAME_SIZE: u32 = 64;
95+
pub const LO_KEY_SIZE: u32 = 32;
96+
pub const LO_CRYPT_NONE: u32 = 0;
97+
pub const LO_CRYPT_XOR: u32 = 1;
98+
pub const LO_CRYPT_DES: u32 = 2;
99+
pub const LO_CRYPT_FISH2: u32 = 3;
100+
pub const LO_CRYPT_BLOW: u32 = 4;
101+
pub const LO_CRYPT_CAST128: u32 = 5;
102+
pub const LO_CRYPT_IDEA: u32 = 6;
103+
pub const LO_CRYPT_DUMMY: u32 = 9;
104+
pub const LO_CRYPT_SKIPJACK: u32 = 10;
105+
pub const LO_CRYPT_CRYPTOAPI: u32 = 18;
106+
pub const MAX_LO_CRYPT: u32 = 20;
107+
pub const LOOP_SET_FD: u32 = 19456;
108+
pub const LOOP_CLR_FD: u32 = 19457;
109+
pub const LOOP_SET_STATUS: u32 = 19458;
110+
pub const LOOP_GET_STATUS: u32 = 19459;
111+
pub const LOOP_SET_STATUS64: u32 = 19460;
112+
pub const LOOP_GET_STATUS64: u32 = 19461;
113+
pub const LOOP_CHANGE_FD: u32 = 19462;
114+
pub const LOOP_SET_CAPACITY: u32 = 19463;
115+
pub const LOOP_SET_DIRECT_IO: u32 = 19464;
116+
pub const LOOP_SET_BLOCK_SIZE: u32 = 19465;
117+
pub const LOOP_CONFIGURE: u32 = 19466;
118+
pub const LOOP_CTL_ADD: u32 = 19584;
119+
pub const LOOP_CTL_REMOVE: u32 = 19585;
120+
pub const LOOP_CTL_GET_FREE: u32 = 19586;
121+
pub const LO_FLAGS_READ_ONLY: _bindgen_ty_1 = _bindgen_ty_1::LO_FLAGS_READ_ONLY;
122+
pub const LO_FLAGS_AUTOCLEAR: _bindgen_ty_1 = _bindgen_ty_1::LO_FLAGS_AUTOCLEAR;
123+
pub const LO_FLAGS_PARTSCAN: _bindgen_ty_1 = _bindgen_ty_1::LO_FLAGS_PARTSCAN;
124+
pub const LO_FLAGS_DIRECT_IO: _bindgen_ty_1 = _bindgen_ty_1::LO_FLAGS_DIRECT_IO;
125+
#[repr(u32)]
126+
#[non_exhaustive]
127+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
128+
pub enum _bindgen_ty_1 {
129+
LO_FLAGS_READ_ONLY = 1,
130+
LO_FLAGS_AUTOCLEAR = 4,
131+
LO_FLAGS_PARTSCAN = 8,
132+
LO_FLAGS_DIRECT_IO = 16,
133+
}

src/arm/loop_device.rs

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/* automatically generated by rust-bindgen 0.66.1 */
2+
3+
pub type __kernel_mode_t = crate::ctypes::c_ushort;
4+
pub type __kernel_ipc_pid_t = crate::ctypes::c_ushort;
5+
pub type __kernel_uid_t = crate::ctypes::c_ushort;
6+
pub type __kernel_gid_t = crate::ctypes::c_ushort;
7+
pub type __kernel_old_dev_t = crate::ctypes::c_ushort;
8+
pub type __kernel_long_t = crate::ctypes::c_long;
9+
pub type __kernel_ulong_t = crate::ctypes::c_ulong;
10+
pub type __kernel_ino_t = __kernel_ulong_t;
11+
pub type __kernel_pid_t = crate::ctypes::c_int;
12+
pub type __kernel_suseconds_t = __kernel_long_t;
13+
pub type __kernel_daddr_t = crate::ctypes::c_int;
14+
pub type __kernel_uid32_t = crate::ctypes::c_uint;
15+
pub type __kernel_gid32_t = crate::ctypes::c_uint;
16+
pub type __kernel_old_uid_t = __kernel_uid_t;
17+
pub type __kernel_old_gid_t = __kernel_gid_t;
18+
pub type __kernel_size_t = crate::ctypes::c_uint;
19+
pub type __kernel_ssize_t = crate::ctypes::c_int;
20+
pub type __kernel_ptrdiff_t = crate::ctypes::c_int;
21+
pub type __kernel_off_t = __kernel_long_t;
22+
pub type __kernel_loff_t = crate::ctypes::c_longlong;
23+
pub type __kernel_old_time_t = __kernel_long_t;
24+
pub type __kernel_time_t = __kernel_long_t;
25+
pub type __kernel_time64_t = crate::ctypes::c_longlong;
26+
pub type __kernel_clock_t = __kernel_long_t;
27+
pub type __kernel_timer_t = crate::ctypes::c_int;
28+
pub type __kernel_clockid_t = crate::ctypes::c_int;
29+
pub type __kernel_caddr_t = *mut crate::ctypes::c_char;
30+
pub type __kernel_uid16_t = crate::ctypes::c_ushort;
31+
pub type __kernel_gid16_t = crate::ctypes::c_ushort;
32+
pub type __s8 = crate::ctypes::c_schar;
33+
pub type __u8 = crate::ctypes::c_uchar;
34+
pub type __s16 = crate::ctypes::c_short;
35+
pub type __u16 = crate::ctypes::c_ushort;
36+
pub type __s32 = crate::ctypes::c_int;
37+
pub type __u32 = crate::ctypes::c_uint;
38+
pub type __s64 = crate::ctypes::c_longlong;
39+
pub type __u64 = crate::ctypes::c_ulonglong;
40+
pub type __kernel_key_t = crate::ctypes::c_int;
41+
pub type __kernel_mqd_t = crate::ctypes::c_int;
42+
pub type __le16 = __u16;
43+
pub type __be16 = __u16;
44+
pub type __le32 = __u32;
45+
pub type __be32 = __u32;
46+
pub type __le64 = __u64;
47+
pub type __be64 = __u64;
48+
pub type __sum16 = __u16;
49+
pub type __wsum = __u32;
50+
pub type __poll_t = crate::ctypes::c_uint;
51+
#[repr(C)]
52+
#[derive(Debug, Copy, Clone)]
53+
pub struct loop_info {
54+
pub lo_number: crate::ctypes::c_int,
55+
pub lo_device: __kernel_old_dev_t,
56+
pub lo_inode: crate::ctypes::c_ulong,
57+
pub lo_rdevice: __kernel_old_dev_t,
58+
pub lo_offset: crate::ctypes::c_int,
59+
pub lo_encrypt_type: crate::ctypes::c_int,
60+
pub lo_encrypt_key_size: crate::ctypes::c_int,
61+
pub lo_flags: crate::ctypes::c_int,
62+
pub lo_name: [crate::ctypes::c_char; 64usize],
63+
pub lo_encrypt_key: [crate::ctypes::c_uchar; 32usize],
64+
pub lo_init: [crate::ctypes::c_ulong; 2usize],
65+
pub reserved: [crate::ctypes::c_char; 4usize],
66+
}
67+
#[repr(C)]
68+
#[derive(Debug, Copy, Clone)]
69+
pub struct loop_info64 {
70+
pub lo_device: __u64,
71+
pub lo_inode: __u64,
72+
pub lo_rdevice: __u64,
73+
pub lo_offset: __u64,
74+
pub lo_sizelimit: __u64,
75+
pub lo_number: __u32,
76+
pub lo_encrypt_type: __u32,
77+
pub lo_encrypt_key_size: __u32,
78+
pub lo_flags: __u32,
79+
pub lo_file_name: [__u8; 64usize],
80+
pub lo_crypt_name: [__u8; 64usize],
81+
pub lo_encrypt_key: [__u8; 32usize],
82+
pub lo_init: [__u64; 2usize],
83+
}
84+
#[repr(C)]
85+
#[derive(Debug, Copy, Clone)]
86+
pub struct loop_config {
87+
pub fd: __u32,
88+
pub block_size: __u32,
89+
pub info: loop_info64,
90+
pub __reserved: [__u64; 8usize],
91+
}
92+
pub const LO_NAME_SIZE: u32 = 64;
93+
pub const LO_KEY_SIZE: u32 = 32;
94+
pub const LO_CRYPT_NONE: u32 = 0;
95+
pub const LO_CRYPT_XOR: u32 = 1;
96+
pub const LO_CRYPT_DES: u32 = 2;
97+
pub const LO_CRYPT_FISH2: u32 = 3;
98+
pub const LO_CRYPT_BLOW: u32 = 4;
99+
pub const LO_CRYPT_CAST128: u32 = 5;
100+
pub const LO_CRYPT_IDEA: u32 = 6;
101+
pub const LO_CRYPT_DUMMY: u32 = 9;
102+
pub const LO_CRYPT_SKIPJACK: u32 = 10;
103+
pub const LO_CRYPT_CRYPTOAPI: u32 = 18;
104+
pub const MAX_LO_CRYPT: u32 = 20;
105+
pub const LOOP_SET_FD: u32 = 19456;
106+
pub const LOOP_CLR_FD: u32 = 19457;
107+
pub const LOOP_SET_STATUS: u32 = 19458;
108+
pub const LOOP_GET_STATUS: u32 = 19459;
109+
pub const LOOP_SET_STATUS64: u32 = 19460;
110+
pub const LOOP_GET_STATUS64: u32 = 19461;
111+
pub const LOOP_CHANGE_FD: u32 = 19462;
112+
pub const LOOP_SET_CAPACITY: u32 = 19463;
113+
pub const LOOP_SET_DIRECT_IO: u32 = 19464;
114+
pub const LOOP_SET_BLOCK_SIZE: u32 = 19465;
115+
pub const LOOP_CONFIGURE: u32 = 19466;
116+
pub const LOOP_CTL_ADD: u32 = 19584;
117+
pub const LOOP_CTL_REMOVE: u32 = 19585;
118+
pub const LOOP_CTL_GET_FREE: u32 = 19586;
119+
pub const LO_FLAGS_READ_ONLY: _bindgen_ty_1 = _bindgen_ty_1::LO_FLAGS_READ_ONLY;
120+
pub const LO_FLAGS_AUTOCLEAR: _bindgen_ty_1 = _bindgen_ty_1::LO_FLAGS_AUTOCLEAR;
121+
pub const LO_FLAGS_PARTSCAN: _bindgen_ty_1 = _bindgen_ty_1::LO_FLAGS_PARTSCAN;
122+
pub const LO_FLAGS_DIRECT_IO: _bindgen_ty_1 = _bindgen_ty_1::LO_FLAGS_DIRECT_IO;
123+
#[repr(u32)]
124+
#[non_exhaustive]
125+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
126+
pub enum _bindgen_ty_1 {
127+
LO_FLAGS_READ_ONLY = 1,
128+
LO_FLAGS_AUTOCLEAR = 4,
129+
LO_FLAGS_PARTSCAN = 8,
130+
LO_FLAGS_DIRECT_IO = 16,
131+
}

0 commit comments

Comments
 (0)