Skip to content

Commit 24e3aba

Browse files
authored
Add support for vm_sockets.h (#177)
The vm_sockets.h header contains sockaddr_vm, which is needed for setting up `AF_VSOCK` sockets. Signed-off-by: John Nunley <dev@notgull.net>
1 parent e730548 commit 24e3aba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2266
-19
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ netlink = []
5252
prctl = []
5353
ptrace = []
5454
system = []
55+
vm_sockets = []
5556
xdp = []
5657
default = ["std", "general", "errno"]
5758
std = []

gen/modules/vm_sockets.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Code needed for vm_sockets.h
2+
3+
#include "support.h"
4+
5+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
6+
#define sa_family_t uint16_t
7+
#include <linux/socket.h>
8+
#include <linux/vm_sockets.h>
9+
#endif
10+

src/aarch64/btrfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ pub dirid: __u64,
741741
#[repr(C)]
742742
#[derive(Debug, Copy, Clone)]
743743
pub struct btrfs_ioctl_encoded_io_args {
744-
pub iov: *const iovec,
744+
pub iov: *mut iovec,
745745
pub iovcnt: crate::ctypes::c_ulong,
746746
pub offset: __s64,
747747
pub flags: __u64,

src/aarch64/vm_sockets.rs

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* automatically generated by rust-bindgen 0.72.1 */
2+
3+
pub type __kernel_sa_family_t = crate::ctypes::c_ushort;
4+
pub type __s8 = crate::ctypes::c_schar;
5+
pub type __u8 = crate::ctypes::c_uchar;
6+
pub type __s16 = crate::ctypes::c_short;
7+
pub type __u16 = crate::ctypes::c_ushort;
8+
pub type __s32 = crate::ctypes::c_int;
9+
pub type __u32 = crate::ctypes::c_uint;
10+
pub type __s64 = crate::ctypes::c_longlong;
11+
pub type __u64 = crate::ctypes::c_ulonglong;
12+
pub type __kernel_key_t = crate::ctypes::c_int;
13+
pub type __kernel_mqd_t = crate::ctypes::c_int;
14+
pub type __kernel_old_uid_t = crate::ctypes::c_ushort;
15+
pub type __kernel_old_gid_t = crate::ctypes::c_ushort;
16+
pub type __kernel_long_t = crate::ctypes::c_long;
17+
pub type __kernel_ulong_t = crate::ctypes::c_ulong;
18+
pub type __kernel_ino_t = __kernel_ulong_t;
19+
pub type __kernel_mode_t = crate::ctypes::c_uint;
20+
pub type __kernel_pid_t = crate::ctypes::c_int;
21+
pub type __kernel_ipc_pid_t = crate::ctypes::c_int;
22+
pub type __kernel_uid_t = crate::ctypes::c_uint;
23+
pub type __kernel_gid_t = crate::ctypes::c_uint;
24+
pub type __kernel_suseconds_t = __kernel_long_t;
25+
pub type __kernel_daddr_t = crate::ctypes::c_int;
26+
pub type __kernel_uid32_t = crate::ctypes::c_uint;
27+
pub type __kernel_gid32_t = crate::ctypes::c_uint;
28+
pub type __kernel_old_dev_t = crate::ctypes::c_uint;
29+
pub type __kernel_size_t = __kernel_ulong_t;
30+
pub type __kernel_ssize_t = __kernel_long_t;
31+
pub type __kernel_ptrdiff_t = __kernel_long_t;
32+
pub type __kernel_off_t = __kernel_long_t;
33+
pub type __kernel_loff_t = crate::ctypes::c_longlong;
34+
pub type __kernel_old_time_t = __kernel_long_t;
35+
pub type __kernel_time_t = __kernel_long_t;
36+
pub type __kernel_time64_t = crate::ctypes::c_longlong;
37+
pub type __kernel_clock_t = __kernel_long_t;
38+
pub type __kernel_timer_t = crate::ctypes::c_int;
39+
pub type __kernel_clockid_t = crate::ctypes::c_int;
40+
pub type __kernel_caddr_t = *mut crate::ctypes::c_char;
41+
pub type __kernel_uid16_t = crate::ctypes::c_ushort;
42+
pub type __kernel_gid16_t = crate::ctypes::c_ushort;
43+
pub type __s128 = i128;
44+
pub type __u128 = u128;
45+
pub type __le16 = __u16;
46+
pub type __be16 = __u16;
47+
pub type __le32 = __u32;
48+
pub type __be32 = __u32;
49+
pub type __le64 = __u64;
50+
pub type __be64 = __u64;
51+
pub type __sum16 = __u16;
52+
pub type __wsum = __u32;
53+
pub type __poll_t = crate::ctypes::c_uint;
54+
#[repr(C)]
55+
#[derive(Copy, Clone)]
56+
pub struct __kernel_sockaddr_storage {
57+
pub __bindgen_anon_1: __kernel_sockaddr_storage__bindgen_ty_1,
58+
}
59+
#[repr(C)]
60+
#[derive(Debug, Copy, Clone)]
61+
pub struct __kernel_sockaddr_storage__bindgen_ty_1__bindgen_ty_1 {
62+
pub ss_family: __kernel_sa_family_t,
63+
pub __data: [crate::ctypes::c_char; 126usize],
64+
}
65+
#[repr(C)]
66+
#[derive(Copy, Clone)]
67+
pub struct sockaddr {
68+
pub __storage: __kernel_sockaddr_storage,
69+
}
70+
#[repr(C)]
71+
#[derive(Debug, Copy, Clone)]
72+
pub struct sockaddr_vm {
73+
pub svm_family: __kernel_sa_family_t,
74+
pub svm_reserved1: crate::ctypes::c_ushort,
75+
pub svm_port: crate::ctypes::c_uint,
76+
pub svm_cid: crate::ctypes::c_uint,
77+
pub svm_flags: __u8,
78+
pub svm_zero: [crate::ctypes::c_uchar; 115usize],
79+
}
80+
pub const _K_SS_MAXSIZE: u32 = 128;
81+
pub const SOCK_SNDBUF_LOCK: u32 = 1;
82+
pub const SOCK_RCVBUF_LOCK: u32 = 2;
83+
pub const SOCK_BUF_LOCK_MASK: u32 = 3;
84+
pub const SOCK_TXREHASH_DEFAULT: u32 = 255;
85+
pub const SOCK_TXREHASH_DISABLED: u32 = 0;
86+
pub const SOCK_TXREHASH_ENABLED: u32 = 1;
87+
pub const __BITS_PER_LONG_LONG: u32 = 64;
88+
pub const SO_VM_SOCKETS_BUFFER_SIZE: u32 = 0;
89+
pub const SO_VM_SOCKETS_BUFFER_MIN_SIZE: u32 = 1;
90+
pub const SO_VM_SOCKETS_BUFFER_MAX_SIZE: u32 = 2;
91+
pub const SO_VM_SOCKETS_PEER_HOST_VM_ID: u32 = 3;
92+
pub const SO_VM_SOCKETS_TRUSTED: u32 = 5;
93+
pub const SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD: u32 = 6;
94+
pub const SO_VM_SOCKETS_NONBLOCK_TXRX: u32 = 7;
95+
pub const SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW: u32 = 8;
96+
pub const SO_VM_SOCKETS_CONNECT_TIMEOUT: u32 = 6;
97+
pub const VMADDR_CID_ANY: i32 = -1;
98+
pub const VMADDR_PORT_ANY: i32 = -1;
99+
pub const VMADDR_CID_HYPERVISOR: u32 = 0;
100+
pub const VMADDR_CID_LOCAL: u32 = 1;
101+
pub const VMADDR_CID_HOST: u32 = 2;
102+
pub const VMADDR_FLAG_TO_HOST: u32 = 1;
103+
pub const VM_SOCKETS_INVALID_VERSION: i32 = -1;
104+
pub const SOL_VSOCK: u32 = 287;
105+
pub const VSOCK_RECVERR: u32 = 1;
106+
#[repr(C)]
107+
#[derive(Copy, Clone)]
108+
pub union __kernel_sockaddr_storage__bindgen_ty_1 {
109+
pub __bindgen_anon_1: __kernel_sockaddr_storage__bindgen_ty_1__bindgen_ty_1,
110+
pub __align: *mut crate::ctypes::c_void,
111+
}

src/arm/btrfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ pub dirid: __u64,
739739
#[repr(C)]
740740
#[derive(Debug, Copy, Clone)]
741741
pub struct btrfs_ioctl_encoded_io_args {
742-
pub iov: *const iovec,
742+
pub iov: *mut iovec,
743743
pub iovcnt: crate::ctypes::c_ulong,
744744
pub offset: __s64,
745745
pub flags: __u64,

src/arm/vm_sockets.rs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* automatically generated by rust-bindgen 0.72.1 */
2+
3+
pub type __kernel_sa_family_t = crate::ctypes::c_ushort;
4+
pub type __s8 = crate::ctypes::c_schar;
5+
pub type __u8 = crate::ctypes::c_uchar;
6+
pub type __s16 = crate::ctypes::c_short;
7+
pub type __u16 = crate::ctypes::c_ushort;
8+
pub type __s32 = crate::ctypes::c_int;
9+
pub type __u32 = crate::ctypes::c_uint;
10+
pub type __s64 = crate::ctypes::c_longlong;
11+
pub type __u64 = crate::ctypes::c_ulonglong;
12+
pub type __kernel_key_t = crate::ctypes::c_int;
13+
pub type __kernel_mqd_t = crate::ctypes::c_int;
14+
pub type __kernel_mode_t = crate::ctypes::c_ushort;
15+
pub type __kernel_ipc_pid_t = crate::ctypes::c_ushort;
16+
pub type __kernel_uid_t = crate::ctypes::c_ushort;
17+
pub type __kernel_gid_t = crate::ctypes::c_ushort;
18+
pub type __kernel_old_dev_t = crate::ctypes::c_ushort;
19+
pub type __kernel_long_t = crate::ctypes::c_long;
20+
pub type __kernel_ulong_t = crate::ctypes::c_ulong;
21+
pub type __kernel_ino_t = __kernel_ulong_t;
22+
pub type __kernel_pid_t = crate::ctypes::c_int;
23+
pub type __kernel_suseconds_t = __kernel_long_t;
24+
pub type __kernel_daddr_t = crate::ctypes::c_int;
25+
pub type __kernel_uid32_t = crate::ctypes::c_uint;
26+
pub type __kernel_gid32_t = crate::ctypes::c_uint;
27+
pub type __kernel_old_uid_t = __kernel_uid_t;
28+
pub type __kernel_old_gid_t = __kernel_gid_t;
29+
pub type __kernel_size_t = crate::ctypes::c_uint;
30+
pub type __kernel_ssize_t = crate::ctypes::c_int;
31+
pub type __kernel_ptrdiff_t = crate::ctypes::c_int;
32+
pub type __kernel_off_t = __kernel_long_t;
33+
pub type __kernel_loff_t = crate::ctypes::c_longlong;
34+
pub type __kernel_old_time_t = __kernel_long_t;
35+
pub type __kernel_time_t = __kernel_long_t;
36+
pub type __kernel_time64_t = crate::ctypes::c_longlong;
37+
pub type __kernel_clock_t = __kernel_long_t;
38+
pub type __kernel_timer_t = crate::ctypes::c_int;
39+
pub type __kernel_clockid_t = crate::ctypes::c_int;
40+
pub type __kernel_caddr_t = *mut crate::ctypes::c_char;
41+
pub type __kernel_uid16_t = crate::ctypes::c_ushort;
42+
pub type __kernel_gid16_t = crate::ctypes::c_ushort;
43+
pub type __le16 = __u16;
44+
pub type __be16 = __u16;
45+
pub type __le32 = __u32;
46+
pub type __be32 = __u32;
47+
pub type __le64 = __u64;
48+
pub type __be64 = __u64;
49+
pub type __sum16 = __u16;
50+
pub type __wsum = __u32;
51+
pub type __poll_t = crate::ctypes::c_uint;
52+
#[repr(C)]
53+
#[derive(Copy, Clone)]
54+
pub struct __kernel_sockaddr_storage {
55+
pub __bindgen_anon_1: __kernel_sockaddr_storage__bindgen_ty_1,
56+
}
57+
#[repr(C)]
58+
#[derive(Debug, Copy, Clone)]
59+
pub struct __kernel_sockaddr_storage__bindgen_ty_1__bindgen_ty_1 {
60+
pub ss_family: __kernel_sa_family_t,
61+
pub __data: [crate::ctypes::c_char; 126usize],
62+
}
63+
#[repr(C)]
64+
#[derive(Copy, Clone)]
65+
pub struct sockaddr {
66+
pub __storage: __kernel_sockaddr_storage,
67+
}
68+
#[repr(C)]
69+
#[derive(Debug, Copy, Clone)]
70+
pub struct sockaddr_vm {
71+
pub svm_family: __kernel_sa_family_t,
72+
pub svm_reserved1: crate::ctypes::c_ushort,
73+
pub svm_port: crate::ctypes::c_uint,
74+
pub svm_cid: crate::ctypes::c_uint,
75+
pub svm_flags: __u8,
76+
pub svm_zero: [crate::ctypes::c_uchar; 115usize],
77+
}
78+
pub const _K_SS_MAXSIZE: u32 = 128;
79+
pub const SOCK_SNDBUF_LOCK: u32 = 1;
80+
pub const SOCK_RCVBUF_LOCK: u32 = 2;
81+
pub const SOCK_BUF_LOCK_MASK: u32 = 3;
82+
pub const SOCK_TXREHASH_DEFAULT: u32 = 255;
83+
pub const SOCK_TXREHASH_DISABLED: u32 = 0;
84+
pub const SOCK_TXREHASH_ENABLED: u32 = 1;
85+
pub const __BITS_PER_LONG_LONG: u32 = 64;
86+
pub const SO_VM_SOCKETS_BUFFER_SIZE: u32 = 0;
87+
pub const SO_VM_SOCKETS_BUFFER_MIN_SIZE: u32 = 1;
88+
pub const SO_VM_SOCKETS_BUFFER_MAX_SIZE: u32 = 2;
89+
pub const SO_VM_SOCKETS_PEER_HOST_VM_ID: u32 = 3;
90+
pub const SO_VM_SOCKETS_TRUSTED: u32 = 5;
91+
pub const SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD: u32 = 6;
92+
pub const SO_VM_SOCKETS_NONBLOCK_TXRX: u32 = 7;
93+
pub const SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW: u32 = 8;
94+
pub const VMADDR_CID_ANY: i32 = -1;
95+
pub const VMADDR_PORT_ANY: i32 = -1;
96+
pub const VMADDR_CID_HYPERVISOR: u32 = 0;
97+
pub const VMADDR_CID_LOCAL: u32 = 1;
98+
pub const VMADDR_CID_HOST: u32 = 2;
99+
pub const VMADDR_FLAG_TO_HOST: u32 = 1;
100+
pub const VM_SOCKETS_INVALID_VERSION: i32 = -1;
101+
pub const SOL_VSOCK: u32 = 287;
102+
pub const VSOCK_RECVERR: u32 = 1;
103+
#[repr(C)]
104+
#[derive(Copy, Clone)]
105+
pub union __kernel_sockaddr_storage__bindgen_ty_1 {
106+
pub __bindgen_anon_1: __kernel_sockaddr_storage__bindgen_ty_1__bindgen_ty_1,
107+
pub __align: *mut crate::ctypes::c_void,
108+
}

src/csky/btrfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ pub dirid: __u64,
739739
#[repr(C)]
740740
#[derive(Debug, Copy, Clone)]
741741
pub struct btrfs_ioctl_encoded_io_args {
742-
pub iov: *const iovec,
742+
pub iov: *mut iovec,
743743
pub iovcnt: crate::ctypes::c_ulong,
744744
pub offset: __s64,
745745
pub flags: __u64,

src/csky/vm_sockets.rs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* automatically generated by rust-bindgen 0.72.1 */
2+
3+
pub type __kernel_sa_family_t = crate::ctypes::c_ushort;
4+
pub type __s8 = crate::ctypes::c_schar;
5+
pub type __u8 = crate::ctypes::c_uchar;
6+
pub type __s16 = crate::ctypes::c_short;
7+
pub type __u16 = crate::ctypes::c_ushort;
8+
pub type __s32 = crate::ctypes::c_int;
9+
pub type __u32 = crate::ctypes::c_uint;
10+
pub type __s64 = crate::ctypes::c_longlong;
11+
pub type __u64 = crate::ctypes::c_ulonglong;
12+
pub type __kernel_key_t = crate::ctypes::c_int;
13+
pub type __kernel_mqd_t = crate::ctypes::c_int;
14+
pub type __kernel_long_t = crate::ctypes::c_long;
15+
pub type __kernel_ulong_t = crate::ctypes::c_ulong;
16+
pub type __kernel_ino_t = __kernel_ulong_t;
17+
pub type __kernel_mode_t = crate::ctypes::c_uint;
18+
pub type __kernel_pid_t = crate::ctypes::c_int;
19+
pub type __kernel_ipc_pid_t = crate::ctypes::c_int;
20+
pub type __kernel_uid_t = crate::ctypes::c_uint;
21+
pub type __kernel_gid_t = crate::ctypes::c_uint;
22+
pub type __kernel_suseconds_t = __kernel_long_t;
23+
pub type __kernel_daddr_t = crate::ctypes::c_int;
24+
pub type __kernel_uid32_t = crate::ctypes::c_uint;
25+
pub type __kernel_gid32_t = crate::ctypes::c_uint;
26+
pub type __kernel_old_uid_t = __kernel_uid_t;
27+
pub type __kernel_old_gid_t = __kernel_gid_t;
28+
pub type __kernel_old_dev_t = crate::ctypes::c_uint;
29+
pub type __kernel_size_t = crate::ctypes::c_uint;
30+
pub type __kernel_ssize_t = crate::ctypes::c_int;
31+
pub type __kernel_ptrdiff_t = crate::ctypes::c_int;
32+
pub type __kernel_off_t = __kernel_long_t;
33+
pub type __kernel_loff_t = crate::ctypes::c_longlong;
34+
pub type __kernel_old_time_t = __kernel_long_t;
35+
pub type __kernel_time_t = __kernel_long_t;
36+
pub type __kernel_time64_t = crate::ctypes::c_longlong;
37+
pub type __kernel_clock_t = __kernel_long_t;
38+
pub type __kernel_timer_t = crate::ctypes::c_int;
39+
pub type __kernel_clockid_t = crate::ctypes::c_int;
40+
pub type __kernel_caddr_t = *mut crate::ctypes::c_char;
41+
pub type __kernel_uid16_t = crate::ctypes::c_ushort;
42+
pub type __kernel_gid16_t = crate::ctypes::c_ushort;
43+
pub type __le16 = __u16;
44+
pub type __be16 = __u16;
45+
pub type __le32 = __u32;
46+
pub type __be32 = __u32;
47+
pub type __le64 = __u64;
48+
pub type __be64 = __u64;
49+
pub type __sum16 = __u16;
50+
pub type __wsum = __u32;
51+
pub type __poll_t = crate::ctypes::c_uint;
52+
#[repr(C)]
53+
#[derive(Copy, Clone)]
54+
pub struct __kernel_sockaddr_storage {
55+
pub __bindgen_anon_1: __kernel_sockaddr_storage__bindgen_ty_1,
56+
}
57+
#[repr(C)]
58+
#[derive(Debug, Copy, Clone)]
59+
pub struct __kernel_sockaddr_storage__bindgen_ty_1__bindgen_ty_1 {
60+
pub ss_family: __kernel_sa_family_t,
61+
pub __data: [crate::ctypes::c_char; 126usize],
62+
}
63+
#[repr(C)]
64+
#[derive(Copy, Clone)]
65+
pub struct sockaddr {
66+
pub __storage: __kernel_sockaddr_storage,
67+
}
68+
#[repr(C)]
69+
#[derive(Debug, Copy, Clone)]
70+
pub struct sockaddr_vm {
71+
pub svm_family: __kernel_sa_family_t,
72+
pub svm_reserved1: crate::ctypes::c_ushort,
73+
pub svm_port: crate::ctypes::c_uint,
74+
pub svm_cid: crate::ctypes::c_uint,
75+
pub svm_flags: __u8,
76+
pub svm_zero: [crate::ctypes::c_uchar; 115usize],
77+
}
78+
pub const _K_SS_MAXSIZE: u32 = 128;
79+
pub const SOCK_SNDBUF_LOCK: u32 = 1;
80+
pub const SOCK_RCVBUF_LOCK: u32 = 2;
81+
pub const SOCK_BUF_LOCK_MASK: u32 = 3;
82+
pub const SOCK_TXREHASH_DEFAULT: u32 = 255;
83+
pub const SOCK_TXREHASH_DISABLED: u32 = 0;
84+
pub const SOCK_TXREHASH_ENABLED: u32 = 1;
85+
pub const __BITS_PER_LONG_LONG: u32 = 64;
86+
pub const SO_VM_SOCKETS_BUFFER_SIZE: u32 = 0;
87+
pub const SO_VM_SOCKETS_BUFFER_MIN_SIZE: u32 = 1;
88+
pub const SO_VM_SOCKETS_BUFFER_MAX_SIZE: u32 = 2;
89+
pub const SO_VM_SOCKETS_PEER_HOST_VM_ID: u32 = 3;
90+
pub const SO_VM_SOCKETS_TRUSTED: u32 = 5;
91+
pub const SO_VM_SOCKETS_CONNECT_TIMEOUT_OLD: u32 = 6;
92+
pub const SO_VM_SOCKETS_NONBLOCK_TXRX: u32 = 7;
93+
pub const SO_VM_SOCKETS_CONNECT_TIMEOUT_NEW: u32 = 8;
94+
pub const VMADDR_CID_ANY: i32 = -1;
95+
pub const VMADDR_PORT_ANY: i32 = -1;
96+
pub const VMADDR_CID_HYPERVISOR: u32 = 0;
97+
pub const VMADDR_CID_LOCAL: u32 = 1;
98+
pub const VMADDR_CID_HOST: u32 = 2;
99+
pub const VMADDR_FLAG_TO_HOST: u32 = 1;
100+
pub const VM_SOCKETS_INVALID_VERSION: i32 = -1;
101+
pub const SOL_VSOCK: u32 = 287;
102+
pub const VSOCK_RECVERR: u32 = 1;
103+
#[repr(C)]
104+
#[derive(Copy, Clone)]
105+
pub union __kernel_sockaddr_storage__bindgen_ty_1 {
106+
pub __bindgen_anon_1: __kernel_sockaddr_storage__bindgen_ty_1__bindgen_ty_1,
107+
pub __align: *mut crate::ctypes::c_void,
108+
}

src/hexagon/btrfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ pub dirid: __u64,
739739
#[repr(C)]
740740
#[derive(Debug, Copy, Clone)]
741741
pub struct btrfs_ioctl_encoded_io_args {
742-
pub iov: *const iovec,
742+
pub iov: *mut iovec,
743743
pub iovcnt: crate::ctypes::c_ulong,
744744
pub offset: __s64,
745745
pub flags: __u64,

0 commit comments

Comments
 (0)