Return of an exit status of zero when running commands with -help,
instead of returning an error. By general convention, and in
previous versions, tools do not not treat -help as an error.
The AFS::Command perl modules, use -help as an introspection
technique, and fail when commands run with the -help option returns
non-zero.
Change-Id: I6ecd95f6ccd07218a2657dbb4dbf1c13599159f4
Reviewed-on: http://gerrit.openafs.org/8087
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Create a pthreaded version of libafsutil, named liboafs_util.la,
and use this library in all of the pthreaded binaries that we build,
replacing both inclusion of libafsutil.a, and direct compliation of
pthreaded versions of the util source files.
libafsutil.a is provided for legacy LWP applications, and the
convenience library libafsutil_pic.a remains until we address the way
in which the user space cache manager is built and linked.
Change-Id: Ibdc3d6e2fe56ca6f5b882cf03991d1a2e32c62b2
Reviewed-on: http://gerrit.openafs.org/8056
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Convert the libcmd and libcmd_pic libaries to being built using
libtool. Historically, these have been built as LWP code, but they
have no LWP dependencies, and no LWP-specific code within them. So,
make cmd a pthread-only library.
In addition to the libtool library liboafs_cmd.la, we build the
legacy libcmd.a and libcmd_pic.a as convenience libraries. libcmd64.a
(a 64bit variant, used solely by kdump), remains built through
"normal" means.
Update pthreaded users of libcmd to use the new liboafs_cmd.la. For
now, non-pthreaded users are left alone.
Change-Id: Id8445949754d1942f6e8752ae182b4e6f86fe94f
Reviewed-on: http://gerrit.openafs.org/8055
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Convert the libafs_comerr library so that it uses libtool.
comerr uses a pthread lock to protect the error tables, so it needs
to be built as both an LWP, and a pthread library (previously, we've
just built it as LWP, which is probably broken on some platforms, as
it won't define -D_REENTRANT)
libafscom_err.a remains as the LWP variant, and all pthreaded code is
modified to use the libtool liboafs_comerr.la library.
Change-Id: Id421cc97ad8681b42af7a5eb3cb512e1e1ce9a90
Reviewed-on: http://gerrit.openafs.org/8054
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: Derrick Brashear <shadow@your-file-system.com>
Convert opr so that it uses libtool. For backwards compatibility we
still build libopr.a, but we do so as a static convenience library.
As libopr.a may, in the future, be converted to an LWP library, change
all of the pthreaded binaries so that they link against the libtool
library liboafs_opr.la
Change-Id: Icee04ff4745334f06ffba16df5bb07fc9dcc0b54
Reviewed-on: http://gerrit.openafs.org/8034
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
Fix the configuration file path for the cmd test so that it works
when invoked from runtests
Change-Id: Id7d717e163abf5cfab2d551aaf08fb9967a87153
Reviewed-on: http://gerrit.openafs.org/7576
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
With this change, we gain the ability to set our command line options
from krb5.conf configuration files. This is only available for tools
which are implemented using the new cmd_OptionAs accessor methods.
Callers should load their configuration file using
cmd_OpenConfigFile("/path/to/config/file.conf");
(an addition to libauth to return a path to a system wide
configuration file will be forthcoming)
and then set their command name (for example, "fileserver", "afsd",
"vos" and so on) using
cmd_SetCommandName("mycommand");
The accessor functions will then populate their return values with
either:
a) The command line options, if specified
b) The contents of the tag matching the option name, in the
[command_subcommand] section of the configuration file, if it
exists
c) The contents of the same tag, in the [command] section of the
configuration file, if it that exists.
d) The contents of the same tag in the [defaults] section of the
configuration file.
Callers can also gain access to the entire configuration file by
calling cmd_RawFile, or to just the section corresponding to their
command line by calling cmd_RawSection. Note that when using the file
directly, it is up to callers to preserve consistency by implementing
similar inheritance rules as the above.
Change-Id: Ic501ab296af3638f961486869af79c9ce47b77b8
Reviewed-on: http://gerrit.openafs.org/7135
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Add additional tests to the libcmd test suite to verify the
behaviour of cmd_OptionPresent and cmd_OptionAsList
Change-Id: I81a235fb5ee87682c72ca942f1341f77be6fda39
Reviewed-on: http://gerrit.openafs.org/7392
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Instead of bundling our own copies of Russ's C TAP Harness, start using
source pulled from his git repository using the src/external import
mechanism. Note that we are not currently building the floating
point (is_double) portion of the harness.
In the process of doing so, we also upgrade our test harness to the latest
upstream version, 1.11. This is somewhat problematic, as there have been
some significant code changes since the version bundled with OpenAFS.
Work around these by
*) Referencing the basic.h header as <tests/tap/basic.h>, rather than
just <tap/basic.h>, to match the new upstream layout
*) Changing the include path so that the tests/ directory can be
found within it.
Change-Id: I63efbb30248165e5729005b0a791e7eb7afb051d
Reviewed-on: http://gerrit.openafs.org/7374
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Russ Allbery <rra@stanford.edu>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Change the command test so that it uses an enum, rather than #defines
for offsets into the parms array. This is mainly a cosmetic change, but
brings the test suite into line with the way that we're doing stuff in
the "real" code.
Change-Id: Ia9d72e13230edd4fe13af52ba6816cf775693c36
Reviewed-on: http://gerrit.openafs.org/7133
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Tom Keiser <tkeiser@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
The cmd/command-t test needs libopr, so give it to it
Change-Id: I74ca08efffb0c0f6245498c9dc0dcf5287915bbd
Reviewed-on: http://gerrit.openafs.org/6949
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Fix a build error in the cmd tap tests.
Change-Id: I757c5b508784fd938b70ca3829130275707dd39a
Reviewed-on: http://gerrit.openafs.org/4975
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Sometimes, when adding a new command parameter, it's necessary to
prevent it from colliding with an existing abbreviation. This patch
adds a new command flag CMD_NOABBRV which can be set on a parameter
to indicate that it should not be considered when checking for
ambiguous abbreviations.
For example, if a command has the existing '-cell' option which is
popularly abbreviated to '-c', adding a '-config' option would
cause the existing abbreviation to stop working. However, if '-config'
is added with the NOABBRV flag set, '-c' will continue to work.
Change-Id: I3b6d718f9dd81c44fb1d10c904db6a4a0fd763b8
Reviewed-on: http://gerrit.openafs.org/4810
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reorder the arguments of this recently introduced function to
make client code more readable.
Change-Id: I37f662f849bd96176230f75783e2a1c62d94b8c9
Reviewed-on: http://gerrit.openafs.org/4755
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Move the -flag parameter to be the first parameter, to test more of
the positional argument handling.
Change-Id: I637c58e8c76bfc23919f29a1c598084275426773
Reviewed-on: http://gerrit.openafs.org/4710
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
The cmd_OptionAsString function attempts to free the previous value
of the string passed to it. Make sure that we initialise the return
value to NULL before passing it in in the test suite.
Change-Id: I8500d5e6812f4d1655fc50618db472c745604e41
Reviewed-on: http://gerrit.openafs.org/4653
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
The cmd/command-t test requires libroken and was misspelled in the
TESTS file. Multiple tests require LD_LIBRARY_PATH to be set to find
libafsroken if it hasn't been installed, so set it when running
runtests via make check. (Note that this means runtests -o will not
work properly unless the user also sets LD_LIBRARY_PATH.)
Change-Id: Ib64f0505b3b75db33adb6c7b6452dcaac0b05dbc
Reviewed-on: http://gerrit.openafs.org/4594
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Some of our code uses arguments of the form -name=value. Add support
to libcmd for dealing with this type of argument, where name is
declared as CMD_SINGLE (or CMD_SINGLE_OR_FLAG)
Change-Id: Ifb7486abc4f6bf26594936ef11749c4fe29a2e9b
Reviewed-on: http://gerrit.openafs.org/4547
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tidy up the output that comes from cmd's -help option by wrapping
at 78 characters, and picking the breaks sensibly. This changes:
Usage: ./vos move -id <volume name or ID> -fromserver <machine name on source> -
frompartition <partition name on source> -toserver <machine name on destination>
-topartition <partition name on destination> [-live] [-cell <cell name>] [-noau
th] [-localauth] [-verbose] [-encrypt] [-noresolve] [-help]
to...
Usage: ./vos move -id <volume name or ID>
-fromserver <machine name on source>
-frompartition <partition name on source>
-toserver <machine name on destination>
-topartition <partition name on destination> [-live]
[-cell <cell name>] [-noauth] [-localauth] [-verbose]
[-encrypt] [-noresolve] [-help]
Change-Id: I494c287a9370d052763b464df33e69a936edef71
Reviewed-on: http://gerrit.openafs.org/4546
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add the CMD_SINGLE_OR_FLAG option which permits a parameter to
either have a single value, or no value at all. If it has no value,
then it behaves in the same way as the current 'flag' implementation.
Change-Id: I49cf313f1d3b9c369f87b1ff66bfcc038b8aa08a
Reviewed-on: http://gerrit.openafs.org/4545
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add support for adding aliases for parameters, in the same way as we
can for syntaxes. This allows multiple different names for a single
option, as well as providing a way around problems with abbreviations.
Aliases may not be abbreviated.
Change-Id: I5c440cf006cd5fd0065ecf1e54213745428063f7
Reviewed-on: http://gerrit.openafs.org/4544
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add a load of accessor functions to help with pulling values out
from the the cmd_syndesc structure. The idea here is to make it
simpler to manipulate command line values, as well as starting to
hide the structure of the cmd_syndesc structure from callers, with
a view to eventually making it private to the cmd library.
Change-Id: I38757d776364ceacd43e98fda16e995da35da65c
Reviewed-on: http://gerrit.openafs.org/4543
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Rather than having to use cmd_Seek, followed by cmd_AddParam,
followed by another cmd_Seek, add a function which permits parameters
to be added at specific reference points. This allows programs to
declare a list (either as an enum or specific #defines) of parameter
code points, rather than using raw numbers.
Change-Id: I25c0d501e678aa2818d296c776d8c5d03b8cdabe
Reviewed-on: http://gerrit.openafs.org/4542
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Split up the command line parsing behaviour out of the cmd_Dispatch
function, and into a function of its own - cmd_Parse. This lets servers
which only have a single "syntax" installed just parse, without needing
to go through a dispatch function, and all of the control flow
complexity that requires.
Change-Id: Ic4325bf933ee5b28cb80db36ef9b2b5fb6763f41
Reviewed-on: http://gerrit.openafs.org/4541
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add an option to completely disable the matching of abbreviations
when parsing command line options.
Change-Id: Ic3babf584c21f389503c9c69670d400d54a6f4a6
Reviewed-on: http://gerrit.openafs.org/4540
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add a new cmd_DisablePositionalCommands function which can be used
to completely disable positional commands, for functions which have
no desire to make use of them.
Change-Id: I5646e9976e544f06902ea6f85043a6330b1ac2fe
Reviewed-on: http://gerrit.openafs.org/4539
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Add some tests for the command library to the integrated test
suite in tests. These are far from complete, and are mainly there
to ensure that we don't break any of this functionality when modifying
the library.
Change-Id: Ib6fbdca114c005c32c5ba8c41f9e350ca67e1fb8
Reviewed-on: http://gerrit.openafs.org/4538
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>