tst_mkfs: add new parameter extra_opts to tst_mkfs function
PATCH v2 1/1 tst_mkfs: add new parameter extra_opts to tst_mkfs function
mmap16 always hit ETIMEDOUT error, if the test device is too large. mkfs on the device will take lots of time. So I want to make ext4 with an appointed size. But the [fs_size] need behind the device name for ext4, e.g. "mkfs -t ext4 dev [fs_size]".
Due to above reason, add a new parameter extra_opts to tst_mkfs. extra_opts store the options need to behind the device name of mkfs. Then mmap16 can make ext4 with an appointed (small) size. And this change can make tst_mkfs() cover more mkfs usage.
Because of tst_mkfs be changed, all testcases which use tst_mkfs add NULL parameter for extra_opts.
---
Hi Cyril,
This v2 patch change mmap16's 100M size to 10M. Due to 100M is bigger than LTP default LTP_DEV size(if no -b device used). 10M is OK as I test.
Thanks,
Zorro
doc/test-writing-guidelines.txt | 10 ++++++-- include/test.h | 6 +++-- lib/tests/tst_device.c | 2 +- lib/tst_mkfs.c | 30 +++++++++++++++++++--- testcases/kernel/io/direct_io/dma_thread_diotest.c | 2 +- testcases/kernel/syscalls/access/access06.c | 2 +- testcases/kernel/syscalls/acct/acct01.c | 2 +- testcases/kernel/syscalls/chmod/chmod06.c | 2 +- testcases/kernel/syscalls/chown/chown04.c | 2 +- testcases/kernel/syscalls/creat/creat06.c | 2 +- testcases/kernel/syscalls/fchmod/fchmod06.c | 2 +- testcases/kernel/syscalls/fchown/fchown04.c | 2 +- testcases/kernel/syscalls/ftruncate/ftruncate04.c | 2 +- testcases/kernel/syscalls/inotify/inotify03.c | 2 +- testcases/kernel/syscalls/lchown/lchown03.c | 2 +- testcases/kernel/syscalls/link/link08.c | 2 +- testcases/kernel/syscalls/linkat/linkat02.c | 2 +- testcases/kernel/syscalls/mkdir/mkdir03.c | 2 +- testcases/kernel/syscalls/mkdirat/mkdirat02.c | 2 +- testcases/kernel/syscalls/mknod/mknod07.c | 2 +- testcases/kernel/syscalls/mknodat/mknodat02.c | 2 +- testcases/kernel/syscalls/mmap/mmap16.c | 2 +- testcases/kernel/syscalls/mount/mount01.c | 2 +- testcases/kernel/syscalls/mount/mount02.c | 2 +- testcases/kernel/syscalls/mount/mount03.c | 2 +- testcases/kernel/syscalls/mount/mount04.c | 2 +- testcases/kernel/syscalls/mount/mount05.c | 2 +- testcases/kernel/syscalls/mount/mount06.c | 2 +- testcases/kernel/syscalls/open/open12.c | 2 +- testcases/kernel/syscalls/quotactl/quotactl02.c | 2 +- testcases/kernel/syscalls/rename/rename11.c | 2 +- testcases/kernel/syscalls/renameat/renameat01.c | 2 +- testcases/kernel/syscalls/rmdir/rmdir02.c | 2 +- testcases/kernel/syscalls/umount/umount01.c | 2 +- testcases/kernel/syscalls/umount/umount02.c | 2 +- testcases/kernel/syscalls/umount/umount03.c | 2 +- testcases/kernel/syscalls/umount2/umount2_01.c | 2 +- testcases/kernel/syscalls/umount2/umount2_02.c | 2 +- testcases/kernel/syscalls/umount2/umount2_03.c | 2 +- testcases/kernel/syscalls/utime/utime06.c | 2 +- testcases/kernel/syscalls/utimes/utimes01.c | 2 +- 41 files changed, 77 insertions(+), 45 deletions(-)
doc/test-writing-guidelines.txt +8 -2
@@ -906,15 +906,21 @@ NOTE: The default filesytem is hardcoded to 'ext2' in the sources and can be #include "test.h" void tst_mkfs(void (cleanup_fn)(void), const char *dev, - const char *fs_type, const char *const fs_opts[]); + const char *fs_type, const char *const fs_opts[] + const char *extra_opts); ------------------------------------------------------------------------------- This function takes a path to a device, filesystem type and an array of extra options passed to mkfs. -The extra options 'fs_opts' should either be 'NULL' if there are none, or a +The fs options 'fs_opts' should either be 'NULL' if there are none, or a 'NULL' terminated array of strings such as '{"-b", "1024", NULL}'. +The extra options 'extra_opts' should either be 'NULL' if there are none, or +a string such as "102400". 'extra_opts' will be used behind device name. e.g: +mkfs -t ext4 -b 1024 /dev/sda1 102400 + ^^^^^^ + 2.2.16 Verifying a filesystem's free space ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
include/test.h +4 -2
@@ -316,10 +316,12 @@ int tst_system(const char *command);* * @dev: path to a device * @fs_type: filesystem type -* @fs_opts: NULL or NULL terminated array of extra mkfs options +* @fs_opts: NULL or NULL terminated array of mkfs options +* @extra_opts: extranal mkfs options which need to behind the device name */ void tst_mkfs (void (cleanup_fn )(void ),const char *dev, -const char *fs_type,const char *const fs_opts[]); +const char *fs_type,const char *const fs_opts[], +const char *extra_opts);/* * Returns filesystem type to be used for the testing. Unless your test is
lib/tests/tst_device.c +1 -1
@@ -46,7 +46,7 @@ int main(void)printf ("Test device='%s'\n" , dev); -tst_mkfs (cleanup, dev,"ext2" ,NULL ); +tst_mkfs (cleanup, dev,"ext2" ,NULL ,NULL );cleanup ();tst_exit ();
lib/tst_mkfs.c +27 -3
@@ -21,12 +21,24 @@#define OPTS_MAX 32 +/* +* tst_mkfs: mkfs.$fs_type on $dev with options $fs_opts and $extra_opts +* cleanup_fn - run it when exit with error. +* dev - device path name +* fs_opts - store the options for mkfs (except -t fs_type). Set +* NULL if don't need options. +* extra_opts - extranal mkfs options for mkfs, these options need +* behind the device name, e.g. [fs_size] for ext4. +* Set NULL, if don't need options behind device name. +*/ void tst_mkfs (void (cleanup_fn )(void ),const char *dev, -const char *fs_type,const char *const fs_opts[]) +const char *fs_type,const char *const fs_opts[], +const char *extra_opts) {int i, pos =3 ;const char *argv[OPTS_MAX ] = {"mkfs" ,"-t" , fs_type};char fs_opts_str[1024 ] ="" ; +const char *fs_extra_opts = extra_opts;if (!fs_type)tst_brkm (TBROK , cleanup_fn,"No fs_type specified" );
@@ -68,10 +80,22 @@ void tst_mkfs(void (cleanup_fn)(void), const char *dev, } argv[pos++] = dev; + +if (fs_extra_opts) { + argv[pos++] = extra_opts; + +if (pos +1 >OPTS_MAX ) { +tst_brkm (TBROK , cleanup_fn, +"Too much mkfs options" ); + } + }else { + fs_extra_opts ="None" ; + } + argv[pos] =NULL ; -tst_resm (TINFO ,"Formatting %s with %s extra opts='%s'" , - dev, fs_type, fs_opts_str); +tst_resm (TINFO ,"Formatting %s with %s opts='%s' extra opts='%s'" , + dev, fs_type, fs_opts_str, fs_extra_opts);tst_run_cmd (cleanup_fn, argv,"/dev/null" ,NULL ,0 ); }
testcases/kernel/io/direct_io/dma_thread_diotest.c +1 -1
@@ -397,7 +397,7 @@ static void setup(void)tst_brkm (TCONF ,NULL ,"you must specify a big blockdevice(>1.3G)" ); }else { -tst_mkfs (NULL , device,"ext3" ,NULL ); +tst_mkfs (NULL , device,"ext3" ,NULL ,NULL ); }if (mount (device,MNT_POINT ,"ext3" ,0 ,NULL ) <0 ) {
testcases/kernel/syscalls/access/access06.c +1 -1
@@ -93,7 +93,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE );TEST_PAUSE ;
testcases/kernel/syscalls/acct/acct01.c +1 -1
@@ -150,7 +150,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,DIR_MODE );if (mount (device,"mntpoint" , fs_type,0 ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/chmod/chmod06.c +1 -1
@@ -192,7 +192,7 @@ void setup(void)SAFE_CHMOD (cleanup,DIR_TEMP ,FILE_MODE );SAFE_TOUCH (cleanup,"t_file" ,MODE_RWX ,NULL ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE );
testcases/kernel/syscalls/chown/chown04.c +1 -1
@@ -149,7 +149,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );TEST_PAUSE ;
testcases/kernel/syscalls/creat/creat06.c +1 -1
@@ -179,7 +179,7 @@ static void setup(void)SAFE_SYMLINK (cleanup,TEST7_FILE ,"test_file_eloop2" );SAFE_SYMLINK (cleanup,"test_file_eloop2" ,TEST7_FILE ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,0777 );if (mount (device,"mntpoint" , fs_type,MS_RDONLY ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/fchmod/fchmod06.c +1 -1
@@ -127,7 +127,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,0755 );
testcases/kernel/syscalls/fchown/fchown04.c +1 -1
@@ -113,7 +113,7 @@ static void setup(void) fd1 =SAFE_OPEN (cleanup,"tfile_1" ,O_RDWR |O_CREAT ,0666 ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,DIR_MODE );if (mount (device,"mntpoint" , fs_type,0 ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/ftruncate/ftruncate04.c +1 -1
@@ -240,7 +240,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MOUNT (NULL , device,MOUNT_DIR , fs_type,MS_MANDLOCK ,NULL ); mount_flag =1 ;
testcases/kernel/syscalls/inotify/inotify03.c +1 -1
@@ -178,7 +178,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );if (mkdir (mntpoint,DIR_MODE ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup, "mkdir(%s, %#o) failed",
testcases/kernel/syscalls/lchown/lchown03.c +1 -1
@@ -107,7 +107,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (test_eloop,"/test_eloop" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,TEST_EROFS ,DIR_MODE );if (mount (device,TEST_EROFS , fs_type,MS_RDONLY ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/link/link08.c +1 -1
@@ -143,7 +143,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (test_file4,"/test_eloop" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE );if (mount (device,MNT_POINT , fs_type,0 ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/linkat/linkat02.c +1 -1
@@ -171,7 +171,7 @@ static void setup(void)SAFE_MKDIR (cleanup,"./tmp" ,DIR_MODE );SAFE_TOUCH (cleanup,TEST_EACCES ,0666 ,NULL ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,DIR_MODE );if (mount (device,"mntpoint" , fs_type,0 ,NULL ) <0 ) {
testcases/kernel/syscalls/mkdir/mkdir03.c +1 -1
@@ -122,7 +122,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (loop_dir,"/test_eloop" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE );if (mount (device,MNT_POINT , fs_type,MS_RDONLY ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/mkdirat/mkdirat02.c +1 -1
@@ -116,7 +116,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (test_file2,"/test_eloop" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"test_dir/mntpoint" ,DIR_MODE );if (mount (device,"test_dir/mntpoint" , fs_type,MS_RDONLY ,NULL ) <0 ) {
testcases/kernel/syscalls/mknod/mknod07.c +1 -1
@@ -123,7 +123,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );TEST_PAUSE ;
testcases/kernel/syscalls/mknodat/mknodat02.c +1 -1
@@ -124,7 +124,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );TEST_PAUSE ;
testcases/kernel/syscalls/mmap/mmap16.c +1 -1
@@ -158,7 +158,7 @@ static void setup(void) device =tst_acquire_device (cleanup);if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type, fs_opts); +tst_mkfs (cleanup, device, fs_type, fs_opts,"10240" );SAFE_MKDIR (cleanup,MNTPOINT ,0755 );/*
testcases/kernel/syscalls/mount/mount01.c +1 -1
@@ -83,7 +83,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );
testcases/kernel/syscalls/mount/mount02.c +1 -1
@@ -186,7 +186,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup, mntpoint,DIR_MODE );
testcases/kernel/syscalls/mount/mount03.c +1 -1
@@ -355,7 +355,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup, mntpoint,DIR_MODE );
testcases/kernel/syscalls/mount/mount04.c +1 -1
@@ -98,7 +98,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL ); ltpuser =SAFE_GETPWNAM (cleanup, nobody_uid);SAFE_SETEUID (cleanup, ltpuser->pw_uid);
testcases/kernel/syscalls/mount/mount05.c +1 -1
@@ -104,7 +104,7 @@ void setup(void)SAFE_MKDIR (cleanup, mntpoint_des,DIR_MODE );if (dflag) { -tst_mkfs (NULL , device, fstype,NULL ); +tst_mkfs (NULL , device, fstype,NULL ,NULL );if (mount (device, mntpoint_src, fstype,0 ,NULL ) ==-1 )tst_brkm (TBROK |TERRNO , cleanup,"mount failed" );
testcases/kernel/syscalls/mount/mount06.c +1 -1
@@ -129,7 +129,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );if (getcwd (path_name,sizeof (path_name)) ==NULL )tst_brkm (TBROK , cleanup,"getcwd failed" );
testcases/kernel/syscalls/open/open12.c +1 -1
@@ -107,7 +107,7 @@ static void setup(void) goto end; } -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MOUNT (cleanup, device,MNTPOINT , fs_type,MS_STRICTATIME ,NULL ); mount_flag =1 ;
testcases/kernel/syscalls/quotactl/quotactl02.c +1 -1
@@ -207,7 +207,7 @@ static void setup(void)if (!block_dev)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, block_dev,"xfs" ,NULL ); +tst_mkfs (cleanup, block_dev,"xfs" ,NULL ,NULL );if (mount (block_dev, mntpoint,"xfs" ,0 ,"uquota" ) <0 )tst_brkm (TFAIL |TERRNO ,NULL ,"mount(2) fail" );
testcases/kernel/syscalls/rename/rename11.c +1 -1
@@ -104,7 +104,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,0755 );if (mount (device,MNTPOINT , fs_type,0 ,NULL ) <0 ) {
testcases/kernel/syscalls/renameat/renameat01.c +1 -1
@@ -183,7 +183,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (looppathname,TESTDIR2 ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIRMODE );if (mount (device,MNTPOINT , fs_type,0 ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/rmdir/rmdir02.c +1 -1
@@ -137,7 +137,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );if (mount (device,MNTPOINT , fs_type,0 ,NULL ) ==-1 ) { tst_brkm(TBROK | TERRNO, cleanup,
testcases/kernel/syscalls/umount/umount01.c +1 -1
@@ -93,7 +93,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );if (mkdir (mntpoint,DIR_MODE ) <0 ) { tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) failed; "
testcases/kernel/syscalls/umount/umount02.c +1 -1
@@ -117,7 +117,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );memset (long_path,'a' ,PATH_MAX +1 );
testcases/kernel/syscalls/umount/umount03.c +1 -1
@@ -99,7 +99,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );
testcases/kernel/syscalls/umount2/umount2_01.c +1 -1
@@ -78,7 +78,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );
testcases/kernel/syscalls/umount2/umount2_02.c +1 -1
@@ -115,7 +115,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );
testcases/kernel/syscalls/umount2/umount2_03.c +1 -1
@@ -96,7 +96,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );
testcases/kernel/syscalls/utime/utime06.c +1 -1
@@ -119,7 +119,7 @@ static void setup(void)if (!dev)tst_brkm (TCONF , cleanup,"Failed to acquire test device" ); -tst_mkfs (cleanup, dev, fs_type,NULL ); +tst_mkfs (cleanup, dev, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,0644 );if (mount (dev,MNT_POINT , fs_type,MS_RDONLY ,NULL ) <0 ) {
testcases/kernel/syscalls/utimes/utimes01.c +1 -1
@@ -139,7 +139,7 @@ static void setup(void)SAFE_CHOWN (cleanup,TESTFILE2 , ltpuser->pw_uid, ltpuser->pw_gid); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );if (mount (device,MNTPOINT , fs_type,0 ,NULL ) ==-1 ) { tst_brkm(TBROK | TERRNO, cleanup,
Signature · 1 line
2.5.0
PATCH v2 1/1 tst_mkfs: add new parameter extra_opts to tst_mkfs function
Quoted 14 lines
doc/test-writing-guidelines.txt +2
-1@@ -906,15 +906,21 @@ NOTE: The default filesytem is hardcoded to 'ext2' in the sources and can be #include "test.h" void tst_mkfs(void (cleanup_fn)(void), const char *dev, - const char *fs_type, const char *const fs_opts[]); + const char *fs_type, const char *const fs_opts[] + const char *extra_opts); ------------------------------------------------------------------------------- This function takes a path to a device, filesystem type and an array of extra
doc/test-writing-guidelines.txt NOTE: The default filesytem is hardcoded to 'ext2' in the sources and can be · line 922
Quoted 10 lines
doc/test-writing-guidelines.txt +5
-1options passed to mkfs. -The extra options 'fs_opts' should either be 'NULL' if there are none, or a +The fs options 'fs_opts' should either be 'NULL' if there are none, or a 'NULL' terminated array of strings such as '{"-b", "1024", NULL}'. +The extra options 'extra_opts' should either be 'NULL' if there are none, or +a string such as "102400". 'extra_opts' will be used behind device name. e.g: +mkfs -t ext4 -b 1024 /dev/sda1 102400 + ^^^^^^
The documentation file si ascii-doc formatted and the ^^^^^ under 102400 is not correct syntax.
Quoted 8 lines
doc/test-writing-guidelines.txt +0
-02.2.16 Verifying a filesystem's free space ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^include/test.h +0
-0
include/test.h int tst_system(const char *command); · line 320
Quoted 6 lines
include/test.h +2
-1@@ -316,10 +316,12 @@ int tst_system(const char *command);* * @dev: path to a device * @fs_type: filesystem type -* @fs_opts: NULL or NULL terminated array of extra mkfs options +* @fs_opts: NULL or NULL terminated array of mkfs options +* @extra_opts: extranal mkfs options which need to behind the device name
^
should be extra_opt right?
Quoted 63 lines
include/test.h +2
-1*/ void tst_mkfs (void (cleanup_fn )(void ),const char *dev, -const char *fs_type,const char *const fs_opts[]); +const char *fs_type,const char *const fs_opts[], +const char *extra_opts);/* * Returns filesystem type to be used for the testing. Unless your test is lib/tests/tst_device.c +1
-1@@ -46,7 +46,7 @@ int main(void)printf ("Test device='%s'\n" , dev); -tst_mkfs (cleanup, dev,"ext2" ,NULL ); +tst_mkfs (cleanup, dev,"ext2" ,NULL ,NULL );cleanup ();tst_exit ();lib/tst_mkfs.c +21
-1@@ -21,12 +21,24 @@#define OPTS_MAX 32 +/* +* tst_mkfs: mkfs.$fs_type on $dev with options $fs_opts and $extra_opts +* cleanup_fn - run it when exit with error. +* dev - device path name +* fs_opts - store the options for mkfs (except -t fs_type). Set +* NULL if don't need options. +* extra_opts - extranal mkfs options for mkfs, these options need +* behind the device name, e.g. [fs_size] for ext4. +* Set NULL, if don't need options behind device name. +*/ void tst_mkfs (void (cleanup_fn )(void ),const char *dev, -const char *fs_type,const char *const fs_opts[]) +const char *fs_type,const char *const fs_opts[], +const char *extra_opts) {int i, pos =3 ;const char *argv[OPTS_MAX ] = {"mkfs" ,"-t" , fs_type};char fs_opts_str[1024 ] ="" ; +const char *fs_extra_opts = extra_opts;if (!fs_type)tst_brkm (TBROK , cleanup_fn,"No fs_type specified" );@@ -68,10 +80,22 @@ void tst_mkfs(void (cleanup_fn)(void), const char *dev, } argv[pos++] = dev; + +if (fs_extra_opts) { + argv[pos++] = extra_opts; + +if (pos +1 >OPTS_MAX ) { +tst_brkm (TBROK , cleanup_fn, +"Too much mkfs options" ); + }
lib/tst_mkfs.c void tst_mkfs(void (cleanup_fn)(void), const char *dev, · line 98
Quoted 10 lines
lib/tst_mkfs.c +6
-2+ }else { + fs_extra_opts ="None" ; + } + argv[pos] =NULL ; -tst_resm (TINFO ,"Formatting %s with %s extra opts='%s'" , - dev, fs_type, fs_opts_str); +tst_resm (TINFO ,"Formatting %s with %s opts='%s' extra opts='%s'" , + dev, fs_type, fs_opts_str, fs_extra_opts);
You can do just:
extra_opts ? extra_opts : ""
In order to save the trouble of fidling with two similary named variables that sometimes does not hold the same value.
Quoted 229 lines
lib/tst_mkfs.c +0
-0tst_run_cmd (cleanup_fn, argv,"/dev/null" ,NULL ,0 ); }testcases/kernel/io/direct_io/dma_thread_diotest.c +1
-1@@ -397,7 +397,7 @@ static void setup(void)tst_brkm (TCONF ,NULL ,"you must specify a big blockdevice(>1.3G)" ); }else { -tst_mkfs (NULL , device,"ext3" ,NULL ); +tst_mkfs (NULL , device,"ext3" ,NULL ,NULL ); }if (mount (device,MNT_POINT ,"ext3" ,0 ,NULL ) <0 ) {testcases/kernel/syscalls/access/access06.c +1
-1@@ -93,7 +93,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE );TEST_PAUSE ;testcases/kernel/syscalls/acct/acct01.c +1
-1@@ -150,7 +150,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,DIR_MODE );if (mount (device,"mntpoint" , fs_type,0 ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,testcases/kernel/syscalls/chmod/chmod06.c +1
-1@@ -192,7 +192,7 @@ void setup(void)SAFE_CHMOD (cleanup,DIR_TEMP ,FILE_MODE );SAFE_TOUCH (cleanup,"t_file" ,MODE_RWX ,NULL ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE );testcases/kernel/syscalls/chown/chown04.c +1
-1@@ -149,7 +149,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );TEST_PAUSE ;testcases/kernel/syscalls/creat/creat06.c +1
-1@@ -179,7 +179,7 @@ static void setup(void)SAFE_SYMLINK (cleanup,TEST7_FILE ,"test_file_eloop2" );SAFE_SYMLINK (cleanup,"test_file_eloop2" ,TEST7_FILE ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,0777 );if (mount (device,"mntpoint" , fs_type,MS_RDONLY ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,testcases/kernel/syscalls/fchmod/fchmod06.c +1
-1@@ -127,7 +127,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,0755 );testcases/kernel/syscalls/fchown/fchown04.c +1
-1@@ -113,7 +113,7 @@ static void setup(void) fd1 =SAFE_OPEN (cleanup,"tfile_1" ,O_RDWR |O_CREAT ,0666 ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,DIR_MODE );if (mount (device,"mntpoint" , fs_type,0 ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,testcases/kernel/syscalls/ftruncate/ftruncate04.c +1
-1@@ -240,7 +240,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MOUNT (NULL , device,MOUNT_DIR , fs_type,MS_MANDLOCK ,NULL ); mount_flag =1 ;testcases/kernel/syscalls/inotify/inotify03.c +1
-1@@ -178,7 +178,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );if (mkdir (mntpoint,DIR_MODE ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup, "mkdir(%s, %#o) failed",testcases/kernel/syscalls/lchown/lchown03.c +1
-1@@ -107,7 +107,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (test_eloop,"/test_eloop" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,TEST_EROFS ,DIR_MODE );if (mount (device,TEST_EROFS , fs_type,MS_RDONLY ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,testcases/kernel/syscalls/link/link08.c +1
-1@@ -143,7 +143,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (test_file4,"/test_eloop" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE );if (mount (device,MNT_POINT , fs_type,0 ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,testcases/kernel/syscalls/linkat/linkat02.c +1
-1@@ -171,7 +171,7 @@ static void setup(void)SAFE_MKDIR (cleanup,"./tmp" ,DIR_MODE );SAFE_TOUCH (cleanup,TEST_EACCES ,0666 ,NULL ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"mntpoint" ,DIR_MODE );if (mount (device,"mntpoint" , fs_type,0 ,NULL ) <0 ) {testcases/kernel/syscalls/mkdir/mkdir03.c +1
-1@@ -122,7 +122,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (loop_dir,"/test_eloop" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE );if (mount (device,MNT_POINT , fs_type,MS_RDONLY ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,testcases/kernel/syscalls/mkdirat/mkdirat02.c +1
-1@@ -116,7 +116,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (test_file2,"/test_eloop" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,"test_dir/mntpoint" ,DIR_MODE );if (mount (device,"test_dir/mntpoint" , fs_type,MS_RDONLY ,NULL ) <0 ) {testcases/kernel/syscalls/mknod/mknod07.c +1
-1@@ -123,7 +123,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );TEST_PAUSE ;testcases/kernel/syscalls/mknodat/mknodat02.c +1
-1@@ -124,7 +124,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );TEST_PAUSE ;testcases/kernel/syscalls/mmap/mmap16.c +0
-0
testcases/kernel/syscalls/mmap/mmap16.c static void setup(void) · line 161
Quoted 5 lines
testcases/kernel/syscalls/mmap/mmap16.c +1
-1@@ -158,7 +158,7 @@ static void setup(void) device =tst_acquire_device (cleanup);if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type, fs_opts); +tst_mkfs (cleanup, device, fs_type, fs_opts,"10240" );
So mkfs.ext4 works with 10Mb device as well? The we should go with 10Mb.
Quoted 252 lines
testcases/kernel/syscalls/mmap/mmap16.c +0
-0SAFE_MKDIR (cleanup,MNTPOINT ,0755 );/* testcases/kernel/syscalls/mount/mount01.c +1
-1@@ -83,7 +83,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );testcases/kernel/syscalls/mount/mount02.c +1
-1@@ -186,7 +186,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup, mntpoint,DIR_MODE );testcases/kernel/syscalls/mount/mount03.c +1
-1@@ -355,7 +355,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup, mntpoint,DIR_MODE );testcases/kernel/syscalls/mount/mount04.c +1
-1@@ -98,7 +98,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL ); ltpuser =SAFE_GETPWNAM (cleanup, nobody_uid);SAFE_SETEUID (cleanup, ltpuser->pw_uid);testcases/kernel/syscalls/mount/mount05.c +1
-1@@ -104,7 +104,7 @@ void setup(void)SAFE_MKDIR (cleanup, mntpoint_des,DIR_MODE );if (dflag) { -tst_mkfs (NULL , device, fstype,NULL ); +tst_mkfs (NULL , device, fstype,NULL ,NULL );if (mount (device, mntpoint_src, fstype,0 ,NULL ) ==-1 )tst_brkm (TBROK |TERRNO , cleanup,"mount failed" );testcases/kernel/syscalls/mount/mount06.c +1
-1@@ -129,7 +129,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );if (getcwd (path_name,sizeof (path_name)) ==NULL )tst_brkm (TBROK , cleanup,"getcwd failed" );testcases/kernel/syscalls/open/open12.c +1
-1@@ -107,7 +107,7 @@ static void setup(void) goto end; } -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MOUNT (cleanup, device,MNTPOINT , fs_type,MS_STRICTATIME ,NULL ); mount_flag =1 ;testcases/kernel/syscalls/quotactl/quotactl02.c +1
-1@@ -207,7 +207,7 @@ static void setup(void)if (!block_dev)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, block_dev,"xfs" ,NULL ); +tst_mkfs (cleanup, block_dev,"xfs" ,NULL ,NULL );if (mount (block_dev, mntpoint,"xfs" ,0 ,"uquota" ) <0 )tst_brkm (TFAIL |TERRNO ,NULL ,"mount(2) fail" );testcases/kernel/syscalls/rename/rename11.c +1
-1@@ -104,7 +104,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,0755 );if (mount (device,MNTPOINT , fs_type,0 ,NULL ) <0 ) {testcases/kernel/syscalls/renameat/renameat01.c +1
-1@@ -183,7 +183,7 @@ static void setup(void)for (i =0 ; i <43 ; i++)strcat (looppathname,TESTDIR2 ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIRMODE );if (mount (device,MNTPOINT , fs_type,0 ,NULL ) <0 ) { tst_brkm(TBROK | TERRNO, cleanup,testcases/kernel/syscalls/rmdir/rmdir02.c +1
-1@@ -137,7 +137,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to acquire device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );if (mount (device,MNTPOINT , fs_type,0 ,NULL ) ==-1 ) { tst_brkm(TBROK | TERRNO, cleanup,testcases/kernel/syscalls/umount/umount01.c +1
-1@@ -93,7 +93,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );if (mkdir (mntpoint,DIR_MODE ) <0 ) { tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) failed; "testcases/kernel/syscalls/umount/umount02.c +1
-1@@ -117,7 +117,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );memset (long_path,'a' ,PATH_MAX +1 );testcases/kernel/syscalls/umount/umount03.c +1
-1@@ -99,7 +99,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );testcases/kernel/syscalls/umount2/umount2_01.c +1
-1@@ -78,7 +78,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );testcases/kernel/syscalls/umount2/umount2_02.c +1
-1@@ -115,7 +115,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );testcases/kernel/syscalls/umount2/umount2_03.c +1
-1@@ -96,7 +96,7 @@ static void setup(void)if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );testcases/kernel/syscalls/utime/utime06.c +1
-1@@ -119,7 +119,7 @@ static void setup(void)if (!dev)tst_brkm (TCONF , cleanup,"Failed to acquire test device" ); -tst_mkfs (cleanup, dev, fs_type,NULL ); +tst_mkfs (cleanup, dev, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNT_POINT ,0644 );if (mount (dev,MNT_POINT , fs_type,MS_RDONLY ,NULL ) <0 ) {testcases/kernel/syscalls/utimes/utimes01.c +1
-1@@ -139,7 +139,7 @@ static void setup(void)SAFE_CHOWN (cleanup,TESTFILE2 , ltpuser->pw_uid, ltpuser->pw_gid); -tst_mkfs (cleanup, device, fs_type,NULL ); +tst_mkfs (cleanup, device, fs_type,NULL ,NULL );SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE );if (mount (device,MNTPOINT , fs_type,0 ,NULL ) ==-1 ) { tst_brkm(TBROK | TERRNO, cleanup,Signature · 1 line
2.5.0
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 tst_mkfs: add new parameter extra_opts to tst_mkfs function
----- 原始邮件 -----
Quoted 30 lines
发件人: "Cyril Hrubis" <[email protected]>
收件人: "Zorro Lang" <[email protected]>
抄送: [email protected]
发送时间: 星期四, 2016年 3 月 10日 下午 10:24:28
主题: Re: [PATCH v2]tst_mkfs: add new parameterextra_optstotst_mkfsfunctionQuoted 24 lines
doc/test-writing-guidelines.txt +0
-0@@ -906,15 +906,21 @@ NOTE: The default filesytem is hardcoded to 'ext2' inthe sources and can be
#include "test.h"void tst_mkfs(void (cleanup_fn)(void), const char *dev,
doc/test-writing-guidelines.txt +2
-2- const char *fs_type, const char *const fs_opts[]); + const char *fs_type, const char *const fs_opts[] + const char *extra_opts); ------------------------------------------------------------------------------- This function takes a path to a device, filesystem type and an array of extra options passed to mkfs. -The extra options 'fs_opts' should either be 'NULL' if there are none, ora
+The fs options 'fs_opts' should either be 'NULL' if there are none, or a
'NULL' terminated array of strings such as '{"-b", "1024", NULL}'.
Quoted 9 lines
doc/test-writing-guidelines.txt NOTE: The default filesytem is hardcoded to 'ext2' in the sources and can be · line 922
Quoted 6 lines
+The extra options '
extra_opts' should either be 'NULL' if there are none, or
+a string such as "102400". 'extra_opts' will be used behind device name. e.g:doc/test-writing-guidelines.txt +2
-0+mkfs -t ext4 -b 1024 /dev/sda1 102400 + ^^^^^^The documentation file si ascii-doc formatted and the ^^^^^ under 102400 is not correct syntax.
Oh, I will delete this ^^^^^.
Quoted 4 lines
Quoted 4 lines
2.2.16 Verifying a filesystem's free space
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 13 lines
include/test.h int tst_system(const char *command); · line 320
Quoted 11 lines
include/test.h +2
-1@@ -316,10 +316,12 @@ int tst_system(const char *command);* * @dev: path to a device * @fs_type: filesystem type -* @fs_opts: NULL or NULL terminated array of extra mkfs options +* @fs_opts: NULL or NULL terminated array of mkfs options +* @extra_opts: extranal mkfs options which need to behind the device name ^
should beextra_optright?
Yes, you're right. Only one option. I haven't find any other options need to behind device name. If I find more than one, I will change it to char *extra_opts[].
Quoted 77 lines
Quoted 64 lines
include/test.h +2
-1*/ void tst_mkfs (void (cleanup_fn )(void ),const char *dev, -const char *fs_type,const char *const fs_opts[]); +const char *fs_type,const char *const fs_opts[], +const char *extra_opts);/* * Returns filesystem type to be used for the testing. Unless your test is lib/tests/tst_device.c +1
-1@@ -46,7 +46,7 @@ int main(void)printf ("Test device='%s'\n" , dev); -tst_mkfs (cleanup, dev,"ext2" ,NULL ); +tst_mkfs (cleanup, dev,"ext2" ,NULL ,NULL );cleanup ();tst_exit ();lib/tst_mkfs.c +21
-1@@ -21,12 +21,24 @@#define OPTS_MAX 32 +/* +* tst_mkfs: mkfs.$fs_type on $dev with options $fs_opts and $extra_opts +* cleanup_fn - run it when exit with error. +* dev - device path name +* fs_opts - store the options for mkfs (except -t fs_type). Set +* NULL if don't need options. +* extra_opts - extranal mkfs options for mkfs, these options need +* behind the device name, e.g. [fs_size] for ext4. +* Set NULL, if don't need options behind device name. +*/ void tst_mkfs (void (cleanup_fn )(void ),const char *dev, -const char *fs_type,const char *const fs_opts[]) +const char *fs_type,const char *const fs_opts[], +const char *extra_opts) {int i, pos =3 ;const char *argv[OPTS_MAX ] = {"mkfs" ,"-t" , fs_type};char fs_opts_str[1024 ] ="" ; +const char *fs_extra_opts = extra_opts;if (!fs_type)tst_brkm (TBROK , cleanup_fn,"No fs_type specified" );@@ -68,10 +80,22 @@ void tst_mkfs(void (cleanup_fn)(void), const char *dev, } argv[pos++] = dev; + +if (fs_extra_opts) { + argv[pos++] = extra_opts; + +if (pos +1 >OPTS_MAX ) { +tst_brkm (TBROK , cleanup_fn, +"Too much mkfs options" ); + }lib/tst_mkfs.c void tst_mkfs(void (cleanup_fn)(void), const char *dev, · line 98
Quoted 10 lines
lib/tst_mkfs.c +6
-2+ }else { + fs_extra_opts ="None" ; + } + argv[pos] =NULL ; -tst_resm (TINFO ,"Formatting %s with %s extra opts='%s'" , - dev, fs_type, fs_opts_str); +tst_resm (TINFO ,"Formatting %s with %s opts='%s' extra opts='%s'" , + dev, fs_type, fs_opts_str, fs_extra_opts);You can do just:
Quoted 4 lines
extra_opts?extra_opts: ""In order to save the trouble of fidling with two similary named variables that sometimes does not hold the same value.
Yes, good idea!
Quoted 4 lines
Quoted 4 lines
lib/tst_mkfs.c +0
-0tst_run_cmd (cleanup_fn, argv,"/dev/null" ,NULL ,0 ); }
<skip ...>
Quoted 5 lines
Quoted 5 lines
testcases/kernel/syscalls/mmap/mmap16.c +0
-0
Quoted 8 lines
testcases/kernel/syscalls/mmap/mmap16.c static void setup(void) · line 161
Quoted 6 lines
testcases/kernel/syscalls/mmap/mmap16.c +1
-1@@ -158,7 +158,7 @@ static void setup(void) device =tst_acquire_device (cleanup);if (!device)tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); -tst_mkfs (cleanup, device, fs_type, fs_opts); +tst_mkfs (cleanup, device, fs_type, fs_opts,"10240" );So mkfs.ext4 works with 10Mb device as well? The we should go with 10Mb.
I tested 10Mb for mmap16, it works well.
I will send V3 patch with above review suggestions.
Thanks,
Zorro