Hi,

On 02/04/2014 08:35 PM, [email protected] wrote:
> Hi!
>> When we used tst_mkfs() to build a file system with extra mkfs options, like 
>> that:
>>     tst_mkfs(NULL, device, "ext4", "-b 1024"); /* device is /dev/loop0 */
>>
>> It will output some error message, like that:
>>     TINFO  :  Formatting /dev/loop0 with ext4 extra opts='-b 1024'
>>     mke2fs 1.42.7 (21-Jan-2013)
>>     mkfs.ext4: invalid blocks '/dev/loop0' on device 'ext4'
>>
>> In tst_mkfs()'s implementations:
>>    argv is defined as below statments:
>>        const char *argv[] = {"mkfs", "-t", fs_type, NULL, NULL, NULL, NULL};
>>    So in the above mkfs case,
>>        the argv's value will be {"mkfs", "-t", "ext4", "-b 1024", 
>> "/dev/loop0", NULL};
>>    then when finally calling execvp(argv[0], (char *const *)argv), the 
>> number of
>> arguments is 5. It's like that we call (mkfs -t ext4 "-b 1024" /dev/loop0) 
>> in shell,
>> but the right command shoule be (mkfs -t ext4 -b 1024 /dev/loop0 # 6 args).
>> Of course, the true reason is that we didn't assign correct arguments to 
>> argv array
>> towards extra mkfs options.
>>
>>    Here we use system(3) to avoid this problem. We only pass the command 
>> string
>> to system(3), avoid parsing extra mkfs options and assigning them to argv 
>> array ourselvs.
> NACK. The code gets ugly this way.
>
> What I would rather is to change the fs_opts to array of strings so
> it could be called as:
>
> const char *const opts[] = {
>       "-b", "1024", NULL,
> };
>
> tst_mkfs(NULL, device, "ext4", opts);
>
> The change in tst_mkfs() would be fairly simple, we would create argv[]
> array which size would depend on number of options passed and set the
> pointers accordingly.
OK, thanks.
Sorry for too late response, I had almost forgotten this patch.

Regards,
Xiaoguang Wang
>


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to