Jun-18-2018, 02:11 PM
Hi
I am trying to implement IOCTL interface to driver
I have created a strcuture
But when the kernel tried to write to the buffer it fails,
My question is how can I transfer the buffer in the structure so the kernel can write to it
Regards
I am trying to implement IOCTL interface to driver
I have created a strcuture
class pass_cmd(Structure): _fields_ = [ ('opcode', c_uint8), #__u8 ('addr', POINTER(c_uint64)), #__u64 ('data_len', c_uint32), #__u32 ('timeout_ms', c_uint32), #__u32 ('result', c_uint32), #__u32 ] buf = (c_uint64 * 4096)() and Args = pass_cmd() Args.opcode = 0x12 Args.addr = POINTER(buf)# id(buf) #Args.addr = ctypes.POINTER(ctypes.cast(ctypes.byref(buf),ctypes.c_void_p)) Args.data_len = 4096 Args.timeout_ms = 400 Args.restult = 0 devicehandle = open('/dev/block', 'rw') output_buffer = fcntl.ioctl(devicehandle, 0xc0484e43 /*Magic number IOCTL */, (Args))The structure transferred to the kernel, in the addr field (Buffer address) is correct,
But when the kernel tried to write to the buffer it fails,
My question is how can I transfer the buffer in the structure so the kernel can write to it
Regards