@Override
    public int doRead(ByteBuf dst, long position, int length) throws IOException {
        long start = position;
        length = Math.min(length, dst.writableBytes());
        long end = position + length;
        long alignedStart = WALUtil.alignSmallByBlockSize(start);
        long alignedEnd = WALUtil.alignLargeByBlockSize(end);
        int alignedSize = (int) (alignedEnd - alignedStart);
        // capacity may be CAPACITY_NOT_SET only when we call {@link CapacityReader#capacity} in recovery mode
        assert CAPACITY_NOT_SET == capacity() || alignedEnd <= capacity();

        ByteBuffer tmpBuf = getBuffer(alignedSize);
        tmpBuf.position(0).limit(alignedSize);

        read(tmpBuf, alignedStart);
        tmpBuf.position((int) (start - alignedStart)).limit((int) (end - alignedStart));

        dst.writeBytes(tmpBuf);
        return (int) (end - start);
    }
Create the file and set length if not exists, and check the file size if exists.
s3stream/src/main/java/com/automq/stream/s3/wal/util/WALBlockDeviceChannel.java