On 2012年07月05日 14:11, Liu Yuan wrote:
> On 07/05/2012 02:06 PM, levin li wrote:
>> From: levin li <[email protected]>
>>
>> Sheep doesn't read the journal head in journal_recover which
>> always leaves all the fields of journal head uninitialized,
>> so the target_path is something random.
>>
>> Signed-off-by: levin li <[email protected]>
>> ---
>>  sheep/journal.c |    6 ++++++
>>  1 files changed, 6 insertions(+), 0 deletions(-)
>>
>> diff --git a/sheep/journal.c b/sheep/journal.c
>> index d082aa2..74384b2 100644
>> --- a/sheep/journal.c
>> +++ b/sheep/journal.c
>> @@ -257,6 +257,12 @@ int jrnl_recover(const char *jrnl_dir)
>>                      goto end_while_3;
>>              }
>>  
>> +            ret = pread64(jd.fd, &jd.head, sizeof(jd.head), 0);
> 
> why not use xpread which handles short read? I think all pread64 should
> be changed into xpread
> 
> Thanks,
> Yuan

I think pread64 is OK for regular files, as the manual says only in
the following conditions the number of bytes read may be less than
the number of bytes requested:

1. The number of bytes left in the file is less than the requested length.
2. The read() was interrupted by a signal.
3. The file is a pipe or FIFO or special device and has fewer bytes than 
requested immediately available for reading.

thanks,

levin

>> +            if (ret != sizeof(jd.head)) {
>> +                    eprintf("can't read journal head\n");
>> +                    goto end_while_2;
>> +            }
>> +
>>              ret = pread64(jd.fd, &end_mark, sizeof(end_mark),
>>                              sizeof(jd.head) + jd.head.size);
>>              if (ret != sizeof(end_mark)) {
>>
> 
> 


-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to