ioctl: move doc to README

This commit is contained in:
Ciro Santilli
2018-07-01 17:44:38 +01:00
parent 084e3faf5a
commit d840b0cb65
7 changed files with 107 additions and 51 deletions

View File

@@ -9,11 +9,10 @@ typedef struct {
int j;
} lkmc_ioctl_struct;
/* Some random number I can't understand how to choose. */
/* TODO some random number I can't understand how to choose. */
#define LKMC_IOCTL_MAGIC 0x33
/*
* I think those number does not *need* to be unique across, that is just to help debugging:
/* I think those number do not *need* to be unique across, that is just to help debugging:
* https://stackoverflow.com/questions/22496123/what-is-the-meaning-of-this-macro-iormy-macig-0-int
*
* However, the ioctl syscall highjacks several low values at do_vfs_ioctl, e.g.
@@ -25,8 +24,19 @@ typedef struct {
* https://stackoverflow.com/questions/6125068/what-does-the-fd-cloexec-fcntl-flag-do
*
* TODO are the W or R of _IOx and type functional, or only to help with uniqueness?
* */
*
* Documentation/ioctl/ioctl-number.txt documents:
*
* ....
* _IO an ioctl with no parameters
* _IOW an ioctl with write parameters (copy_from_user)
* _IOR an ioctl with read parameters (copy_to_user)
* _IOWR an ioctl with both write and read parameters.
* ....
*/
/* Take an int, increment it. */
#define LKMC_IOCTL_INC _IOWR(LKMC_IOCTL_MAGIC, 0, int)
/* Take a struct with two ints, increment the first, and decrement the second. */
#define LKMC_IOCTL_INC_DEC _IOWR(LKMC_IOCTL_MAGIC, 1, lkmc_ioctl_struct)
#endif