[Mono-list] Why no ioctl call in Mono.Unix.Native

Jonathan Gilbert 2a5gjx302 at sneakemail.com
Tue Jul 4 12:48:06 EDT 2006

At 06:28 PM 04/07/2006 +0200, Johannes Fortner wrote:
>#define FE_GET_INFO                _IOR('o', 61, struct
>How can i port this to mono (c#)?

The easiest way is to write a short C program to output the value, as in:

#include <linux/dvb/frontend.h>
#include <stdio.h>

int main()
  printf("const int FE_GET_INFO = %d;\n", FE_GET_INFO);
  return 0;

The alternative is to look up the definition of _IOR, and of all the macros
it references, and so on, recursively, and distill the composition of the
control code down to its component bit fields. This obviously takes much
longer, but results in source code that, for the those with academic
interest, explains how the value is derived. :-)

This probably doesn't help in your case, but Socket objects (in the
System.Net.Sockets namespace) do in fact have an ioctl wrapper:
Socket::IOControl. It can be used to set parameters from the IOControlCode
enumeration. See:


Doesn't directly help in your case, but perhaps the implementation of
Socket::IOControl can help you make an equivalent function for working on
your file descriptor :-)

Jonathan Gilbert

More information about the Mono-list mailing list