diff --git a/.gitignore b/.gitignore index cdce7347..c3d9e655 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,8 @@ fdasd/fdasd.bash hmcdrvfs/hmcdrvfs hsavmcore/check-dep-fuse hsavmcore/hsavmcore +hsavmcore/_hsavmcore +hsavmcore/hsavmcore.bash hyptop/hyptop ip_watcher/xcec-bridge ipl_tools/chreipl diff --git a/hsavmcore/Makefile b/hsavmcore/Makefile index ed98ef87..9225c7f0 100644 --- a/hsavmcore/Makefile +++ b/hsavmcore/Makefile @@ -7,6 +7,11 @@ include ../common.mak +zsh-completions = _hsavmcore +bash-completions = hsavmcore.bash + +include ../common_autocomp.mak + ALL_CPPFLAGS += -D_FILE_OFFSET_BITS=64 ifeq (${HAVE_FUSE},0) @@ -41,7 +46,7 @@ endif ALL_CFLAGS += $(FUSE_CFLAGS) $(SYSTEMD_CFLAGS) LDLIBS += $(FUSE_LDLIBS) $(SYSTEMD_LDLIBS) -lpthread -sources := $(wildcard *.c) +sources := $(filter-out %_host.c, $(wildcard *.c)) objects := $(patsubst %.c,%.o,$(sources)) libs = $(rootdir)/libutil/libutil.a diff --git a/hsavmcore/autocompletion_generator_host.c b/hsavmcore/autocompletion_generator_host.c new file mode 100644 index 00000000..1ed2a97e --- /dev/null +++ b/hsavmcore/autocompletion_generator_host.c @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#include "lib/util_autocomp.h" + +#include "hsavmcore_cli.h" + +int main(void) +{ + generate_autocomp(opt_vec, "hsavmcore"); + + return 0; +} diff --git a/hsavmcore/cmdline_options.c b/hsavmcore/cmdline_options.c index b3918636..375c622d 100644 --- a/hsavmcore/cmdline_options.c +++ b/hsavmcore/cmdline_options.c @@ -16,6 +16,7 @@ #include "lib/util_log.h" #include "cmdline_options.h" +#include "hsavmcore_cli.h" static const struct util_prg prg = { .desc = "hsavmcore is designed to make the dump process with kdump more " @@ -32,91 +33,6 @@ static const struct util_prg prg = { } }; -static struct util_opt opt_vec[] = { - UTIL_OPT_SECTION("CONFIGURATION"), - { - .option = { "config", required_argument, NULL, 'c' }, - .argument = "CONFIGFILE", - .desc = "Path to the configuration file.\n" - "Default: no configuration file is used", - }, - { - .option = { "vmcore", required_argument, NULL, 'C' }, - .argument = "VMCOREFILE", - .desc = "Path to the vmcore file.\n" - "Default: " PROC_VMCORE, - }, - { - .option = { "hsa", required_argument, NULL, 'H' }, - .argument = "ZCOREHSAFILE", - .desc = "Path to the zcore HSA file.\n" - "Default: " ZCORE_HSA, - }, - { - .option = { "workdir", required_argument, NULL, 'W' }, - .argument = "WORKDIR", - .desc = "Path to the work directory where temporary files can be " - "stored.\nDefault: " WORKDIR, - }, - { - .option = { "bmvmcore", required_argument, NULL, 'B' }, - .argument = "VMCOREFILE", - .desc = "Path to the target of the bind mount for the vmcore " - "replacement.\nDefault: " PROC_VMCORE, - }, - { - .option = { "swap", required_argument, NULL, 'S' }, - .argument = "PATH", - .desc = "Path to a swap device or file. The specified swap " - "device or file must exist and have the proper swap " - "format.\nDefault: no swap device or file is activated", - }, - { - .option = { "hsasize", required_argument, NULL, 'T' }, - .argument = "HSASIZE", - .desc = "HSA size in bytes.\n" - "Default: -1 (read from the zcore HSA file)", - }, - { - .option = { "dbgfsmnt", no_argument, NULL, 'D' }, - .desc = "Mount the debug file system.\n" - "Default: the debug file system is not mounted", - }, - { - .option = { "hsamem", no_argument, NULL, 'F' }, - .desc = "Cache the HSA memory in regular memory.\n" - "Default: the HSA memory is cached as a file within " - "WORKDIR", - }, - { - .option = { "norelhsa", no_argument, NULL, 'R' }, - .desc = "Do NOT release the HSA memory after caching.\n" - "Default: the HSA memory is released", - }, - { - .option = { "nobindmnt", no_argument, NULL, 'N' }, - .desc = "Do NOT replace the system's vmcore.\n" - "Default: the system's vmcore is replaced", - }, - UTIL_OPT_SECTION("LOGGING"), - { - .option = { "verbose", no_argument, NULL, 'V' }, - .desc = "Print verbose messages to stdout. Repeat this option " - "for increased verbosity from just error messages to " - "also include warning, information, debug, and trace " - "messages. This option is intended for debugging", - }, - { - .option = { "fusedbg", no_argument, NULL, 'G' }, - .desc = "Enable FUSE debugging.\n" - "Default: FUSE debugging is disabled", - }, - UTIL_OPT_SECTION("GENERAL OPTIONS"), - UTIL_OPT_HELP, - UTIL_OPT_VERSION, - UTIL_OPT_END -}; - void parse_cmdline_options(int argc, char *argv[], struct config *config) { int opt, ret; diff --git a/hsavmcore/hsavmcore_cli.h b/hsavmcore/hsavmcore_cli.h new file mode 100644 index 00000000..fabf7db7 --- /dev/null +++ b/hsavmcore/hsavmcore_cli.h @@ -0,0 +1,99 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#ifndef HSAVMCORE_CLI_H +#define HSAVMCORE_CLI_H + +#include "lib/util_opt.h" + +#include "common.h" + +static struct util_opt opt_vec[] = { + UTIL_OPT_SECTION("CONFIGURATION"), + { + .option = { "config", required_argument, NULL, 'c' }, + .argument = "CONFIGFILE", + .desc = "Path to the configuration file.\n" + "Default: no configuration file is used", + }, + { + .option = { "vmcore", required_argument, NULL, 'C' }, + .argument = "VMCOREFILE", + .desc = "Path to the vmcore file.\n" + "Default: " PROC_VMCORE, + }, + { + .option = { "hsa", required_argument, NULL, 'H' }, + .argument = "ZCOREHSAFILE", + .desc = "Path to the zcore HSA file.\n" + "Default: " ZCORE_HSA, + }, + { + .option = { "workdir", required_argument, NULL, 'W' }, + .argument = "WORKDIR", + .desc = "Path to the work directory where temporary files can be " + "stored.\nDefault: " WORKDIR, + }, + { + .option = { "bmvmcore", required_argument, NULL, 'B' }, + .argument = "VMCOREFILE", + .desc = "Path to the target of the bind mount for the vmcore " + "replacement.\nDefault: " PROC_VMCORE, + }, + { + .option = { "swap", required_argument, NULL, 'S' }, + .argument = "PATH", + .desc = "Path to a swap device or file. The specified swap " + "device or file must exist and have the proper swap " + "format.\nDefault: no swap device or file is activated", + }, + { + .option = { "hsasize", required_argument, NULL, 'T' }, + .argument = "HSASIZE", + .desc = "HSA size in bytes.\n" + "Default: -1 (read from the zcore HSA file)", + }, + { + .option = { "dbgfsmnt", no_argument, NULL, 'D' }, + .desc = "Mount the debug file system.\n" + "Default: the debug file system is not mounted", + }, + { + .option = { "hsamem", no_argument, NULL, 'F' }, + .desc = "Cache the HSA memory in regular memory.\n" + "Default: the HSA memory is cached as a file within " + "WORKDIR", + }, + { + .option = { "norelhsa", no_argument, NULL, 'R' }, + .desc = "Do NOT release the HSA memory after caching.\n" + "Default: the HSA memory is released", + }, + { + .option = { "nobindmnt", no_argument, NULL, 'N' }, + .desc = "Do NOT replace the system's vmcore.\n" + "Default: the system's vmcore is replaced", + }, + UTIL_OPT_SECTION("LOGGING"), + { + .option = { "verbose", no_argument, NULL, 'V' }, + .desc = "Print verbose messages to stdout. Repeat this option " + "for increased verbosity from just error messages to " + "also include warning, information, debug, and trace " + "messages. This option is intended for debugging", + }, + { + .option = { "fusedbg", no_argument, NULL, 'G' }, + .desc = "Enable FUSE debugging.\n" + "Default: FUSE debugging is disabled", + }, + UTIL_OPT_SECTION("GENERAL OPTIONS"), + UTIL_OPT_HELP, + UTIL_OPT_VERSION, + UTIL_OPT_END +}; + +#endif