Module Name: src
Committed By: jdolecek
Date: Sat Mar 17 11:07:26 UTC 2018
Modified Files:
src/sbin/nvmectl: devlist.c identify.c logpage.c nvmectl.c nvmectl.h
perftest.c power.c reset.c wdc.c
Log Message:
use setprogname()/getprogname(), do not hardcode the prognam name in fixed
strings
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/nvmectl/devlist.c \
src/sbin/nvmectl/identify.c src/sbin/nvmectl/perftest.c \
src/sbin/nvmectl/power.c
cvs rdiff -u -r1.4 -r1.5 src/sbin/nvmectl/logpage.c \
src/sbin/nvmectl/nvmectl.c src/sbin/nvmectl/nvmectl.h
cvs rdiff -u -r1.1 -r1.2 src/sbin/nvmectl/reset.c src/sbin/nvmectl/wdc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/nvmectl/devlist.c
diff -u src/sbin/nvmectl/devlist.c:1.2 src/sbin/nvmectl/devlist.c:1.3
--- src/sbin/nvmectl/devlist.c:1.2 Sat Jun 4 20:59:49 2016
+++ src/sbin/nvmectl/devlist.c Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: devlist.c,v 1.2 2016/06/04 20:59:49 joerg Exp $ */
+/* $NetBSD: devlist.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: devlist.c,v 1.2 2016/06/04 20:59:49 joerg Exp $");
+__RCSID("$NetBSD: devlist.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/devlist.c 260381 2014-01-06 23:48:47Z jimharris $");
#endif
@@ -52,7 +52,7 @@ __dead static void
devlist_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, DEVLIST_USAGE);
+ fprintf(stderr, "\t%s " DEVLIST_USAGE, getprogname());
exit(1);
}
Index: src/sbin/nvmectl/identify.c
diff -u src/sbin/nvmectl/identify.c:1.2 src/sbin/nvmectl/identify.c:1.3
--- src/sbin/nvmectl/identify.c:1.2 Sat Jun 4 20:59:49 2016
+++ src/sbin/nvmectl/identify.c Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: identify.c,v 1.2 2016/06/04 20:59:49 joerg Exp $ */
+/* $NetBSD: identify.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: identify.c,v 1.2 2016/06/04 20:59:49 joerg Exp $");
+__RCSID("$NetBSD: identify.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/identify.c 253476 2013-07-19 21:40:57Z jimharris $");
#endif
@@ -170,7 +170,7 @@ __dead static void
identify_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, IDENTIFY_USAGE);
+ fprintf(stderr, "\t%s " IDENTIFY_USAGE, getprogname());
exit(1);
}
Index: src/sbin/nvmectl/perftest.c
diff -u src/sbin/nvmectl/perftest.c:1.2 src/sbin/nvmectl/perftest.c:1.3
--- src/sbin/nvmectl/perftest.c:1.2 Thu Jul 14 10:02:43 2016
+++ src/sbin/nvmectl/perftest.c Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: perftest.c,v 1.2 2016/07/14 10:02:43 nonaka Exp $ */
+/* $NetBSD: perftest.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: perftest.c,v 1.2 2016/07/14 10:02:43 nonaka Exp $");
+__RCSID("$NetBSD: perftest.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/perftest.c 257531 2013-11-01 22:05:29Z jimharris $");
#endif
@@ -78,7 +78,7 @@ static void
perftest_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, PERFTEST_USAGE);
+ fprintf(stderr, "\t%s" PERFTEST_USAGE, getprogname());
exit(1);
}
Index: src/sbin/nvmectl/power.c
diff -u src/sbin/nvmectl/power.c:1.2 src/sbin/nvmectl/power.c:1.3
--- src/sbin/nvmectl/power.c:1.2 Sat Jun 4 20:59:49 2016
+++ src/sbin/nvmectl/power.c Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: power.c,v 1.2 2016/06/04 20:59:49 joerg Exp $ */
+/* $NetBSD: power.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (c) 2016 Netflix, Inc
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: power.c,v 1.2 2016/06/04 20:59:49 joerg Exp $");
+__RCSID("$NetBSD: power.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/power.c 296672 2016-03-11 17:25:18Z dim $");
#endif
@@ -52,7 +52,7 @@ __dead static void
power_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, POWER_USAGE);
+ fprintf(stderr, "\t%s " POWER_USAGE, getprogname());
exit(1);
}
Index: src/sbin/nvmectl/logpage.c
diff -u src/sbin/nvmectl/logpage.c:1.4 src/sbin/nvmectl/logpage.c:1.5
--- src/sbin/nvmectl/logpage.c:1.4 Sat Apr 29 00:06:40 2017
+++ src/sbin/nvmectl/logpage.c Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: logpage.c,v 1.4 2017/04/29 00:06:40 nonaka Exp $ */
+/* $NetBSD: logpage.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (c) 2013 EMC Corp.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: logpage.c,v 1.4 2017/04/29 00:06:40 nonaka Exp $");
+__RCSID("$NetBSD: logpage.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/logpage.c 314230 2017-02-25 00:09:16Z imp $");
#endif
@@ -899,7 +899,7 @@ __dead static void
logpage_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, LOGPAGE_USAGE);
+ fprintf(stderr, "\t%s " LOGPAGE_USAGE, getprogname());
exit(1);
}
Index: src/sbin/nvmectl/nvmectl.c
diff -u src/sbin/nvmectl/nvmectl.c:1.4 src/sbin/nvmectl/nvmectl.c:1.5
--- src/sbin/nvmectl/nvmectl.c:1.4 Wed May 3 01:37:16 2017
+++ src/sbin/nvmectl/nvmectl.c Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmectl.c,v 1.4 2017/05/03 01:37:16 christos Exp $ */
+/* $NetBSD: nvmectl.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: nvmectl.c,v 1.4 2017/05/03 01:37:16 christos Exp $");
+__RCSID("$NetBSD: nvmectl.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/nvmecontrol.c 314229 2017-02-25 00:09:12Z imp $");
#endif
@@ -52,7 +52,7 @@ __FBSDID("$FreeBSD: head/sbin/nvmecontro
#include "nvmectl.h"
-static struct nvme_function funcs[] = {
+static const struct nvme_function funcs[] = {
{"devlist", devlist, DEVLIST_USAGE},
{"identify", identify, IDENTIFY_USAGE},
#ifdef PERFTEST_USAGE
@@ -71,21 +71,21 @@ static struct nvme_function funcs[] = {
};
static __dead void
-gen_usage(struct nvme_function *f)
+gen_usage(const struct nvme_function *f)
{
fprintf(stderr, "usage:\n");
while (f->name != NULL) {
- fprintf(stderr, "%s", f->usage);
+ fprintf(stderr, "\t%s %s", getprogname(), f->usage);
f++;
}
exit(1);
}
__dead void
-dispatch(int argc, char *argv[], struct nvme_function *tbl)
+dispatch(int argc, char *argv[], const struct nvme_function *tbl)
{
- struct nvme_function *f = tbl;
+ const struct nvme_function *f = tbl;
if (argv[1] == NULL)
gen_usage(tbl);
@@ -280,6 +280,7 @@ nvme_strvis(u_char *dst, int dlen, const
int
main(int argc, char *argv[])
{
+ setprogname(argv[0]);
if (argc < 2)
gen_usage(funcs);
Index: src/sbin/nvmectl/nvmectl.h
diff -u src/sbin/nvmectl/nvmectl.h:1.4 src/sbin/nvmectl/nvmectl.h:1.5
--- src/sbin/nvmectl/nvmectl.h:1.4 Wed May 3 01:37:16 2017
+++ src/sbin/nvmectl/nvmectl.h Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmectl.h,v 1.4 2017/05/03 01:37:16 christos Exp $ */
+/* $NetBSD: nvmectl.h,v 1.5 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -48,14 +48,14 @@ struct nvme_function {
#define NVME_NS_PREFIX "ns"
#define DEVLIST_USAGE \
-" nvmectl devlist\n"
+"devlist\n"
#define IDENTIFY_USAGE \
-" nvmectl identify [-x [-v]] <controller id|namespace id>\n"
+"identify [-x [-v]] <controller id|namespace id>\n"
#if 0
#define PERFTEST_USAGE \
-" nvmectl perftest <-n num_threads> <-o read|write>\n" \
+"perftest <-n num_threads> <-o read|write>\n" \
" <-s size_in_bytes> <-t time_in_seconds>\n" \
" <-i intr|wait> [-f refthread] [-p]\n" \
" <namespace id>\n"
@@ -63,23 +63,23 @@ struct nvme_function {
#if 0
#define RESET_USAGE \
-" nvmectl reset <controller id>\n"
+"reset <controller id>\n"
#endif
#define LOGPAGE_USAGE \
-" nvmectl logpage <-p page_id> [-b] [-v vendor] [-x] " \
+"logpage <-p page_id> [-b] [-v vendor] [-x] " \
"<controller id|namespace id>\n"
#if 0
#define FIRMWARE_USAGE \
-" nvmectl firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n"
+"firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n"
#endif
#define POWER_USAGE \
-" nvmectl power [-l] [-p new-state [-w workload-hint]] <controller id>\n"
+"power [-l] [-p new-state [-w workload-hint]] <controller id>\n"
#define WDC_USAGE \
-" nvmecontrol wdc (cap-diag|drive-log|get-crash-dump|purge|purge-montior)\n"
+"wdc (cap-diag|drive-log|get-crash-dump|purge|purge-montior)\n"
void devlist(int, char *[]) __dead;
void identify(int, char *[]) __dead;
@@ -102,7 +102,7 @@ void read_controller_data(int, struct nv
void read_namespace_data(int, int, struct nvm_identify_namespace *);
void print_hex(void *, uint32_t);
void read_logpage(int, uint8_t, int, void *, uint32_t);
-__dead void dispatch(int argc, char *argv[], struct nvme_function *f);
+__dead void dispatch(int argc, char *argv[], const struct nvme_function *f);
void nvme_strvis(uint8_t *, int, const uint8_t *, int);
#endif /* __NVMECTL_H__ */
Index: src/sbin/nvmectl/reset.c
diff -u src/sbin/nvmectl/reset.c:1.1 src/sbin/nvmectl/reset.c:1.2
--- src/sbin/nvmectl/reset.c:1.1 Sat Jun 4 16:29:35 2016
+++ src/sbin/nvmectl/reset.c Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: reset.c,v 1.1 2016/06/04 16:29:35 nonaka Exp $ */
+/* $NetBSD: reset.c,v 1.2 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (C) 2012-2013 Intel Corporation
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: reset.c,v 1.1 2016/06/04 16:29:35 nonaka Exp $");
+__RCSID("$NetBSD: reset.c,v 1.2 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/reset.c 253109 2013-07-09 21:14:15Z jimharris $");
#endif
@@ -51,7 +51,7 @@ static void
reset_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, RESET_USAGE);
+ fprintf(stderr, "\t%s " RESET_USAGE, getprogname());
exit(1);
}
Index: src/sbin/nvmectl/wdc.c
diff -u src/sbin/nvmectl/wdc.c:1.1 src/sbin/nvmectl/wdc.c:1.2
--- src/sbin/nvmectl/wdc.c:1.1 Sat Apr 29 00:08:46 2017
+++ src/sbin/nvmectl/wdc.c Sat Mar 17 11:07:26 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc.c,v 1.1 2017/04/29 00:08:46 nonaka Exp $ */
+/* $NetBSD: wdc.c,v 1.2 2018/03/17 11:07:26 jdolecek Exp $ */
/*-
* Copyright (c) 2017 Netflix, Inc
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: wdc.c,v 1.1 2017/04/29 00:08:46 nonaka Exp $");
+__RCSID("$NetBSD: wdc.c,v 1.2 2018/03/17 11:07:26 jdolecek Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/wdc.c 316105 2017-03-28 20:34:02Z ngie $");
#endif
@@ -72,13 +72,13 @@ static void wdc_get_crash_dump(int argc,
static void wdc_purge(int argc, char *argv[]);
static void wdc_purge_monitor(int argc, char *argv[]);
-#define WDC_CAP_DIAG_USAGE "\tnvmecontrol wdc cap-diag [-o path-template]\n"
-#define WDC_DRIVE_LOG_USAGE "\tnvmecontrol wdc drive-log [-o path-template]\n"
-#define WDC_GET_CRASH_DUMP_USAGE "\tnvmecontrol wdc get-crash-dump [-o path-template]\n"
-#define WDC_PURGE_USAGE "\tnvmecontrol wdc purge [-o path-template]\n"
-#define WDC_PURGE_MONITOR_USAGE "\tnvmecontrol wdc purge-monitor\n"
+#define WDC_CAP_DIAG_USAGE "wdc cap-diag [-o path-template]\n"
+#define WDC_DRIVE_LOG_USAGE "wdc drive-log [-o path-template]\n"
+#define WDC_GET_CRASH_DUMP_USAGE "wdc get-crash-dump [-o path-template]\n"
+#define WDC_PURGE_USAGE "wdc purge [-o path-template]\n"
+#define WDC_PURGE_MONITOR_USAGE "wdc purge-monitor\n"
-static struct nvme_function wdc_funcs[] = {
+static const struct nvme_function wdc_funcs[] = {
{"cap-diag", wdc_cap_diag, WDC_CAP_DIAG_USAGE},
{"drive-log", wdc_drive_log, WDC_DRIVE_LOG_USAGE},
{"get-crash-dump", wdc_get_crash_dump, WDC_GET_CRASH_DUMP_USAGE},
@@ -193,7 +193,7 @@ __dead static void
wdc_cap_diag_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, WDC_CAP_DIAG_USAGE);
+ fprintf(stderr, "\t%s " WDC_CAP_DIAG_USAGE, getprogname());
exit(1);
}
@@ -230,7 +230,7 @@ __dead static void
wdc_drive_log_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, WDC_DRIVE_LOG_USAGE);
+ fprintf(stderr, "\t%s " WDC_DRIVE_LOG_USAGE, getprogname());
exit(1);
}
@@ -267,7 +267,7 @@ __dead static void
wdc_get_crash_dump_usage(void)
{
fprintf(stderr, "usage:\n");
- fprintf(stderr, WDC_CAP_DIAG_USAGE);
+ fprintf(stderr, "\t%s " WDC_CAP_DIAG_USAGE, getprogname());
exit(1);
}