Skip to content

Commit aef1b65

Browse files
Merge pull request #2 from solidigm/sedcli_1_2
sedcli 1.2 version
2 parents ceeaede + 8a594fd commit aef1b65

11 files changed

Lines changed: 543 additions & 489 deletions

File tree

src/argp.c

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static void print_short_usage(const app *app_values)
128128

129129
static void print_info(const app *app_values)
130130
{
131-
sedcli_printf(LOG_INFO, "Try `%s --help | -H' for more information.\n", app_values->name);
131+
sedcli_printf(LOG_INFO, "Try `%s --help' for more information.\n", app_values->name);
132132
}
133133

134134
char *get_short_name_string(const char short_name, char *buf)
@@ -348,8 +348,11 @@ void print_help(const app *app_values, const cli_command *commands)
348348
if (is_command_hidden(commands, i))
349349
continue;
350350

351-
get_short_name_string(commands[i].short_name, short_name);
352-
sedcli_printf(LOG_INFO, "%s%-4s--%-25s%s\n", PADDING, short_name, commands[i].name, commands[i].desc);
351+
char* buf = get_short_name_string(commands[i].short_name, short_name);
352+
if (buf[0])
353+
sedcli_printf(LOG_INFO, "%s%-4s--%-25s%s\n", PADDING, short_name, commands[i].name, commands[i].desc);
354+
else
355+
sedcli_printf(LOG_INFO, "%s--%-25s%s\n", PADDING, commands[i].name, commands[i].desc);
353356
}
354357

355358
sedcli_printf(LOG_INFO, "\nSee 'sedcli <command> --help' for more information on a specific command.\n"
@@ -420,6 +423,11 @@ static int is_help(const char* cmd)
420423
return args_is(cmd, "help", 'H');
421424
}
422425

426+
static int is_version(const char* cmd)
427+
{
428+
return args_is(cmd, "version", 'V');
429+
}
430+
423431
static int get_help_position(int argc, char **argv)
424432
{
425433
for (int i = 2; i < argc; i++)
@@ -491,26 +499,26 @@ void log_command(int argc, char **argv, int result, long long int timespan)
491499
}
492500

493501
static const char *sed_statuses[] = {
494-
[SED_SUCCESS] = "SUCCESS",
495-
[SED_NOT_AUTHORIZED] = "NOT_AUTHORIZED",
496-
[SED_UNKNOWN_ERROR] = "OBSOLETE", // as in spec
497-
[SED_SP_BUSY] = "SP_BUSY",
498-
[SED_SP_FAILED] = "SP_FAILED",
499-
[SED_SP_DISABLED] = "SP_DISABLED",
500-
[SED_SP_FROZEN] = "SP_FROZEN",
501-
[SED_NO_SESSIONS_AVAILABLE] = "NO_SESSIONS_AVAILABLE",
502-
[SED_UNIQUENESS_CONFLICT] = "UNIQUENESS_CONFLICT",
503-
[SED_INSUFFICIENT_SPACE] = "INSUFFICIENT_SPACE",
504-
[SED_INSUFFICIENT_ROWS] = "INSUFFICIENT_ROWS",
505-
[SED_INVALID_FUNCTION] = "OBSOLETE", // not in spec
506-
[SED_INVALID_PARAMETER] = "INVALID PARAMETER",
507-
[SED_INVALID_REFERENCE] = "OBSOLETE", // as in spec
508-
[SED_UNKNOWN_ERROR_1] = "OBSOLETE", // as in spec
509-
[SED_TPER_MALFUNCTION] = "TPER_MALFUNCTION",
510-
[SED_TRANSACTION_FAILURE] = "TRANSACTION_FAILURE",
511-
[SED_RESPONSE_OVERFLOW] = "RESPONSE_OVERFLOW",
512-
[SED_AUTHORITY_LOCKED_OUT] = "AUTHORITY_LOCKED_OUT",
513-
[SED_FAIL] = "FAIL",
502+
/* 0x00 */ [SED_SUCCESS] = "SUCCESS",
503+
/* 0x01 */ [SED_NOT_AUTHORIZED] = "NOT_AUTHORIZED",
504+
/* 0x02 */ [SED_UNKNOWN_ERROR] = "OBSOLETE", // as in spec
505+
/* 0x03 */ [SED_SP_BUSY] = "SP_BUSY",
506+
/* 0x04 */ [SED_SP_FAILED] = "SP_FAILED",
507+
/* 0x05 */ [SED_SP_DISABLED] = "SP_DISABLED",
508+
/* 0x06 */ [SED_SP_FROZEN] = "SP_FROZEN",
509+
/* 0x07 */ [SED_NO_SESSIONS_AVAILABLE] = "NO_SESSIONS_AVAILABLE",
510+
/* 0x08 */ [SED_UNIQUENESS_CONFLICT] = "UNIQUENESS_CONFLICT",
511+
/* 0x09 */ [SED_INSUFFICIENT_SPACE] = "INSUFFICIENT_SPACE",
512+
/* 0x0A */ [SED_INSUFFICIENT_ROWS] = "INSUFFICIENT_ROWS",
513+
/* 0x0B */ [SED_INVALID_FUNCTION] = "OBSOLETE", // not in spec
514+
/* 0x0C */ [SED_INVALID_PARAMETER] = "INVALID PARAMETER",
515+
/* 0x0D */ [SED_INVALID_REFERENCE] = "OBSOLETE", // as in spec
516+
/* 0x0E */ [SED_UNKNOWN_ERROR_1] = "OBSOLETE", // as in spec
517+
/* 0x0F */ [SED_TPER_MALFUNCTION] = "TPER_MALFUNCTION",
518+
/* 0x10 */ [SED_TRANSACTION_FAILURE] = "TRANSACTION_FAILURE",
519+
/* 0x11 */ [SED_RESPONSE_OVERFLOW] = "RESPONSE_OVERFLOW",
520+
/* 0x12 */ [SED_AUTHORITY_LOCKED_OUT] = "AUTHORITY_LOCKED_OUT",
521+
/* 0x3F */ [SED_FAIL] = "FAIL",
514522
};
515523

516524
const char *sed_error_text(int sed_status)
@@ -558,6 +566,15 @@ static void print_sed_status(int status)
558566
if (status == KMIP_SUCCESS_CONNECTED)
559567
sedcli_printf(LOG_ERR, "sedcli-kmip: Successful connection to the KMIP server.\n");
560568
} else {
569+
if (nvme_error == 4)
570+
{
571+
sedcli_printf(LOG_ERR, "sedcli: IOCTL error: 0x04 Interrupted system call.\n");
572+
return;
573+
} else if (nvme_error == 5) {
574+
sedcli_printf(LOG_ERR, "sedcli: IOCTL error: 0x05 I/O error.\n");
575+
return;
576+
}
577+
561578
sed_status = sed_error_text(status);
562579
if (sed_status == NULL && status > 0 && status <= 0xFFFF) {
563580
if (nvme_error) {
@@ -567,7 +584,7 @@ static void print_sed_status(int status)
567584
status, nes.error_bits.SC, nes.error_bits.SCT, nes.error_bits.CRD, nes.error_bits.M, nes.error_bits.DNR);
568585
}
569586
else
570-
sedcli_printf(LOG_ERR, "status: Unknown status.\n");
587+
sedcli_printf(LOG_ERR, "status: Unknown status: %d\n", status);
571588
}
572589
else
573590
sedcli_printf((status == 0) ? LOG_INFO : LOG_ERR, "status: 0x%02x %s\n", status, sed_status);
@@ -611,7 +628,7 @@ int run_command(cli_command *commands, int cmd, int argc, char **argv)
611628

612629
/* execute command */
613630
result = commands[cmd].handle();
614-
if (is_help(argv[1]) == false)
631+
if (is_help(argv[1]) == false && is_version(argv[1]) == false)
615632
print_sed_status(result);
616633

617634
clock_gettime(CLOCK_REALTIME, &t1);

src/configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ function test_compile() {
4646
}
4747

4848
function generate_version() {
49-
SEDCLI_KMIP_VERSION="1.1"
49+
SEDCLI_KMIP_VERSION="1.2"
5050
echo "#define SEDCLI_KMIP_VERSION (\"${SEDCLI_KMIP_VERSION}\")" >> ${CONFIG_H}
5151

52-
SEDCLI_VERSION="1.1"
52+
SEDCLI_VERSION="1.2"
5353
echo "#define SEDCLI_VERSION (\"${SEDCLI_VERSION}\")" >> ${CONFIG_H}
5454
}
5555

0 commit comments

Comments
 (0)