@Override
    public void doWrite(ByteBuf src, long position) throws IOException {
        if (unalignedWrite) {
            // unaligned write, just used for testing
            unalignedWrite(src, position);
            return;
        }
        assert WALUtil.isAligned(position);

        int alignedSize = (int) WALUtil.alignLargeByBlockSize(src.readableBytes());
        assert position + alignedSize <= capacity();
        ByteBuffer tmpBuf = getBuffer(alignedSize);
        tmpBuf.clear();

        for (ByteBuffer buffer : src.nioBuffers()) {
            tmpBuf.put(buffer);
        }
        tmpBuf.position(0).limit(alignedSize);

        write(tmpBuf, position);
    }
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