private long bytesToRead(long pos, long max) {
    long available = size - pos;
    if (available <= 0) {
      return -1;
    }
    return Math.min(available, max);
  }
Returns the number of bytes that can be read starting at position {@code pos} (up to a maximum
of {@code max}) or -1 if {@code pos} is greater than or equal to the current size.
jimfs/src/main/java/com/google/common/jimfs/RegularFile.java