public int pread(int fd, ByteBuffer buf, long offset) throws IOException {
        final int start = buf.position();
        assert start == blockStart(start);
        final int toRead = buf.remaining();
        assert toRead == blockStart(toRead);
        assert offset == blockStart(offset);

        final long address = PlatformDependent.directBufferAddress(buf);
        Pointer pointer = new Pointer(address);
        int n = pread(fd, pointer.share(start), new NativeLong(toRead), new NativeLong(offset)).intValue();
        if (n < 0) {
            throw new IOException("error reading file at offset " + offset + ": " + getLastError());
        }
        buf.position(n);
        return n;
    }
Interface into native pread function.

@param fd     A file descriptor to pass to native pread
@param buf    The direct buffer into which to record the file read
@param offset The file offset at which to read
@return The number of bytes successfully read from the file
@throws IOException
s3stream/src/main/java/com/automq/stream/thirdparty/moe/cnkirito/kdio/DirectIOLib.java