[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 04/27] Introduce virStreamSkip



On 05.05.2016 16:37, Eric Blake wrote:
> On 04/28/2016 04:04 AM, Michal Privoznik wrote:
>> This API can be used to tell the other side of the stream to skip
>> some bytes in the stream. This can be used to create a sparse
>> file on the receiving side of a stream.
>>
>> It takes just one argument @offset, which says how big the hole
>> is. Since our streams are not rewindable like regular files, we
>> don't need @whence argument like seek(2) has.
>>
>> Signed-off-by: Michal Privoznik <mprivozn redhat com>
>> ---
>>  include/libvirt/libvirt-stream.h |  3 +++
>>  src/driver-stream.h              |  5 +++++
>>  src/libvirt-stream.c             | 40 ++++++++++++++++++++++++++++++++++++++++
>>  src/libvirt_public.syms          |  5 +++++
>>  4 files changed, 53 insertions(+)
>>
> 
>> +++ b/src/libvirt-stream.c
>> @@ -286,6 +286,46 @@ virStreamRecv(virStreamPtr stream,
>>  
>>  
>>  /**
>> + * virStreamSkip:
>> + * @stream: pointer to the stream object
>> + * @offset: number of bytes to skip
>> + *
>> + * Skip @offset bytes in the stream. This is useful when there's
>> + * no actual data in the stream, just a hole. If that's the case,
>> + * this API can be used to skip the hole properly instead of
>> + * transmitting zeroes to the other side.
>> + *
>> + * Returns 0 on success,
>> + *        -1 error
>> + */
>> +int
>> +virStreamSkip(virStreamPtr stream,
>> +              unsigned long long offset)
> 
> 'offset' is a bit misleading - you're not skipping _to_ the given
> offset, so much as _over_ length bytes.  I'd name it 'length'.
> 
> Otherwise looks okay.
> 

Ah, good point. Whilst implementing this I've balanced between Seek and
Skip back and forth.  That's why I call streem seekable even if it's
really just skip what is implemented here.

Michal


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]