async Task <int> Read(byte[] buffer, int offset, int count, bool async, CancellationToken cancellationToken = default) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } if (offset < 0) { throw new ArgumentOutOfRangeException(nameof(offset)); } if (count < 0) { throw new ArgumentOutOfRangeException(nameof(count)); } if (buffer.Length - offset < count) { throw new ArgumentException("Invalid offset or count for this buffer"); } CheckDisposed(); var chunkCount = Math.Min(count, _manager.MaxTransferBlockSize); var read = 0; while (read < count) { var bytesRead = await _manager.ExecuteFunctionGetBytes( "loread", buffer, offset + read, count - read, async, cancellationToken, _fd, chunkCount); _pos += bytesRead; read += bytesRead; if (bytesRead < chunkCount) { return(read); } } return(read); }