lib/tst_mkfs.c: fix a bug when calling tst_mkfs() with extra mkfs options

When we use tst_mkfs() to build a file system with extra mkfs options:

    tst_mkfs(NULL, device, "ext4", "-b 1024"); /* device is /dev/loop0 */

It will output some error message:

    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.

With this patch, if user wants to pass extra mkfs options, he should do:
	const char *const opts[] = { "-b", "1024", NULL };
	tst_mkfs(NULL, device, "ext4", opts);

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
3 files changed