سؤال

According to the fcntl documentation the usage of fcntl.ioctl is as follows:

 fcntl.ioctl(fd, op[, arg[, mutate_flag]])

with op defined as

The operation is defined by op and is operating system dependent. These codes are also found in the fcntl module. 

It does not answer 'what' op is. Is it an int? A string? A structure? How to be able to use this command properly e.g. on a Linux platform?

هل كانت مفيدة؟

المحلول

As with many of the other functions in the fcntl and os modules, ioctl is a thin wrapper around the OS system call of the same name. If you consult the manpage for that system call you will see that it's an integer.

The additional argument (after op) to ioctl could be just about anything. ioctl has notoriously variable arguments that depend on exactly what the request is and even what piece of kernel or driver code receives and processes the request. Difference drivers can even reuse the integer values of op to mean different things (although they're encouraged to coordinate to avoid this kind of duplication).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top