I am doing kernel module programming using ioctl calls to communicate between userspace and kernel space. I plan on making the userspace api in python.
To pass data between kernel and userspace ioctl calls utilizes address, and data is copied using copy_to_user, or copy_from_user. The address here is given by unsigned long arg.
int ioctl(struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg)
In C userspace programming it is trivial to pass address. What I want to do, is to use struct of python to create a structure which is compatible with the structure which i have defined in the kernel module, and pass the populated python struct, using ioctl from fcntl module of python.
Is it possible? If it is possible, how do i pass the address of python struct in the ioctl call?
I do not want to use ctypes, or extend python with c. Pure python code, is what i would like.
[python]and[kernel-programming]in the same question :) - NPEfcntl? Because it already does what you are asking for: ".. When the argument is a string it represents a binary structure, e.g. created by struct.pack(). The binary data is copied to a buffer whose address is passed to the C fcntl() call. ..". Anything else you wanna do ? - mmgp