move eventfd stuff out to own file
[trinity.git] / include / ioctls.h
blobfbb27adde19637e69652e6a8a316f31d41b6ad48
1 #pragma once
3 #include <stdlib.h>
4 #include <sys/stat.h>
6 struct ioctl {
7 const char *name;
8 unsigned int request;
9 };
11 #define DEV_CHAR 1
12 #define DEV_BLOCK 2
13 #define DEV_MISC 3
15 struct ioctl_group {
16 /* optional user visible string that describes this group of ioctl
17 * operations. */
18 const char *name;
20 /* Non-NULL sanitise routine for this ioctl group. Initialize to
21 * "pick_random_ioctl" to pick one random ioctl. */
22 void (*sanitise)(const struct ioctl_group *, int childno);
24 /* Plug the available ioctls here. */
25 const struct ioctl *ioctls;
26 size_t ioctls_cnt;
28 /* One of the DEV_* constants. */
29 int devtype;
31 /* List the device names from /proc/devices or /proc/misc that these
32 * ioctl operations are valid for. */
33 const char *const *devs;
34 size_t devs_cnt;
36 /* Optional routine that should return 0 if the file descriptor is
37 * valid for this group. */
38 int (*fd_test)(int fd, const struct stat *);
41 void register_ioctl_group(const struct ioctl_group *);
43 const struct ioctl_group *find_ioctl_group(int fd);
45 const struct ioctl_group *get_random_ioctl_group(void);
47 void pick_random_ioctl(const struct ioctl_group *, int childno);
49 void dump_ioctls(void);
51 #define IOCTL(_request) \
52 { .request = _request, .name = #_request, }
54 #define REG_IOCTL_GROUP(_struct) \
55 static void __attribute__((constructor)) register_##_struct(void) { \
56 register_ioctl_group(&_struct); \