[Libguestfs] [PATCH 2/2] Include resize2fs_P into vfs_min_size.

Maxim Perevedentsev mperevedentsev at virtuozzo.com
Tue Oct 20 12:04:08 UTC 2015


On 10/19/2015 07:58 PM, Pino Toscano wrote:
> On Monday 19 October 2015 17:05:03 Maxim Perevedentsev wrote:
>> +static int32_t
>> +get_block_size (const char *device)
>> +{
>> +  CLEANUP_FREE_STRING_LIST char **params = NULL;
>> +  const char *block_pattern = "Block size";
>> +  size_t i;
>> +  int32_t block_size;
>> +
>> +  params = do_tune2fs_l (device);
> This works, yes, although maybe there should be a way to run tune2fs -l
> and traverse its output to either build a return hash (i.e. what
> do_tune2fs_l currently does) or just lookup one or more keys (like
> needed here).
We could extract running tune2fs -l to separate function returning 
char*, and parse parameters using strstr. It's terrible... I think the 
cost of calling external command is much higher than the cost of 
building hash.

To make things betters, we could extract line-splitting function, create 
2 similar functions (1 building hash (as for now) and 1 comparing key to 
argument). I do not think we will save much if we avoid copying strings 
into hash.

-- 
Your sincerely,
Maxim Perevedentsev




More information about the Libguestfs mailing list