diff --git a/.gitignore b/.gitignore index 578dacb3..cdce7347 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,8 @@ dump2tar/src/dump2tar dump2tar/src/_dump2tar dump2tar/src/dump2tar.bash fdasd/fdasd +fdasd/_fdasd +fdasd/fdasd.bash hmcdrvfs/hmcdrvfs hsavmcore/check-dep-fuse hsavmcore/hsavmcore diff --git a/fdasd/Makefile b/fdasd/Makefile index facd89ea..c7dbb408 100644 --- a/fdasd/Makefile +++ b/fdasd/Makefile @@ -1,5 +1,10 @@ include ../common.mak +zsh-completions = _fdasd +bash-completions = fdasd.bash + +include ../common_autocomp.mak + libs = $(rootdir)/libvtoc/libvtoc.a \ $(rootdir)/libzds/libzds.a \ $(rootdir)/libdasd/libdasd.a \ diff --git a/fdasd/autocompletion_generator_host.c b/fdasd/autocompletion_generator_host.c new file mode 100644 index 00000000..597ff272 --- /dev/null +++ b/fdasd/autocompletion_generator_host.c @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#include "lib/util_autocomp.h" + +#include "fdasd_cli.h" + +int main(void) +{ + generate_autocomp(opt_vec, "fdasd"); + + return 0; +} diff --git a/fdasd/fdasd.c b/fdasd/fdasd.c index ca6a7fe1..8301f91e 100644 --- a/fdasd/fdasd.c +++ b/fdasd/fdasd.c @@ -21,6 +21,7 @@ #include "lib/zt_common.h" #include "fdasd.h" +#include "fdasd_cli.h" /* global variables */ static struct hd_geometry geo; @@ -138,58 +139,6 @@ static const struct util_prg prg = { } }; -static struct util_opt opt_vec[] = { - UTIL_OPT_SECTION("NON-INTERACTIVE MODE"), - { - .option = { "auto", no_argument, NULL, 'a' }, - .desc = "Create a single partition spanning the entire disk", - }, - { - .option = { "config", required_argument, NULL, 'c' }, - .argument = "FILE", - .desc = "Create partitions(s) based on content of FILE", - }, - { - .option = { "keep_volser", no_argument, NULL, 'k' }, - .desc = "Do not change the current volume serial", - }, - { - .option = { "label", required_argument, NULL, 'l' }, - .argument = "VOLSER", - .desc = "Set the volume serial to VOLSER", - }, - UTIL_OPT_SECTION("MISC"), - { - .option = { "check_host_count", no_argument, NULL, 'C' }, - .desc = "Check if device is in use by other hosts", - }, - { - .option = { "force", optional_argument, NULL, 'f' }, - .argument = "TYPE,SIZE", - .desc = "Force fdasd to work on non DASD devices with assumed " - "TYPE (3390, 3380, or 9345) and blocksize SIZE", - }, - { - .option = { "volser", no_argument, NULL, 'i' }, - .desc = "Print volume serial", - }, - { - .option = { "table", no_argument, NULL, 'p' }, - .desc = "Print partition table", - }, - { - .option = { "verbose", no_argument, NULL, 'r' }, - .desc = "Provide more verbose output", - }, - { - .option = { "silent", no_argument, NULL, 's' }, - .desc = "Suppress messages", - }, - UTIL_OPT_HELP, - UTIL_OPT_VERSION, - UTIL_OPT_END -}; - static int getpos(fdasd_anchor_t *anc, int dsn) { return anc->partno[dsn]; diff --git a/fdasd/fdasd_cli.h b/fdasd/fdasd_cli.h new file mode 100644 index 00000000..3d554186 --- /dev/null +++ b/fdasd/fdasd_cli.h @@ -0,0 +1,64 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright IBM Corp. + */ + +#ifndef FDASD_CLI_H +#define FDASD_CLI_H + +#include "lib/util_opt.h" + +static struct util_opt opt_vec[] = { + UTIL_OPT_SECTION("NON-INTERACTIVE MODE"), + { + .option = { "auto", no_argument, NULL, 'a' }, + .desc = "Create a single partition spanning the entire disk", + }, + { + .option = { "config", required_argument, NULL, 'c' }, + .argument = "FILE", + .desc = "Create partitions(s) based on content of FILE", + }, + { + .option = { "keep_volser", no_argument, NULL, 'k' }, + .desc = "Do not change the current volume serial", + }, + { + .option = { "label", required_argument, NULL, 'l' }, + .argument = "VOLSER", + .desc = "Set the volume serial to VOLSER", + }, + UTIL_OPT_SECTION("MISC"), + { + .option = { "check_host_count", no_argument, NULL, 'C' }, + .desc = "Check if device is in use by other hosts", + }, + { + .option = { "force", optional_argument, NULL, 'f' }, + .argument = "TYPE,SIZE", + .desc = "Force fdasd to work on non DASD devices with assumed " + "TYPE (3390, 3380, or 9345) and blocksize SIZE", + }, + { + .option = { "volser", no_argument, NULL, 'i' }, + .desc = "Print volume serial", + }, + { + .option = { "table", no_argument, NULL, 'p' }, + .desc = "Print partition table", + }, + { + .option = { "verbose", no_argument, NULL, 'r' }, + .desc = "Provide more verbose output", + }, + { + .option = { "silent", no_argument, NULL, 's' }, + .desc = "Suppress messages", + }, + UTIL_OPT_HELP, + UTIL_OPT_VERSION, + UTIL_OPT_END +}; + +#endif