ioctl.h 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #ifndef IOCTL_H
  2. #define IOCTL_H
  3. #include <linux/ioctl.h>
  4. /* Structs are the way to pass multiple arguments. */
  5. typedef struct {
  6. int i;
  7. int j;
  8. } lkmc_ioctl_struct;
  9. /* Some random number I can't understand how to choose. */
  10. #define LKMC_IOCTL_MAGIC 0x33
  11. /*
  12. * I think those number does not *need* to be unique across, that is just to help debugging:
  13. * https://stackoverflow.com/questions/22496123/what-is-the-meaning-of-this-macro-iormy-macig-0-int
  14. *
  15. * However, the ioctl syscall highjacks several low values at do_vfs_ioctl, e.g.
  16. * This "forces" use to use the _IOx macros...
  17. * https://stackoverflow.com/questions/10071296/ioctl-is-not-called-if-cmd-2
  18. *
  19. * Some of those magic low values are used for fnctl, which can also be used on regular files:
  20. * e.g. FIOCLEX for close-on-exec:
  21. * https://stackoverflow.com/questions/6125068/what-does-the-fd-cloexec-fcntl-flag-do
  22. *
  23. * TODO are the W or R of _IOx and type functional, or only to help with uniqueness?
  24. * */
  25. #define LKMC_IOCTL_INC _IOWR(LKMC_IOCTL_MAGIC, 0, int)
  26. #define LKMC_IOCTL_INC_DEC _IOWR(LKMC_IOCTL_MAGIC, 1, lkmc_ioctl_struct)
  27. #endif