|
| 1 | +#ifndef __CR_IO_URING_H__ |
| 2 | +#define __CR_IO_URING_H__ |
| 3 | + |
| 4 | +#include <linux/capability.h> |
| 5 | + |
| 6 | +#include "files.h" |
| 7 | +#include "io_uring.pb-c.h" |
| 8 | + |
| 9 | +/* Definitions */ |
| 10 | +struct __io_uring_restriction { |
| 11 | + __u16 opcode; |
| 12 | + union { |
| 13 | + __u8 register_op; /* IORING_RESTRICTION_REGISTER_OP */ |
| 14 | + __u8 sqe_op; /* IORING_RESTRICTION_SQE_OP */ |
| 15 | + __u8 sqe_flags; /* IORING_RESTRICTION_SQE_FLAGS_* */ |
| 16 | + }; |
| 17 | + __u8 resv; |
| 18 | + __u32 resv2[3]; |
| 19 | +}; |
| 20 | + |
| 21 | +#ifndef IORING_SETUP_IOPOLL |
| 22 | +#define IORING_SETUP_IOPOLL (1U << 0) /* io_context is polled */ |
| 23 | +#endif |
| 24 | +#ifndef IORING_SETUP_SQPOLL |
| 25 | +#define IORING_SETUP_SQPOLL (1U << 1) /* SQ poll thread */ |
| 26 | +#endif |
| 27 | +#ifndef IORING_SETUP_SQ_AFF |
| 28 | +#define IORING_SETUP_SQ_AFF (1U << 2) /* sq_thread_cpu is valid */ |
| 29 | +#endif |
| 30 | +#ifndef IORING_SETUP_CQSIZE |
| 31 | +#define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */ |
| 32 | +#endif |
| 33 | +#ifndef IORING_SETUP_ATTACH_WQ |
| 34 | +#define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */ |
| 35 | +#endif |
| 36 | +#ifndef IORING_SETUP_R_DISABLED |
| 37 | +#define IORING_SETUP_R_DISABLED (1U << 6) /* start with ring disabled */ |
| 38 | +#endif |
| 39 | + |
| 40 | +#ifndef IORING_OFF_SQ_RING |
| 41 | +#define IORING_OFF_SQ_RING 0ULL |
| 42 | +#endif |
| 43 | +#ifndef IORING_OFF_CQ_RING |
| 44 | +#define IORING_OFF_CQ_RING 0x8000000ULL |
| 45 | +#endif |
| 46 | +#ifndef IORING_OFF_SQES |
| 47 | +#define IORING_OFF_SQES 0x10000000ULL |
| 48 | +#endif |
| 49 | + |
| 50 | +#ifndef IOSQE_IO_DRAIN |
| 51 | +#define IOSQE_IO_DRAIN (1U << 1) |
| 52 | +#endif |
| 53 | + |
| 54 | +#define __IORING_RESTRICTION_REGISTER_OP 0 |
| 55 | +#define __IORING_RESTRICTION_SQE_OP 1 |
| 56 | +#define __IORING_RESTRICTION_SQE_FLAGS_ALLOWED 2 |
| 57 | +#define __IORING_RESTRICTION_SQE_FLAGS_REQUIRED 3 |
| 58 | +#define __IORING_REGISTER_PERSONALITY 9 |
| 59 | +#define __IORING_REGISTER_RESTRICTIONS 11 |
| 60 | +#define __IORING_REGISTER_ENABLE_RINGS 12 |
| 61 | + |
| 62 | +struct io_uring_file_info { |
| 63 | + IoUringFileEntry *iofe; |
| 64 | + struct file_desc d; |
| 65 | +}; |
| 66 | + |
| 67 | +struct io_uring_data_info { |
| 68 | + IoUringDataEntry *iode; |
| 69 | +}; |
| 70 | + |
| 71 | +struct io_uring_group_desc { |
| 72 | + struct list_head list; |
| 73 | + gid_t group; |
| 74 | + char group_name[32]; |
| 75 | +}; |
| 76 | + |
| 77 | +struct io_uring_personality_desc { |
| 78 | + int id; |
| 79 | + uid_t uid; |
| 80 | + uid_t euid; |
| 81 | + uid_t suid; |
| 82 | + uid_t fsuid; |
| 83 | + gid_t gid; |
| 84 | + gid_t egid; |
| 85 | + gid_t sgid; |
| 86 | + gid_t fsgid; |
| 87 | + u32 cap_eff[CR_CAP_SIZE]; |
| 88 | + size_t nr_groups; |
| 89 | + struct list_head group_list; |
| 90 | +}; |
| 91 | + |
| 92 | +struct io_uring_ctx; |
| 93 | + |
| 94 | +extern struct collect_image_info io_uring_cinfo; |
| 95 | +extern struct collect_image_info io_uring_data_cinfo; |
| 96 | +extern const struct fdtype_ops io_uring_dump_ops; |
| 97 | + |
| 98 | +int is_io_uring_link(char *link); |
| 99 | +int io_uring_synchronize_fd(int fd); |
| 100 | +int collect_io_uring_map(struct vma_area *vma); |
| 101 | +int dump_io_uring_map(struct vma_area *vma); |
| 102 | +int add_one_io_uring_mapping(uint64_t offset, ino_t inode); |
| 103 | + |
| 104 | +int io_uring_push_buf(struct io_uring_ctx *ctx, unsigned int idx, long long unsigned int address, unsigned int len); |
| 105 | +int io_uring_push_personality(struct io_uring_ctx *ctx, struct io_uring_personality_desc *desc); |
| 106 | +IoUringFileEntry *io_uring_get_iofe(struct io_uring_ctx *ctx); |
| 107 | + |
| 108 | +#endif /* __CR_IO_URING_H__ */ |
0 commit comments