From 54f5bc01b9509f80b3e8fe16f8bb1bc0228265ab Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Wed, 26 Jul 2017 23:18:03 +0100 Subject: [PATCH] tools: Introduce exit code EINIT_FAILED. Replace -1 (reported as 255) by 4. --- WHATS_NEW | 1 + tools/errors.h | 1 + tools/lvm2cmd.h | 1 + tools/lvmcmdline.c | 14 +++++++------- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index a9b3a084c..20da268a2 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.174 - ================================= + Introduce exit code 4 EINIT_FAILED to replace -1 when initialisation fails. Add synchronization points with udev during reshape of raid LVs. Version 2.02.173 - 20th July 2017 diff --git a/tools/errors.h b/tools/errors.h index bfc0461bf..3d87a4861 100644 --- a/tools/errors.h +++ b/tools/errors.h @@ -19,6 +19,7 @@ #define ECMD_PROCESSED 1 #define ENO_SUCH_CMD 2 #define EINVALID_CMD_LINE 3 +#define EINIT_FAILED 4 #define ECMD_FAILED 5 /* FIXME Also returned by cmdlib. */ diff --git a/tools/lvm2cmd.h b/tools/lvm2cmd.h index 2966ec944..cd2e0ec9d 100644 --- a/tools/lvm2cmd.h +++ b/tools/lvm2cmd.h @@ -40,6 +40,7 @@ typedef void (*lvm2_log_fn_t) (int level, const char *file, int line, #define LVM2_COMMAND_SUCCEEDED 1 /* ECMD_PROCESSED */ #define LVM2_NO_SUCH_COMMAND 2 /* ENO_SUCH_CMD */ #define LVM2_INVALID_PARAMETERS 3 /* EINVALID_CMD_LINE */ +#define LVM2_INIT_FAILED 4 /* EINIT_FAILED */ #define LVM2_PROCESSING_FAILED 5 /* ECMD_FAILED */ /* diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index ae55e1239..81cc5e0d3 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -3420,7 +3420,7 @@ int lvm2_main(int argc, char **argv) const char *run_command_name = NULL; if (!argv) - return -1; + return EINIT_FAILED; base = last_path_component(argv[0]); if (strcmp(base, "lvm") && strcmp(base, "lvm.static") && @@ -3428,16 +3428,16 @@ int lvm2_main(int argc, char **argv) alias = 1; if (!_check_standard_fds()) - return -1; + return EINIT_FAILED; if (!_get_custom_fds(&custom_fds)) - return -1; + return EINIT_FAILED; if (!_close_stray_fds(base, &custom_fds)) - return -1; + return EINIT_FAILED; if (!init_custom_log_streams(&custom_fds)) - return -1; + return EINIT_FAILED; if (is_static() && strcmp(base, "lvm.static") && path_exists(LVM_PATH) && @@ -3461,12 +3461,12 @@ int lvm2_main(int argc, char **argv) if (*argv[1] == '-') { log_error("Specify options after a command: lvm [command] [options]."); - return -1; + return EINVALID_CMD_LINE; } } if (!(cmd = init_lvm(0, 0))) - return -1; + return EINIT_FAILED; /* Store original argv location so we may customise it if we become a daemon */ cmd->argv = argv; -- 2.43.5