public FileDescriptorIO(Ruby runtime, IRubyObject fd) {
super(runtime, runtime.getModule("FFI").getClass(CLASS_NAME));
MakeOpenFile();
ModeFlags modes = newModeFlags(runtime, ModeFlags.RDWR);
int fileno = RubyNumeric.fix2int(fd);
FileStat stat = runtime.getPosix().fstat(fileno);
ByteChannel channel;
if (stat.isSocket()) {
channel = new jnr.enxio.channels.NativeSocketChannel(fileno);
} else if (stat.isBlockDev() || stat.isCharDev()) {
channel = new jnr.enxio.channels.NativeDeviceChannel(fileno);
} else {
channel = new FileDescriptorByteChannel(runtime, fileno);
}