Poke-a-hole and friends. The pahole man page.
Create vmlinux.h header
pahole --compile | sed 's,single double,double ,' > vmlinux.h
Create vmlinux.zig module
zig translate-c -lc vmlinux.h > vmlinux.zig
Test program
const vmlinux = @import("vmlinux.zig");
const print = @import("std").debug.print;
pub fn main() void {
const proc_ops: vmlinux.struct_proc_ops = .{ .proc_flags = 0 };
const file_ops: vmlinux.struct_file_operations = .{ .owner = null };
print("{}\n", .{proc_ops});
print("{}\n", .{file_ops});
}
Run
zig run test.zig
Enjoy
.{ .proc_flags = 0, .proc_open = null, .proc_read = null, .proc_read_iter = null, .proc_write = null, .proc_lseek = null, .proc_release = null, .proc_poll = null, .proc_ioctl = null, .proc_compat_ioctl = null, .proc_mmap = null, .proc_get_unmapped_area = null }
.{ .owner = vmlinux.struct_module@0, .llseek = null, .read = null, .write = null, .read_iter = null, .write_iter = null, .iopoll = null, .iterate_shared = null, .poll = null, .unlocked_ioctl = null, .compat_ioctl = null, .mmap = null, .mmap_supported_flags = 0, .open = null, .flush = null, .release = null, .fsync = null, .fasync = null, .lock = null, .get_unmapped_area = null, .check_flags = null, .flock = null, .splice_write = null, .splice_read = null, .splice_eof = null, .setlease = null, .fallocate = null, .show_fdinfo = null, .copy_file_range = null, .remap_file_range = null, .fadvise = null, .uring_cmd = null, .uring_cmd_iopoll = null }