4 #include <linux/ioctl.h>
9 struct fetch_fops_args {
14 #define MOCTEL_FETCH_FOPS _IOR('m', 1, struct fetch_fops_args)
16 struct file_operations {
36 void *get_unmapped_area;
47 int main(int argc, char **argv) {
48 if (argc != 2) fputs("Usage: show_ioctl <device>\n", stderr), exit(1);
50 char *devname = argv[1];
51 int devfd = open(devname, O_RDONLY);
52 if (devfd == -1) fprintf(stderr, "Can't open %s: %m\n", devname), exit(1);
54 int ioctlfd = open("/dev/ioctl_info", O_RDONLY);
55 if (ioctlfd == -1) fprintf(stderr, "Can't open /dev/ioctl_info: %m\n"), exit(1);
57 struct file_operations fops;
58 struct fetch_fops_args ioctl_args = {
60 .retp = (uint64_t)&fops
62 int ret = ioctl(ioctlfd, MOCTEL_FETCH_FOPS, &ioctl_args);
63 if (ret) fprintf(stderr, "can't perform MOCTEL_FETCH_FOPS: %m\n"), exit(1);
68 printf("unlocked_ioctl: %llx\n", (unsigned long long)fops.unlocked_ioctl);