common/xfs: Initialise OPTIND for getopts calls
PATCH 1/1 common/xfs: Initialise OPTIND for getopts calls
From: Dave Chinner <[email protected]>
According to the bash man page:
OPTIND is initialized to 1 each time the shell or a shell script is invoked.
This doesn't appear to be true - in tests scripts with no other getopts calls, I'm seeing the getopts loop in _xfs_check to fail to parse input parameters correctly. Tracing shows the parameters are being passed to _xfs_check correctly, but on occassion getopts simply doesn't see the,
Hence when running tests with both external log and real time devices, tests are failing at random because xfs_check is mis-parsing the parameters passed to it and not configuring the external log correctly:
_check_xfs_filesystem: filesystem on /dev/sdg is inconsistent (c) *** xfs_check output ***
aborting - no external log specified for FS with an external log *** end xfs_check output
Fix this by ensuring OPTIND is correctly initialised before using getopts. Do it for all places that call getopts that don't already set OPTIND=1 before starting their parsing loop.
--- common/xfs | 1 + tests/generic/074 | 1 + tests/generic/075 | 1 + tests/generic/112 | 1 + 4 files changed, 4 insertions(+)
common/xfs +1 -0
@@ -119,6 +119,7 @@ _xfs_check() DBOPTS=" " USAGE="Usage: xfs_check [-fsvV] [-l logdev] [-i ino]... [-b bno]... special" + OPTIND=1 while getopts "b:fi:l:stvV" c; do case $c in s) OPTS=$OPTS"-s ";;
tests/generic/074 +1 -0
@@ -87,6 +87,7 @@ _usage() _process_args() { + OPTIND=1 while getopts "f:l:n:?" c $@ do case $c
tests/generic/075 +1 -0
@@ -98,6 +98,7 @@ _usage() _process_args() { + OPTIND=1 while getopts "l:n:N:?" c $@ do case $c
tests/generic/112 +1 -0
@@ -94,6 +94,7 @@ _usage() _process_args() { + OPTIND=1 while getopts "l:n:N:?" c $@ do case $c
Signature · 1 line
2.16.1
Quoted 4 lines · Dave Chinner
From: Dave Chinner <[email protected]>
According to the bash man page:
Quoted 8 lines
OPTIND is initialized to 1 each time the shell or a shell script is invoked.
This doesn't appear to be true - in tests scripts with no other getopts calls, I'm seeing the getopts loop in
_xfs_checkto fail to parse input parameters correctly. Tracing shows the parameters are being passed to_xfs_checkcorrectly, but on occassion getopts simply doesn't see the,
Hmm, unfinished sentence here?
Otherwise looks fine to me.
Thanks,
Eryu
Quoted 78 lines
Hence when running tests with both external log and real time devices, tests are failing at random because
xfs_checkis mis-parsing the parameters passed to it and not configuring the external log correctly:
_check_xfs_filesystem: filesystem on/dev/sdgis inconsistent (c) ***xfs_checkoutput ***
aborting - no external log specified for FS with an external log *** endxfs_checkoutputFix this by ensuring OPTIND is correctly initialised before using getopts. Do it for all places that call getopts that don't already set OPTIND=1 before starting their parsing loop.
Signed-off-by Dave Chinner <[email protected]>--- common/xfs | 1 + tests/generic/074 | 1 + tests/generic/075 | 1 + tests/generic/112 | 1 + 4 files changed, 4 insertions(+)common/xfs +1
-0@@ -119,6 +119,7 @@ _xfs_check() DBOPTS=" " USAGE="Usage: xfs_check [-fsvV] [-l logdev] [-i ino]... [-b bno]... special" + OPTIND=1 while getopts "b:fi:l:stvV" c; do case $c in s) OPTS=$OPTS"-s ";;tests/generic/074 +1
-0@@ -87,6 +87,7 @@ _usage() _process_args() { + OPTIND=1 while getopts "f:l:n:?" c $@ do case $ctests/generic/075 +1
-0@@ -98,6 +98,7 @@ _usage() _process_args() { + OPTIND=1 while getopts "l:n:N:?" c $@ do case $ctests/generic/112 +1
-0@@ -94,6 +94,7 @@ _usage() _process_args() { + OPTIND=1 while getopts "l:n:N:?" c $@ do case $cSignature · 6 lines
2.16.1 -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Eryu Guan
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
According to the bash man page:
OPTIND is initialized to 1 each time the shell or a shell script is invoked.
Quoted 7 lines
Quoted 5 lines
This doesn't appear to be true - in tests scripts with no other getopts calls, I'm seeing the getopts loop in
_xfs_checkto fail to parse input parameters correctly. Tracing shows the parameters are being passed to_xfs_checkcorrectly, but on occassion getopts simply doesn't see the,Hmm, unfinished sentence here?
Typo. "simply doesn't see them."
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]