public long transferFrom(FileChannel src, final long position, final long count)
     throws IOException {
   if (allAreSet(state, WRITE_SHUTDOWN)) {
     throw new ClosedChannelException();
   }
   if (count == 0L) return 0L;
   final long res;
   src = thread.getWorker().getXnio().unwrapFileChannel(src);
   if (Native.HAS_SENDFILE && src instanceof FileChannelImpl) {
     res = Native.testAndThrowRead(Native.sendfile(fd, src, position, count));
     if (Native.EXTRA_TRACE) log.tracef("Sendfile(%s -> %d): %d", src, fd, res);
   } else {
     res = src.transferTo(position, count, new ConduitWritableByteChannel(this));
   }
   if (res == 0) state &= ~WRITE_READY;
   checkWriteTimeout(res > 0);
   return res;
 }
 /**
  * Write a {@link DefaultFileRegion}
  *
  * @param region the {@link DefaultFileRegion} from which the bytes should be written
  * @return amount the amount of written bytes
  */
 private long doWriteFileRegion(DefaultFileRegion region, long count) throws Exception {
   return Native.sendfile(fd, region, region.transfered(), count);
 }