--- old/src/java.base/unix/native/libnio/ch/FileChannelImpl.c 2016-11-16 10:28:19.868497916 -0800 +++ new/src/java.base/unix/native/libnio/ch/FileChannelImpl.c 2016-11-16 10:28:19.810497915 -0800 @@ -276,3 +276,31 @@ #endif } +JNIEXPORT jint JNICALL +Java_sun_nio_ch_FileChannelImpl_setDirect0(JNIEnv *env, jobject this, jobject fObj) +{ + jint fd = fdval(env, fObj); + jint result; + +#ifdef O_DIRECT + result = fcntl(fd, F_SETFL, O_DIRECT); + if (result == -1) { + JNU_ThrowIOExceptionWithLastError(env, "DirectIO setup failed"); + } + return result; +#elif F_NOCACHE + result = fcntl(fd, F_NOCACHE, 1); + if (result == -1) { + JNU_ThrowIOExceptionWithLastError(env, "DirectIO setup failed"); + } + return result; +//#elif DIRECTIO_ON +// result = directio(fd, DIRECTIO_ON); +// if (result == -1) { +// JNU_ThrowIOExceptionWithLastError(env, "DirectIO setup failed"); +// } + return result; +#else + return -1; +#endif +}