Bug Summary

File:.build-ci/../src/nvme.c
Warning:line 413, column 3
Potential leak of memory pointed to by 'str'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -O3 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name nvme.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/__w/nvme-cli/nvme-cli/.build-ci -fcoverage-compilation-dir=/__w/nvme-cli/nvme-cli/.build-ci -resource-dir /usr/bin/../lib/clang/22 -include /__w/nvme-cli/nvme-cli/.build-ci/nvme-config.h -I nvme.p -I . -I .. -I src -I ../src -I ccan -I ../ccan -I libnvme/src -I ../libnvme/src -I shared -I ../shared -I /usr/include/json-c -D _FILE_OFFSET_BITS=64 -D _GNU_SOURCE -U NDEBUG -internal-isystem /usr/bin/../lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=gnu99 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-opt-analyze-headers -analyzer-output=html -faddrsig -fdwarf2-cfi-asm -o /__w/nvme-cli/nvme-cli/.build-ci/scan-results/2026-08-08-045408-589-1 -x c ../src/nvme.c
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * NVM-Express command line utility.
4 *
5 * Copyright (c) 2014-2015, Intel Corporation.
6 *
7 * Written by Keith Busch <kbusch@kernel.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23
24/**
25 * This program uses NVMe IOCTLs to run native nvme commands to a device.
26 */
27#include <dirent.h>
28#include <errno(*__errno_location ()).h>
29#include <fcntl.h>
30#include <getopt.h>
31#include <inttypes.h>
32#include <libgen.h>
33#include <locale.h>
34#include <math.h>
35#include <signal.h>
36#include <stdint.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <unistd.h>
41
42#ifdef NVME_HAVE_MMAP
43#include <sys/mman.h>
44#endif
45#include <sys/stat.h>
46#include <sys/types.h>
47
48#include <libnvme.h>
49#include <libnvme-mi.h>
50
51#include "common.h"
52#include "fabrics.h"
53#include "global-config.h"
54#include "logging.h"
55#include "nvme-cmds.h"
56#include "nvme-print.h"
57#include "nvme.h"
58#include "plugin.h"
59#include "argconfig.h"
60#include "cleanup.h"
61#include "sig-util.h"
62#include "suffix-util.h"
63#include "parse-util.h"
64
65#define CREATE_CMD
66#include "nvme-builtin.h"
67#include "malloc.h"
68
69struct feat_cfg {
70 __u8 feature_id; /* enum nvme_features_id */
71 __u8 sel; /* enum nvme_get_features_sel */
72 __u32 namespace_id;
73 __u32 cdw11;
74 __u32 cdw12;
75 __u8 uuid_index;
76 __u32 data_len;
77 bool_Bool raw_binary;
78 bool_Bool changed;
79};
80
81struct passthru_config {
82 __u8 opcode;
83 __u8 flags;
84 __u16 rsvd;
85 __u32 namespace_id;
86 __u32 data_len;
87 __u32 metadata_len;
88 __u32 cdw2;
89 __u32 cdw3;
90 __u32 cdw10;
91 __u32 cdw11;
92 __u32 cdw12;
93 __u32 cdw13;
94 __u32 cdw14;
95 __u32 cdw15;
96 char *input_file;
97 char *metadata;
98 bool_Bool raw_binary;
99 bool_Bool show_command;
100 bool_Bool read;
101 bool_Bool write;
102 __u8 prefill;
103 bool_Bool latency;
104};
105
106struct get_reg_config {
107 int offset;
108 bool_Bool cap;
109 bool_Bool vs;
110 bool_Bool intms;
111 bool_Bool intmc;
112 bool_Bool cc;
113 bool_Bool csts;
114 bool_Bool nssr;
115 bool_Bool aqa;
116 bool_Bool asq;
117 bool_Bool acq;
118 bool_Bool cmbloc;
119 bool_Bool cmbsz;
120 bool_Bool bpinfo;
121 bool_Bool bprsel;
122 bool_Bool bpmbl;
123 bool_Bool cmbmsc;
124 bool_Bool cmbsts;
125 bool_Bool cmbebs;
126 bool_Bool cmbswtp;
127 bool_Bool nssd;
128 bool_Bool crto;
129 bool_Bool pmrcap;
130 bool_Bool pmrctl;
131 bool_Bool pmrsts;
132 bool_Bool pmrebs;
133 bool_Bool pmrswtp;
134 bool_Bool pmrmscl;
135 bool_Bool pmrmscu;
136 bool_Bool fabrics;
137};
138
139struct set_reg_config {
140 int offset;
141 bool_Bool mmio32;
142 __u64 value;
143 __u32 intms;
144 __u32 intmc;
145 __u32 cc;
146 __u32 csts;
147 __u32 nssr;
148 __u32 aqa;
149 __u64 asq;
150 __u64 acq;
151 __u32 bprsel;
152 __u64 bpmbl;
153 __u64 cmbmsc;
154 __u32 nssd;
155 __u32 pmrctl;
156 __u32 pmrmscl;
157 __u32 pmrmscu;
158};
159
160static const char nvme_version_string[] = NVME_VERSION"3.0-b.5";
161
162static struct plugin builtin = {
163 .commands = commands,
164 .name = NULL((void*)0),
165 .desc = NULL((void*)0),
166 .next = NULL((void*)0),
167 .tail = &builtin,
168};
169
170static struct program nvme = {
171 .name = "nvme",
172 .version = nvme_version_string,
173 .usage = "<command> [<device>] [<args>]",
174 .desc = "The '<device>' may be either an NVMe controller "
175 "device (ex: /dev/nvme0), an nvme namespace device "
176 "(ex: /dev/nvme0n1), or a mctp address in the form "
177 "mctp:<net>,<eid>[:ctrl-id]",
178 .extensions = &builtin,
179};
180
181const char *uuid_index = "UUID index";
182const char *namespace_id_desired = "identifier of desired namespace";
183
184static const char *app_tag = "app tag for end-to-end PI";
185static const char *app_tag_mask = "app tag mask for end-to-end PI";
186static const char *block_count = "number of blocks (zeroes based) on device to access";
187static const char *crkey = "current reservation key";
188static const char *csi = "command set identifier";
189static const char *buf_len = "buffer len (if) data is sent or received";
190static const char *domainid = "Domain Identifier";
191static const char *doper = "directive operation";
192static const char *dspec_w_dtype = "directive specification associated with directive type";
193static const char *dtype = "directive type";
194static const char *endgid = "Endurance Group Identifier (ENDGID)";
195static const char *force_unit_access = "force device to commit data before command completes";
196static const char *iekey = "ignore existing res. key";
197static const char *latency = "output latency statistics";
198static const char *lba_format_index = "The index into the LBA Format list\n"
199 "identifying the LBA Format capabilities that are to be returned";
200static const char *limited_retry = "limit media access attempts";
201static const char *lsp = "log specific field";
202static const char *mos = "management operation specific";
203static const char *mo = "management operation";
204static const char *namespace_desired = "desired namespace";
205static const char *namespace_id_optional = "optional namespace attached to controller";
206static const char *nssf = "NVMe Security Specific Field";
207static const char *only_ctrl_dev = "Only controller device is allowed";
208static const char *prinfo = "PI and check field";
209static const char *rae = "Retain an Asynchronous Event";
210static const char *raw_directive = "show directive in binary format";
211static const char *raw_dump = "dump output in binary format";
212static const char *raw_identify = "show identify in binary format";
213static const char *raw_log = "show log in binary format";
214static const char *raw_output = "output in binary format";
215static const char *ref_tag = "reference tag for end-to-end PI";
216static const char *raw_use = "use binary output";
217static const char *rtype = "reservation type";
218static const char *secp = "security protocol (cf. SPC-4)";
219static const char *spsp = "security-protocol-specific (cf. SPC-4)";
220static const char *start_block = "64-bit LBA of first block to access";
221static const char *storage_tag = "storage tag for end-to-end PI";
222static const char *storage_tag_check = "This bit specifies if the Storage Tag field shall be checked as\n"
223 "part of end-to-end data protection processing";
224static const char *uuid_index_specify = "specify uuid index";
225static const char dash[51] = {[0 ... 49] = '=', '\0'};
226static const char space[51] = {[0 ... 49] = ' ', '\0'};
227static const char *offset = "offset of the requested register";
228static const char *intms = "INTMS=0xc register offset";
229static const char *intmc = "INTMC=0x10 register offset";
230static const char *cc = "CC=0x14 register offset";
231static const char *csts = "CSTS=0x1c register offset";
232static const char *nssr = "NSSR=0x20 register offset";
233static const char *aqa = "AQA=0x24 register offset";
234static const char *asq = "ASQ=0x28 register offset";
235static const char *acq = "ACQ=0x30 register offset";
236static const char *bprsel = "BPRSEL=0x44 register offset";
237static const char *bpmbl = "BPMBL=0x48 register offset";
238static const char *cmbmsc = "CMBMSC=0x50 register offset";
239static const char *nssd = "NSSD=0x64 register offset";
240static const char *pmrctl = "PMRCTL=0xe04 register offset";
241static const char *pmrmscl = "PMRMSCL=0xe14 register offset";
242static const char *pmrmscu = "PMRMSCU=0xe18 register offset";
243static const char *ish = "Ignore Shutdown (for NVMe-MI command)";
244
245static void *mmap_registers(struct libnvme_transport_handle *hdl, bool_Bool writable);
246static int munmap_registers(void *addr);
247
248static OPT_VALS(feature_name)struct argconfig_opt_val feature_name[] = {
249 VAL_BYTE("arbitration", NVME_FEAT_FID_ARBITRATION){"arbitration", CFG_BYTE, .val.byte = NVME_FEAT_FID_ARBITRATION
}
,
250 VAL_BYTE("power-mgmt", NVME_FEAT_FID_POWER_MGMT){"power-mgmt", CFG_BYTE, .val.byte = NVME_FEAT_FID_POWER_MGMT
}
,
251 VAL_BYTE("lba-range", NVME_FEAT_FID_LBA_RANGE){"lba-range", CFG_BYTE, .val.byte = NVME_FEAT_FID_LBA_RANGE},
252 VAL_BYTE("temp-thresh", NVME_FEAT_FID_TEMP_THRESH){"temp-thresh", CFG_BYTE, .val.byte = NVME_FEAT_FID_TEMP_THRESH
}
,
253 VAL_BYTE("err-recovery", NVME_FEAT_FID_ERR_RECOVERY){"err-recovery", CFG_BYTE, .val.byte = NVME_FEAT_FID_ERR_RECOVERY
}
,
254 VAL_BYTE("volatile-wc", NVME_FEAT_FID_VOLATILE_WC){"volatile-wc", CFG_BYTE, .val.byte = NVME_FEAT_FID_VOLATILE_WC
}
,
255 VAL_BYTE("num-queues", NVME_FEAT_FID_NUM_QUEUES){"num-queues", CFG_BYTE, .val.byte = NVME_FEAT_FID_NUM_QUEUES
}
,
256 VAL_BYTE("irq-coalesce", NVME_FEAT_FID_IRQ_COALESCE){"irq-coalesce", CFG_BYTE, .val.byte = NVME_FEAT_FID_IRQ_COALESCE
}
,
257 VAL_BYTE("irq-config", NVME_FEAT_FID_IRQ_CONFIG){"irq-config", CFG_BYTE, .val.byte = NVME_FEAT_FID_IRQ_CONFIG
}
,
258 VAL_BYTE("write-atomic", NVME_FEAT_FID_WRITE_ATOMIC){"write-atomic", CFG_BYTE, .val.byte = NVME_FEAT_FID_WRITE_ATOMIC
}
,
259 VAL_BYTE("async-event", NVME_FEAT_FID_ASYNC_EVENT){"async-event", CFG_BYTE, .val.byte = NVME_FEAT_FID_ASYNC_EVENT
}
,
260 VAL_BYTE("auto-pst", NVME_FEAT_FID_AUTO_PST){"auto-pst", CFG_BYTE, .val.byte = NVME_FEAT_FID_AUTO_PST},
261 VAL_BYTE("host-mem-buf", NVME_FEAT_FID_HOST_MEM_BUF){"host-mem-buf", CFG_BYTE, .val.byte = NVME_FEAT_FID_HOST_MEM_BUF
}
,
262 VAL_BYTE("timestamp", NVME_FEAT_FID_TIMESTAMP){"timestamp", CFG_BYTE, .val.byte = NVME_FEAT_FID_TIMESTAMP},
263 VAL_BYTE("kato", NVME_FEAT_FID_KATO){"kato", CFG_BYTE, .val.byte = NVME_FEAT_FID_KATO},
264 VAL_BYTE("hctm", NVME_FEAT_FID_HCTM){"hctm", CFG_BYTE, .val.byte = NVME_FEAT_FID_HCTM},
265 VAL_BYTE("nopsc", NVME_FEAT_FID_NOPSC){"nopsc", CFG_BYTE, .val.byte = NVME_FEAT_FID_NOPSC},
266 VAL_BYTE("rrl", NVME_FEAT_FID_RRL){"rrl", CFG_BYTE, .val.byte = NVME_FEAT_FID_RRL},
267 VAL_BYTE("plm-config", NVME_FEAT_FID_PLM_CONFIG){"plm-config", CFG_BYTE, .val.byte = NVME_FEAT_FID_PLM_CONFIG
}
,
268 VAL_BYTE("plm-window", NVME_FEAT_FID_PLM_WINDOW){"plm-window", CFG_BYTE, .val.byte = NVME_FEAT_FID_PLM_WINDOW
}
,
269 VAL_BYTE("lba-sts-interval", NVME_FEAT_FID_LBA_STS_INTERVAL){"lba-sts-interval", CFG_BYTE, .val.byte = NVME_FEAT_FID_LBA_STS_INTERVAL
}
,
270 VAL_BYTE("host-behavior", NVME_FEAT_FID_HOST_BEHAVIOR){"host-behavior", CFG_BYTE, .val.byte = NVME_FEAT_FID_HOST_BEHAVIOR
}
,
271 VAL_BYTE("sanitize", NVME_FEAT_FID_SANITIZE){"sanitize", CFG_BYTE, .val.byte = NVME_FEAT_FID_SANITIZE},
272 VAL_BYTE("endurance-evt-cfg", NVME_FEAT_FID_ENDURANCE_EVT_CFG){"endurance-evt-cfg", CFG_BYTE, .val.byte = NVME_FEAT_FID_ENDURANCE_EVT_CFG
}
,
273 VAL_BYTE("iocs-profile", NVME_FEAT_FID_IOCS_PROFILE){"iocs-profile", CFG_BYTE, .val.byte = NVME_FEAT_FID_IOCS_PROFILE
}
,
274 VAL_BYTE("spinup-control", NVME_FEAT_FID_SPINUP_CONTROL){"spinup-control", CFG_BYTE, .val.byte = NVME_FEAT_FID_SPINUP_CONTROL
}
,
275 VAL_BYTE("power-loss-signal", NVME_FEAT_FID_POWER_LOSS_SIGNAL){"power-loss-signal", CFG_BYTE, .val.byte = NVME_FEAT_FID_POWER_LOSS_SIGNAL
}
,
276 VAL_BYTE("perf-characteristics", NVME_FEAT_FID_PERF_CHARACTERISTICS){"perf-characteristics", CFG_BYTE, .val.byte = NVME_FEAT_FID_PERF_CHARACTERISTICS
}
,
277 VAL_BYTE("fdp", NVME_FEAT_FID_FDP){"fdp", CFG_BYTE, .val.byte = NVME_FEAT_FID_FDP},
278 VAL_BYTE("fdp-events", NVME_FEAT_FID_FDP_EVENTS){"fdp-events", CFG_BYTE, .val.byte = NVME_FEAT_FID_FDP_EVENTS
}
,
279 VAL_BYTE("ns-admin-label", NVME_FEAT_FID_NS_ADMIN_LABEL){"ns-admin-label", CFG_BYTE, .val.byte = NVME_FEAT_FID_NS_ADMIN_LABEL
}
,
280 VAL_BYTE("key-value", NVME_FEAT_FID_KEY_VALUE){"key-value", CFG_BYTE, .val.byte = NVME_FEAT_FID_KEY_VALUE},
281 VAL_BYTE("ctrl-data-queue", NVME_FEAT_FID_CTRL_DATA_QUEUE){"ctrl-data-queue", CFG_BYTE, .val.byte = NVME_FEAT_FID_CTRL_DATA_QUEUE
}
,
282 VAL_BYTE("emb-mgmt-ctrl-addr", NVME_FEAT_FID_EMB_MGMT_CTRL_ADDR){"emb-mgmt-ctrl-addr", CFG_BYTE, .val.byte = NVME_FEAT_FID_EMB_MGMT_CTRL_ADDR
}
,
283 VAL_BYTE("host-mgmt-agent-addr", NVME_FEAT_FID_HOST_MGMT_AGENT_ADDR){"host-mgmt-agent-addr", CFG_BYTE, .val.byte = NVME_FEAT_FID_HOST_MGMT_AGENT_ADDR
}
,
284 VAL_BYTE("enh-ctrl-metadata", NVME_FEAT_FID_ENH_CTRL_METADATA){"enh-ctrl-metadata", CFG_BYTE, .val.byte = NVME_FEAT_FID_ENH_CTRL_METADATA
}
,
285 VAL_BYTE("ctrl-metadata", NVME_FEAT_FID_CTRL_METADATA){"ctrl-metadata", CFG_BYTE, .val.byte = NVME_FEAT_FID_CTRL_METADATA
}
,
286 VAL_BYTE("ns-metadata", NVME_FEAT_FID_NS_METADATA){"ns-metadata", CFG_BYTE, .val.byte = NVME_FEAT_FID_NS_METADATA
}
,
287 VAL_BYTE("sw-progress", NVME_FEAT_FID_SW_PROGRESS){"sw-progress", CFG_BYTE, .val.byte = NVME_FEAT_FID_SW_PROGRESS
}
,
288 VAL_BYTE("host-id", NVME_FEAT_FID_HOST_ID){"host-id", CFG_BYTE, .val.byte = NVME_FEAT_FID_HOST_ID},
289 VAL_BYTE("resv-nf-mask", NVME_FEAT_FID_RESV_NF_MASK){"resv-nf-mask", CFG_BYTE, .val.byte = NVME_FEAT_FID_RESV_NF_MASK
}
,
290 VAL_BYTE("resv-persist", NVME_FEAT_FID_RESV_PERSIST){"resv-persist", CFG_BYTE, .val.byte = NVME_FEAT_FID_RESV_PERSIST
}
,
291 VAL_BYTE("write-protect", NVME_FEAT_FID_WRITE_PROTECT){"write-protect", CFG_BYTE, .val.byte = NVME_FEAT_FID_WRITE_PROTECT
}
,
292 VAL_BYTE("bp-write-protect", NVME_FEAT_FID_BP_WRITE_PROTECT){"bp-write-protect", CFG_BYTE, .val.byte = NVME_FEAT_FID_BP_WRITE_PROTECT
}
,
293 VAL_END(){ ((void*)0) }
294};
295
296#ifndef HAVE_STRSEP
297static char *strsep(char **stringp, const char *delim)
298{
299 char *s, *end;
300
301 if (!stringp || !*stringp)
302 return NULL((void*)0);
303
304 s = *stringp;
305 end = s + strcspn(s, delim);
306
307 if (*end)
308 *end++ = '\0';
309 else
310 end = NULL((void*)0);
311
312 *stringp = end;
313 return s;
314}
315#endif
316
317static int check_arg_dev(int argc, char **argv)
318{
319 if (optind >= argc) {
320 errno(*__errno_location ()) = EINVAL22;
321 nvme_show_perror(argv[0]);
322 return -EINVAL22;
323 }
324 return 0;
325}
326
327static int get_transport_handle(struct libnvme_global_ctx *ctx, int argc,
328 char **argv, int flags,
329 struct libnvme_transport_handle **hdl)
330{
331 char *devname;
332 int ret;
333
334 ret = check_arg_dev(argc, argv);
335 if (ret)
336 return ret;
337
338 devname = argv[optind];
339
340 ret = libnvme_open(ctx, devname, hdl);
341 if (ret)
342 nvme_show_err(ret, devname);
343
344 return ret;
345}
346
347void put_transport_handle(struct libnvme_transport_handle *hdl)
348{
349 libnvme_close(hdl);
350}
351
352int parse_args(int argc, char *argv[], const char *desc,
353 struct argconfig_commandline_options *opts)
354{
355 int ret;
356
357 ret = argconfig_parse(argc, argv, desc, opts);
358 if (ret)
359 return ret;
360
361 nvme_show_init();
362
363 return 0;
364}
365
366static void setup_transport_handle(struct libnvme_global_ctx *ctx,
367 struct libnvme_transport_handle *hdl,
368 struct argconfig_commandline_options *opts)
369{
370 libnvme_transport_handle_set_submit_entry(hdl, nvme_submit_entry);
371 libnvme_transport_handle_set_submit_exit(hdl, nvme_submit_exit);
372 libnvme_transport_handle_set_decide_retry(hdl, nvme_decide_retry);
373
374#ifdef CONFIG_MI
375 if (libnvme_transport_handle_is_mi(hdl)) {
376 libnvme_mi_ep_t ep = libnvme_transport_handle_get_mi_ep(hdl);
377 if (ep) {
378 libnvme_mi_ep_set_submit_entry(ep, nvme_mi_submit_entry);
379 libnvme_mi_ep_set_submit_exit(ep, nvme_mi_submit_exit);
380 }
381 }
382#endif
383
384 libnvme_set_dry_run(ctx, nvme_args.dry_run);
385 if (nvme_args.timeout != NVME_DEFAULT_IOCTL_TIMEOUT0)
386 libnvme_transport_handle_set_timeout(hdl, nvme_args.timeout);
387}
388
389static bool_Bool is_true(const char *val)
390{
391 return !strcmp(val, "1") ||
392 !strcasecmp(val, "true") ||
393 !strncasecmp(val, "enable", 6);
394}
395
396/*
397 * nvme_apply_option() - apply a single "key=value" pair to @ctx.
398 *
399 * Returns 0 on success, -EINVAL for unknown keys or missing '='.
400 */
401static int nvme_apply_option(struct libnvme_global_ctx *ctx, const char *kv)
402{
403 __cleanup_free__attribute__((cleanup(shr_freep))) char *str = NULL((void*)0);
404 char *key, *val;
405 int ret = 0;
406
407 str = strdup(kv);
16
Memory is allocated
408 if (!str)
17
Assuming 'str' is non-null
18
Taking false branch
409 return -ENOMEM12;
410
411 val = strchr(str, '=')_Generic (0 ? (str) : (void *) 1, const void *: (const char *
) (strchr (str, '=')), default: strchr (str, '='))
;
412 if (!val) {
19
Assuming 'val' is null
20
Taking true branch
413 nvme_show_error("--set-options: missing '=' in '%s'", kv)nvme_show_message(1, "--set-options: missing '=' in '%s'", kv
)
;
21
Potential leak of memory pointed to by 'str'
414 return -EINVAL22;
415 }
416 *val++ = '\0';
417 key = str;
418
419 if (!strcmp(key, "force-4k")) {
420 libnvme_set_force_4k(ctx, is_true(val));
421 } else if (!strcmp(key, "mi-probe-enabled")) {
422 libnvme_set_mi_probe_enabled(ctx, is_true(val));
423 } else if (!strcmp(key, "test-base-dir")) {
424 ret = libnvme_set_test_base_dir(ctx, val);
425 } else if (!strcmp(key, "test-sysfs-dir")) {
426 ret = libnvme_set_test_sysfs_dir(ctx, val);
427 } else {
428 nvme_show_error("--set-options: unknown key '%s'", key)nvme_show_message(1, "--set-options: unknown key '%s'", key);
429 return -EINVAL22;
430 }
431
432 if (ret)
433 nvme_show_error("--set-options: failed to set '%s=%s': %s",nvme_show_message(1, "--set-options: failed to set '%s=%s': %s"
, key, val, libnvme_strerror(-ret))
434 key, val, libnvme_strerror(-ret))nvme_show_message(1, "--set-options: failed to set '%s=%s': %s"
, key, val, libnvme_strerror(-ret))
;
435
436 return ret;
437}
438
439static int __nvme_create_global_ctx(struct libnvme_global_ctx **pctx)
440{
441 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
442 __cleanup_free__attribute__((cleanup(shr_freep))) char *buf = NULL((void*)0);
443 const char *opt;
444 int log_level;
445 char *p;
446 int err;
447
448 ctx = libnvme_create_global_ctx();
449 if (!ctx)
6
Assuming 'ctx' is non-null
7
Taking false branch
450 return -ENOMEM12;
451
452 log_level = map_log_level(nvme_args.verbose, nvme_args.quiet);
453 libnvme_set_logging_file(ctx, stdoutstdout);
454 libnvme_set_logging_level(ctx, log_level, false0, false0);
455
456 if (!nvme_args.set_options)
8
Assuming field 'set_options' is non-null
9
Taking false branch
457 goto out;
458
459 buf = strdup(nvme_args.set_options);
460 if (!buf)
10
Assuming 'buf' is non-null
11
Taking false branch
461 return -ENOMEM12;
462
463 p = buf;
464 while ((opt = strsep(&p, ",")) != NULL((void*)0)) {
12
Loop condition is true. Entering loop body
465 if (!*opt)
13
Assuming the condition is false
14
Taking false branch
466 continue;
467 err = nvme_apply_option(ctx, opt);
15
Calling 'nvme_apply_option'
468 if (err)
469 return err;
470 }
471
472out:
473 *pctx = ctx;
474 ctx = NULL((void*)0);
475
476 return 0;
477}
478
479int nvme_create_global_ctx_hostnqn(struct libnvme_global_ctx **pctx,
480 const char *hostnqn_arg,
481 const char *hostid_arg,
482 char **hostnqn, char **hostid)
483{
484 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
485 __cleanup_free__attribute__((cleanup(shr_freep))) char *hnqn = NULL((void*)0);
486 __cleanup_free__attribute__((cleanup(shr_freep))) char *hid = NULL((void*)0);
487 int err;
488
489 err = __nvme_create_global_ctx(&ctx);
5
Calling '__nvme_create_global_ctx'
490 if (err)
491 return err;
492
493 libnvme_set_ioctl_probing(ctx, !nvme_args.no_ioctl_probing);
494
495#ifdef CONFIG_FABRICS
496 err = libnvmf_host_get_ids(ctx, hostnqn_arg, hostid_arg, &hnqn, &hid);
497 if (err)
498 return err;
499
500 libnvme_set_hostnqn(ctx, hnqn);
501 libnvme_set_hostid(ctx, hid);
502#endif
503
504 if (hostnqn) {
505 *hostnqn = hnqn;
506 hnqn = NULL((void*)0);
507 }
508 if (hostid) {
509 *hostid = hid;
510 hid = NULL((void*)0);
511 }
512
513 *pctx = ctx;
514 ctx = NULL((void*)0);
515
516 return 0;
517}
518
519int nvme_create_global_ctx(struct libnvme_global_ctx **pctx)
520{
521 return nvme_create_global_ctx_hostnqn(pctx, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
4
Calling 'nvme_create_global_ctx_hostnqn'
522}
523
524int parse_and_open(struct libnvme_global_ctx **ctx,
525 struct libnvme_transport_handle **hdl, int argc, char **argv,
526 const char *desc, struct argconfig_commandline_options *opts)
527{
528 struct libnvme_transport_handle *hdl_new;
529 struct libnvme_global_ctx *ctx_new;
530 int ret;
531
532 ret = parse_args(argc, argv, desc, opts);
533 if (ret
1.1
'ret' is 0
)
2
Taking false branch
534 return ret;
535
536 ret = nvme_create_global_ctx(&ctx_new);
3
Calling 'nvme_create_global_ctx'
537 if (ret)
538 return ret;
539
540 ret = get_transport_handle(ctx_new, argc, argv, O_RDONLY00, &hdl_new);
541 if (ret) {
542 libnvme_free_global_ctx(ctx_new);
543 argconfig_print_help(desc, opts);
544 return -ENXIO6;
545 }
546
547 setup_transport_handle(ctx_new, hdl_new, opts);
548
549 *ctx = ctx_new;
550 *hdl = hdl_new;
551
552 return 0;
553}
554
555int open_exclusive(struct libnvme_global_ctx **ctx,
556 struct libnvme_transport_handle **hdl, int argc, char **argv,
557 int ignore_exclusive,
558 struct argconfig_commandline_options *opts)
559{
560 struct libnvme_transport_handle *hdl_new;
561 struct libnvme_global_ctx *ctx_new;
562 int flags = O_RDONLY00;
563 int ret;
564
565 if (!ignore_exclusive)
566 flags |= O_EXCL0200;
567
568 ret = nvme_create_global_ctx(&ctx_new);
569 if (ret)
570 return ret;
571
572 ret = get_transport_handle(ctx_new, argc, argv, flags, &hdl_new);
573 if (ret) {
574 libnvme_free_global_ctx(ctx_new);
575 return -ENXIO6;
576 }
577
578 setup_transport_handle(ctx_new, hdl_new, opts);
579
580 *ctx = ctx_new;
581 *hdl = hdl_new;
582
583 return 0;
584}
585
586static int open_fallback_chardev(struct libnvme_global_ctx *ctx,
587 __u32 nsid,
588 struct libnvme_transport_handle **phdl)
589{
590 struct libnvme_transport_handle *hdl = *phdl;
591 int err;
592
593 if (libnvme_transport_handle_is_ctrl(hdl)) {
594 __cleanup_free__attribute__((cleanup(shr_freep))) char *cdev = NULL((void*)0);
595
596 if (!nsid) {
597 nvme_show_error("controller device not supported without --namespace-id")nvme_show_message(1, "controller device not supported without --namespace-id"
)
;
598 return -EINVAL22;
599 }
600
601 if (asprintf(&cdev, "/dev/%sn%d",
602 libnvme_transport_handle_get_name(hdl), nsid) < 0)
603 return -ENOMEM12;
604
605 libnvme_close(hdl);
606
607 err = libnvme_open(ctx, cdev, &hdl);
608 if (err) {
609 *phdl = NULL((void*)0);
610
611 nvme_show_error("could not open %s", cdev)nvme_show_message(1, "could not open %s", cdev);
612 return err;
613 }
614
615 *phdl = hdl;
616 }
617
618 return 0;
619}
620
621int validate_output_format(const char *format, nvme_print_flags_t *flags)
622{
623 nvme_print_flags_t f;
624 nvme_print_flags_t supported_formats = nvme_args.supported_output_formats;
625
626 if (!format)
627 return -EINVAL22;
628
629 if (!strcmp(format, "normal"))
630 f = NORMAL;
631#ifdef CONFIG_JSONC
632 else if (!strcmp(format, "json") && (supported_formats & JSON))
633 f = JSON;
634#endif /* CONFIG_JSONC */
635 else if (!strcmp(format, "binary") && (supported_formats & BINARY))
636 f = BINARY;
637 else if (!strcmp(format, "tabular") && (supported_formats & TABULAR))
638 f = TABULAR;
639 else
640 return -EINVAL22;
641
642 *flags = f;
643
644 return 0;
645}
646
647bool_Bool nvme_is_output_format_normal(void)
648{
649 nvme_print_flags_t flags;
650
651 if (validate_output_format(nvme_args.output_format, &flags))
652 return false0;
653
654 return flags == NORMAL;
655}
656
657bool_Bool nvme_is_output_format_json(void)
658{
659 nvme_print_flags_t flags;
660
661 if (validate_output_format(nvme_args.output_format, &flags))
662 return false0;
663
664 return flags == JSON;
665}
666
667static int get_smart_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
668{
669 const char *desc = "Retrieve SMART log for the given device "
670 "(or optionally a namespace) in either decoded format "
671 "(default) or binary.";
672
673 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_smart_log *smart_log = NULL((void*)0);
674 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
675 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
676 const char *namespace = "(optional) desired namespace";
677 nvme_print_flags_t flags;
678 int err = -1;
679
680 struct config {
681 __u32 namespace_id;
682 bool_Bool raw_binary;
683 };
684
685 struct config cfg = {
686 .namespace_id = NVME_NSID_ALL,
687 .raw_binary = false0,
688 };
689
690 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_output, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
691 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_output, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
692 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_output))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_output, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
693
694 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
695 if (err)
696 return err;
697
698 err = validate_output_format(nvme_args.output_format, &flags);
699 if (err < 0) {
700 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
701 return err;
702 }
703
704 if (cfg.raw_binary)
705 flags = BINARY;
706
707 if (nvme_args.verbose)
708 flags |= VERBOSE;
709
710 smart_log = libnvme_alloc(sizeof(*smart_log));
711 if (!smart_log)
712 return -ENOMEM12;
713
714 err = nvme_get_log_smart(hdl, cfg.namespace_id, smart_log);
715 if (err) {
716 nvme_show_err(err, "smart log");
717 return err;
718 }
719
720 nvme_show_smart_log(smart_log, cfg.namespace_id,
721 libnvme_transport_handle_get_name(hdl), flags);
722
723 return err;
724}
725
726static int get_ana_log(int argc, char **argv, struct command *acmd,
727 struct plugin *plugin)
728{
729 const char *desc = "Retrieve ANA log for the given device in "
730 "decoded format (default), json or binary.";
731 const char *groups = "Return ANA groups only.";
732
733 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
734 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
735 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
736 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_ana_log *ana_log = NULL((void*)0);
737 size_t max_ana_log_len;
738 __u32 ana_log_len;
739 nvme_print_flags_t flags;
740 int err = -1;
741
742 struct config {
743 bool_Bool groups;
744 };
745
746 struct config cfg = {
747 .groups = false0,
748 };
749
750 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"groups", 'g', ((void*)0), CFG_FLAG, &cfg.groups,
0, groups, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((
void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
751 OPT_FLAG("groups", 'g', &cfg.groups, groups))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"groups", 'g', ((void*)0), CFG_FLAG, &cfg.groups,
0, groups, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((
void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
752
753
754 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
755 if (err)
756 return err;
757
758 err = validate_output_format(nvme_args.output_format, &flags);
759 if (err < 0) {
760 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
761 return err;
762 }
763
764 ctrl = libnvme_alloc(sizeof(*ctrl));
765 if (!ctrl)
766 return -ENOMEM12;
767
768 err = nvme_identify_ctrl(hdl, ctrl);
769 if (err) {
770 nvme_show_error("ERROR : nvme_identify_ctrl() failed: %s",nvme_show_message(1, "ERROR : nvme_identify_ctrl() failed: %s"
, libnvme_strerror(err))
771 libnvme_strerror(err))nvme_show_message(1, "ERROR : nvme_identify_ctrl() failed: %s"
, libnvme_strerror(err))
;
772 return err;
773 }
774
775 max_ana_log_len = libnvme_get_ana_log_len_from_id_ctrl(ctrl, cfg.groups);
776 ana_log_len = max_ana_log_len;
777 if (ana_log_len < max_ana_log_len) {
778 nvme_show_error("ANA log length %zu too large", max_ana_log_len)nvme_show_message(1, "ANA log length %zu too large", max_ana_log_len
)
;
779 return -ENOMEM12;
780 }
781
782 ana_log = libnvme_alloc(ana_log_len);
783 if (!ana_log)
784 return -ENOMEM12;
785
786 err = libnvme_get_ana_log_atomic(hdl, true1, cfg.groups, ana_log, &ana_log_len, 10);
787 if (err) {
788 nvme_show_err(err, "ana-log");
789 return err;
790 }
791
792 nvme_show_ana_log(ana_log, libnvme_transport_handle_get_name(hdl),
793 ana_log_len, flags);
794
795 return err;
796}
797
798static int parse_telemetry_da(struct libnvme_transport_handle *hdl,
799 enum nvme_telemetry_da da,
800 struct nvme_telemetry_log *telem,
801 size_t *size,
802 bool_Bool da4_support)
803
804{
805 size_t dalb, da1lb = le16_to_cpu(telem->dalb1), da2lb = le16_to_cpu(telem->dalb2),
806 da3lb = le16_to_cpu(telem->dalb3), da4lb = le32_to_cpu(telem->dalb4);
807
808 switch (da) {
809 case NVME_TELEMETRY_DA_CTRL_DETERMINE:
810 if (da4_support)
811 dalb = da4lb;
812 else
813 dalb = da3lb;
814 break;
815 case NVME_TELEMETRY_DA_1:
816 dalb = da1lb;
817 break;
818 case NVME_TELEMETRY_DA_2:
819 dalb = da2lb;
820 break;
821 case NVME_TELEMETRY_DA_3:
822 /* dalb3 >= dalb2 >= dalb1 */
823 dalb = da3lb;
824 break;
825 case NVME_TELEMETRY_DA_4:
826 if (da4_support) {
827 dalb = da4lb;
828 } else {
829 nvme_show_error(nvme_show_message(1, "Data area 4 unsupported, bit 6 of Log Page Attributes not set"
)
830 "Data area 4 unsupported, bit 6 of Log Page Attributes not set")nvme_show_message(1, "Data area 4 unsupported, bit 6 of Log Page Attributes not set"
)
;
831 return -EINVAL22;
832 }
833 break;
834 default:
835 nvme_show_error("Invalid data area parameter - %d", da)nvme_show_message(1, "Invalid data area parameter - %d", da);
836 return -EINVAL22;
837 }
838
839 if (dalb == 0) {
840 nvme_show_error("ERROR: No telemetry data block")nvme_show_message(1, "ERROR: No telemetry data block");
841 return -ENOENT2;
842 }
843 *size = (dalb + 1) * NVME_LOG_TELEM_BLOCK_SIZE;
844 return 0;
845}
846
847static int get_log_telemetry_ctrl(struct libnvme_transport_handle *hdl, bool_Bool rae, size_t size,
848 struct nvme_telemetry_log **buf)
849{
850 struct nvme_telemetry_log *log;
851 int err;
852
853 log = libnvme_alloc(size);
854 if (!log)
855 return -ENOMEM12;
856
857 err = nvme_get_log_telemetry_ctrl(hdl, rae, 0, log, size);
858 if (err) {
859 libnvme_free(log);
860 return err;
861 }
862
863 *buf = log;
864 return 0;
865}
866
867static int get_log_telemetry_host(struct libnvme_transport_handle *hdl, size_t size,
868 struct nvme_telemetry_log **buf)
869{
870 struct nvme_telemetry_log *log;
871 int err;
872
873 log = libnvme_alloc(size);
874 if (!log)
875 return -ENOMEM12;
876
877 err = nvme_get_log_telemetry_host(hdl, 0, log, size);
878 if (err) {
879 libnvme_free(log);
880 return err;
881 }
882
883 *buf = log;
884 return 0;
885}
886
887static int __create_telemetry_log_host(struct libnvme_transport_handle *hdl,
888 enum nvme_telemetry_da da,
889 size_t *size,
890 struct nvme_telemetry_log **buf,
891 bool_Bool da4_support)
892{
893 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_telemetry_log *log = NULL((void*)0);
894 int err;
895
896 log = libnvme_alloc(sizeof(*log));
897 if (!log)
898 return -ENOMEM12;
899
900 err = nvme_get_log_create_telemetry_host_mcda(hdl, da, log);
901 if (err)
902 return err;
903
904 err = parse_telemetry_da(hdl, da, log, size, da4_support);
905 if (err)
906 return err;
907
908 return get_log_telemetry_host(hdl, *size, buf);
909}
910
911static int __get_telemetry_log_ctrl(struct libnvme_transport_handle *hdl,
912 bool_Bool rae,
913 enum nvme_telemetry_da da,
914 size_t *size,
915 struct nvme_telemetry_log **buf,
916 bool_Bool da4_support)
917{
918 struct nvme_telemetry_log *log;
919 int err;
920
921 log = libnvme_alloc(NVME_LOG_TELEM_BLOCK_SIZE);
922 if (!log)
923 return -ENOMEM12;
924
925 /*
926 * set rae = true so it won't clear the current telemetry log in
927 * controller
928 */
929 err = nvme_get_log_telemetry_ctrl(hdl, true1, 0, log,
930 NVME_LOG_TELEM_BLOCK_SIZE);
931 if (err)
932 goto free;
933
934 if (!log->ctrlavail) {
935 if (!rae) {
936 err = nvme_get_log_telemetry_ctrl(hdl, rae, 0, log,
937 NVME_LOG_TELEM_BLOCK_SIZE);
938 goto free;
939 }
940
941 *size = NVME_LOG_TELEM_BLOCK_SIZE;
942 *buf = log;
943
944 nvme_show_error("Warning: Telemetry Controller-Initiated Data Not Available.")nvme_show_message(1, "Warning: Telemetry Controller-Initiated Data Not Available."
)
;
945 return 0;
946 }
947
948 err = parse_telemetry_da(hdl, da, log, size, da4_support);
949 if (err)
950 goto free;
951
952 return get_log_telemetry_ctrl(hdl, rae, *size, buf);
953
954free:
955 libnvme_free(log);
956 return err;
957}
958
959static int __get_telemetry_log_host(struct libnvme_transport_handle *hdl,
960 enum nvme_telemetry_da da,
961 size_t *size,
962 struct nvme_telemetry_log **buf,
963 bool_Bool da4_support)
964{
965 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_telemetry_log *log = NULL((void*)0);
966 int err;
967
968 log = libnvme_alloc(sizeof(*log));
969 if (!log)
970 return -ENOMEM12;
971
972 err = nvme_get_log_telemetry_host(hdl, 0, log,
973 NVME_LOG_TELEM_BLOCK_SIZE);
974 if (err)
975 return err;
976
977 err = parse_telemetry_da(hdl, da, log, size, da4_support);
978 if (err)
979 return err;
980
981 return get_log_telemetry_host(hdl, *size, buf);
982}
983
984static int get_telemetry_log(int argc, char **argv, struct command *acmd,
985 struct plugin *plugin)
986{
987 const char *desc = "Retrieve telemetry log and write to binary file";
988 const char *fname = "File name to save raw binary, includes header";
989 const char *hgen = "Have the host tell the controller to generate the report";
990 const char *cgen = "Gather report generated by the controller.";
991 const char *dgen = "Pick which telemetry data area to report. Default is 3 to fetch areas 1-3. Valid options are 1, 2, 3, 4.";
992 const char *mcda = "Host-init Maximum Created Data Area. Valid options are 0 ~ 4 "
993 "If given, This option will override dgen. 0 : controller determines data area";
994
995 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_telemetry_log *log = NULL((void*)0);
996 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *id_ctrl = NULL((void*)0);
997 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
998 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
999 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int output = -1;
1000 int err = 0;
1001 size_t total_size = 0;
1002 __u8 *data_ptr = NULL((void*)0);
1003 int data_written, data_remaining = 0;
1004 nvme_print_flags_t flags;
1005 bool_Bool da4_support = false0,
1006 host_behavior_changed = false0;
1007
1008 struct config {
1009 char *file_name;
1010 __u32 host_gen;
1011 bool_Bool ctrl_init;
1012 int data_area;
1013 bool_Bool rae;
1014 __u8 mcda;
1015 };
1016 struct config cfg = {
1017 .file_name = NULL((void*)0),
1018 .host_gen = 1,
1019 .ctrl_init = false0,
1020 .data_area = 3,
1021 .rae = false0,
1022 .mcda = 0xff,
1023 };
1024
1025 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"output-file", 'O', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"host-generate", 'g', "NUM", CFG_POSITIVE,
&cfg.host_gen, 1, hgen, 0, }, {"controller-init", 'c', (
(void*)0), CFG_FLAG, &cfg.ctrl_init, 0, cgen, 0, }, {"data-area"
, 'd', "NUM", CFG_POSITIVE, &cfg.data_area, 1, dgen, 0, }
, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0,
}, {"mcda", 'm', "NUM", CFG_BYTE, &cfg.mcda, 1, mcda, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1026 OPT_FILE("output-file", 'O', &cfg.file_name, fname),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"output-file", 'O', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"host-generate", 'g', "NUM", CFG_POSITIVE,
&cfg.host_gen, 1, hgen, 0, }, {"controller-init", 'c', (
(void*)0), CFG_FLAG, &cfg.ctrl_init, 0, cgen, 0, }, {"data-area"
, 'd', "NUM", CFG_POSITIVE, &cfg.data_area, 1, dgen, 0, }
, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0,
}, {"mcda", 'm', "NUM", CFG_BYTE, &cfg.mcda, 1, mcda, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1027 OPT_UINT("host-generate", 'g', &cfg.host_gen, hgen),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"output-file", 'O', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"host-generate", 'g', "NUM", CFG_POSITIVE,
&cfg.host_gen, 1, hgen, 0, }, {"controller-init", 'c', (
(void*)0), CFG_FLAG, &cfg.ctrl_init, 0, cgen, 0, }, {"data-area"
, 'd', "NUM", CFG_POSITIVE, &cfg.data_area, 1, dgen, 0, }
, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0,
}, {"mcda", 'm', "NUM", CFG_BYTE, &cfg.mcda, 1, mcda, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1028 OPT_FLAG("controller-init", 'c', &cfg.ctrl_init, cgen),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"output-file", 'O', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"host-generate", 'g', "NUM", CFG_POSITIVE,
&cfg.host_gen, 1, hgen, 0, }, {"controller-init", 'c', (
(void*)0), CFG_FLAG, &cfg.ctrl_init, 0, cgen, 0, }, {"data-area"
, 'd', "NUM", CFG_POSITIVE, &cfg.data_area, 1, dgen, 0, }
, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0,
}, {"mcda", 'm', "NUM", CFG_BYTE, &cfg.mcda, 1, mcda, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1029 OPT_UINT("data-area", 'd', &cfg.data_area, dgen),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"output-file", 'O', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"host-generate", 'g', "NUM", CFG_POSITIVE,
&cfg.host_gen, 1, hgen, 0, }, {"controller-init", 'c', (
(void*)0), CFG_FLAG, &cfg.ctrl_init, 0, cgen, 0, }, {"data-area"
, 'd', "NUM", CFG_POSITIVE, &cfg.data_area, 1, dgen, 0, }
, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0,
}, {"mcda", 'm', "NUM", CFG_BYTE, &cfg.mcda, 1, mcda, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1030 OPT_FLAG("rae", 'r', &cfg.rae, rae),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"output-file", 'O', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"host-generate", 'g', "NUM", CFG_POSITIVE,
&cfg.host_gen, 1, hgen, 0, }, {"controller-init", 'c', (
(void*)0), CFG_FLAG, &cfg.ctrl_init, 0, cgen, 0, }, {"data-area"
, 'd', "NUM", CFG_POSITIVE, &cfg.data_area, 1, dgen, 0, }
, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0,
}, {"mcda", 'm', "NUM", CFG_BYTE, &cfg.mcda, 1, mcda, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1031 OPT_BYTE("mcda", 'm', &cfg.mcda, mcda))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"output-file", 'O', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"host-generate", 'g', "NUM", CFG_POSITIVE,
&cfg.host_gen, 1, hgen, 0, }, {"controller-init", 'c', (
(void*)0), CFG_FLAG, &cfg.ctrl_init, 0, cgen, 0, }, {"data-area"
, 'd', "NUM", CFG_POSITIVE, &cfg.data_area, 1, dgen, 0, }
, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0,
}, {"mcda", 'm', "NUM", CFG_BYTE, &cfg.mcda, 1, mcda, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1032
1033
1034 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1035 if (err)
1036 return err;
1037
1038 err = validate_output_format(nvme_args.output_format, &flags);
1039 if (err < 0) {
1040 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1041 return err;
1042 }
1043
1044 if (!cfg.file_name) {
1045 nvme_show_error("Please provide an output file!")nvme_show_message(1, "Please provide an output file!");
1046 return -EINVAL22;
1047 }
1048
1049 cfg.host_gen = !!cfg.host_gen;
1050
1051 if (cfg.mcda != 0xff) {
1052 if (cfg.ctrl_init || !cfg.host_gen) {
1053 nvme_show_error("mcda allowed for Host-init Creation!")nvme_show_message(1, "mcda allowed for Host-init Creation!");
1054 return -EINVAL22;
1055 }
1056 cfg.data_area = cfg.mcda;
1057 }
1058
1059 if (cfg.data_area == 4) {
1060 id_ctrl = libnvme_alloc(sizeof(*id_ctrl));
1061 if (!id_ctrl)
1062 return -ENOMEM12;
1063
1064 err = nvme_identify_ctrl(hdl, id_ctrl);
1065 if (err) {
1066 nvme_show_error("identify-ctrl")nvme_show_message(1, "identify-ctrl");
1067 return err;
1068 }
1069
1070 da4_support = id_ctrl->lpa & 0x40;
1071
1072 if (!da4_support) {
1073 nvme_show_error("%s: Telemetry data area 4 not supported by device",nvme_show_message(1, "%s: Telemetry data area 4 not supported by device"
, __func__)
1074 __func__)nvme_show_message(1, "%s: Telemetry data area 4 not supported by device"
, __func__)
;
1075 return -EINVAL22;
1076 }
1077
1078 err = libnvme_set_etdas(hdl, &host_behavior_changed);
1079 if (err) {
1080 nvme_show_error("%s: Failed to set ETDAS bit", __func__)nvme_show_message(1, "%s: Failed to set ETDAS bit", __func__);
1081 return err;
1082 }
1083 }
1084
1085 output = nvme_open_rawdata(cfg.file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)open((cfg.file_name), (01 | 0100 | 01000), 0666);
1086 if (output < 0) {
1087 nvme_show_error("Failed to open output file %s: %s!",nvme_show_message(1, "Failed to open output file %s: %s!", cfg
.file_name, libnvme_strerror((*__errno_location ())))
1088 cfg.file_name, libnvme_strerror(errno))nvme_show_message(1, "Failed to open output file %s: %s!", cfg
.file_name, libnvme_strerror((*__errno_location ())))
;
1089 return output;
1090 }
1091
1092 log = libnvme_alloc(sizeof(*log));
1093 if (!log)
1094 return -ENOMEM12;
1095
1096 if (cfg.ctrl_init)
1097 err = __get_telemetry_log_ctrl(hdl, cfg.rae, cfg.data_area,
1098 &total_size, &log, da4_support);
1099 else if (cfg.host_gen)
1100 err = __create_telemetry_log_host(hdl, cfg.data_area,
1101 &total_size, &log, da4_support);
1102 else
1103 err = __get_telemetry_log_host(hdl, cfg.data_area,
1104 &total_size, &log, da4_support);
1105
1106 if (err) {
1107 nvme_show_err(err, "get-telemetry-log");
1108 if (err > 0)
1109 nvme_show_error("Failed to acquire telemetry log %d!", err)nvme_show_message(1, "Failed to acquire telemetry log %d!", err
)
;
1110 return err;
1111 }
1112
1113 data_remaining = total_size;
1114 data_ptr = (__u8 *)log;
1115
1116 while (data_remaining) {
1117 data_written = write(output, data_ptr, data_remaining);
1118 if (data_written < 0) {
1119 err = -errno(*__errno_location ());
1120 nvme_show_error("ERROR: %s: : write failed with error : %s",nvme_show_message(1, "ERROR: %s: : write failed with error : %s"
, __func__, libnvme_strerror((*__errno_location ())))
1121 __func__, libnvme_strerror(errno))nvme_show_message(1, "ERROR: %s: : write failed with error : %s"
, __func__, libnvme_strerror((*__errno_location ())))
;
1122 break;
1123 } else if (data_written <= data_remaining) {
1124 data_remaining -= data_written;
1125 data_ptr += data_written;
1126 } else {
1127 /* Unexpected overwrite */
1128 nvme_show_error("Failure: Unexpected telemetry log overwrite - data_remaining = 0x%x, data_written = 0x%x",nvme_show_message(1, "Failure: Unexpected telemetry log overwrite - data_remaining = 0x%x, data_written = 0x%x"
, data_remaining, data_written)
1129 data_remaining, data_written)nvme_show_message(1, "Failure: Unexpected telemetry log overwrite - data_remaining = 0x%x, data_written = 0x%x"
, data_remaining, data_written)
;
1130 err = -1;
1131 break;
1132 }
1133 }
1134
1135 if (fsync(output) < 0) {
1136 nvme_show_error("ERROR : %s: : fsync : %s", __func__, libnvme_strerror(errno))nvme_show_message(1, "ERROR : %s: : fsync : %s", __func__, libnvme_strerror
((*__errno_location ())))
;
1137 return -1;
1138 }
1139
1140 if (host_behavior_changed) {
1141 host_behavior_changed = false0;
1142 err = libnvme_clear_etdas(hdl, &host_behavior_changed);
1143 if (err) {
1144 nvme_show_error("%s: Failed to clear ETDAS bit", __func__)nvme_show_message(1, "%s: Failed to clear ETDAS bit", __func__
)
;
1145 return err;
1146 }
1147 }
1148
1149 return err;
1150}
1151
1152static int get_endurance_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
1153{
1154 const char *desc = "Retrieves endurance groups log page and prints the log.";
1155 const char *group_id = "The endurance group identifier";
1156
1157 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_endurance_group_log *endurance_log = NULL((void*)0);
1158 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1159 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1160 nvme_print_flags_t flags;
1161 int err;
1162
1163 struct config {
1164 __u16 group_id;
1165 };
1166
1167 struct config cfg = {
1168 .group_id = 0,
1169 };
1170
1171 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"group-id", 'g', "NUM", CFG_SHORT, &cfg.group_id,
1, group_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1172 OPT_SHRT("group-id", 'g', &cfg.group_id, group_id))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"group-id", 'g', "NUM", CFG_SHORT, &cfg.group_id,
1, group_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1173
1174
1175 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1176 if (err)
1177 return err;
1178
1179 err = validate_output_format(nvme_args.output_format, &flags);
1180 if (err < 0) {
1181 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1182 return err;
1183 }
1184
1185 endurance_log = libnvme_alloc(sizeof(*endurance_log));
1186 if (!endurance_log)
1187 return -ENOMEM12;
1188
1189 err = nvme_get_log_endurance_group(hdl, cfg.group_id, endurance_log);
1190 if (err) {
1191 nvme_show_err(err, "endurance log");
1192 return err;
1193 }
1194
1195 nvme_show_endurance_log(endurance_log, cfg.group_id,
1196 libnvme_transport_handle_get_name(hdl), flags);
1197
1198 return err;
1199}
1200
1201static int collect_effects_log(struct libnvme_transport_handle *hdl, enum nvme_csi csi,
1202 struct list_head *list, int flags)
1203{
1204 nvme_effects_log_node_t *node;
1205 int err;
1206
1207 node = libnvme_alloc(sizeof(*node));
1208 if (!node)
1209 return -ENOMEM12;
1210
1211 node->csi = csi;
1212
1213 err = nvme_get_log_cmd_effects(hdl, csi, &node->effects);
1214 if (err) {
1215 libnvme_free(node);
1216 return err;
1217 }
1218 list_add(list, &node->node)list_add_(list, &node->node, "../src/nvme.c" ":" "1218"
)
;
1219 return 0;
1220}
1221
1222static int get_effects_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
1223{
1224 const char *desc = "Retrieve command effects log page and print the table.";
1225
1226 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1227 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1228 struct libnvme_passthru_cmd cmd;
1229 struct list_head log_pages;
1230 nvme_effects_log_node_t *node;
1231
1232 void *bar = NULL((void*)0);
1233
1234 int err = -1;
1235 nvme_print_flags_t flags;
1236
1237 struct config {
1238 bool_Bool raw_binary;
1239 int csi;
1240 };
1241
1242 struct config cfg = {
1243 .raw_binary = false0,
1244 .csi = -1,
1245 };
1246
1247 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_log, 0, }, {"csi", 'c', "NUM", CFG_INT, &cfg.csi
, 1, csi, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1248 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_log),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_log, 0, }, {"csi", 'c', "NUM", CFG_INT, &cfg.csi
, 1, csi, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1249 OPT_INT("csi", 'c', &cfg.csi, csi))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_log, 0, }, {"csi", 'c', "NUM", CFG_INT, &cfg.csi
, 1, csi, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1250
1251
1252 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1253 if (err)
1254 return err;
1255
1256 err = validate_output_format(nvme_args.output_format, &flags);
1257 if (err < 0) {
1258 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1259 return err;
1260 }
1261
1262 if (cfg.raw_binary)
1263 flags = BINARY;
1264
1265 if (nvme_args.verbose)
1266 flags |= VERBOSE;
1267
1268 list_head_init(&log_pages);
1269
1270 if (cfg.csi < 0) {
1271 __u64 cap;
1272 if (libnvme_transport_handle_is_ns(hdl)) {
1273 nvme_show_error("Namespace device isn't allowed without csi")nvme_show_message(1, "Namespace device isn't allowed without csi"
)
;
1274 return -EINVAL22;
1275 }
1276 bar = mmap_registers(hdl, false0);
1277
1278 if (bar) {
1279 cap = mmio_read64(bar + NVME_REG_CAP);
1280 munmap_registers(bar);
1281 } else {
1282 nvme_init_get_property(&cmd, NVME_REG_CAP);
1283 err = libnvme_exec_admin_passthru(hdl, &cmd);
1284 if (err)
1285 goto cleanup_list;
1286 cap = cmd.result;
1287 }
1288
1289 if (NVME_CAP_CSS(cap)(((cap) >> NVME_CAP_CSS_SHIFT) & NVME_CAP_CSS_MASK) & NVME_CAP_CSS_NVM)
1290 err = collect_effects_log(hdl, NVME_CSI_NVM,
1291 &log_pages, flags);
1292
1293 if (!err && (NVME_CAP_CSS(cap)(((cap) >> NVME_CAP_CSS_SHIFT) & NVME_CAP_CSS_MASK) & NVME_CAP_CSS_CSI))
1294 err = collect_effects_log(hdl, NVME_CSI_ZNS,
1295 &log_pages, flags);
1296 } else {
1297 err = collect_effects_log(hdl, cfg.csi, &log_pages, flags);
1298 }
1299
1300 if (err) {
1301 nvme_show_err(err, "effects log page");
1302 goto cleanup_list;
1303 }
1304
1305 nvme_print_effects_log_pages(&log_pages, flags);
1306
1307cleanup_list:
1308 while ((node = list_pop(&log_pages, nvme_effects_log_node_t, node)((nvme_effects_log_node_t *)list_pop_((&log_pages), (__builtin_offsetof
(nvme_effects_log_node_t, node) + ((typeof(((nvme_effects_log_node_t
*)0)->node) *)0 != (struct list_node *)0))))
))
1309 libnvme_free(node);
1310
1311 return err;
1312}
1313
1314static int get_supported_log_pages(int argc, char **argv, struct command *acmd,
1315 struct plugin *plugin)
1316{
1317 const char *desc = "Retrieve supported logs and print the table.";
1318
1319 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_supported_log_pages *supports = NULL((void*)0);
1320 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1321 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1322 nvme_print_flags_t flags;
1323 int err = -1;
1324
1325 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1326
1327 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1328 if (err)
1329 return err;
1330
1331 err = validate_output_format(nvme_args.output_format, &flags);
1332 if (err < 0) {
1333 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1334 return err;
1335 }
1336
1337 if (nvme_args.verbose)
1338 flags |= VERBOSE;
1339
1340 supports = libnvme_alloc(sizeof(*supports));
1341 if (!supports)
1342 return -ENOMEM12;
1343
1344 err = nvme_get_log_supported_log_pages(hdl, supports);
1345 if (err) {
1346 nvme_show_err(err, "supported log pages");
1347 return err;
1348 }
1349
1350 nvme_show_supported_log(supports, libnvme_transport_handle_get_name(hdl),
1351 flags);
1352
1353 return err;
1354}
1355
1356static int get_error_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
1357{
1358 const char *desc = "Retrieve specified number of "
1359 "error log entries from a given device "
1360 "in either decoded format (default) or binary.";
1361 const char *log_entries = "number of entries to retrieve";
1362 const char *status = "output specified STATUS entry only";
1363 const char *nsid = "output specified NSID entry only";
1364 const char *trtype = "output specified TRTYPE entry only";
1365 const char *opcode = "output specified OPC entry only";
1366 const char *sqid = "output specified SQID entry only";
1367 const char *valid_entry = "output valid entry only";
1368 const char *lba = "output specified LBA entry only";
1369 const char *csi = "output specified CSI entry only";
1370 const char *raw = "dump in binary format";
1371
1372 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_error_log_page *err_log = NULL((void*)0);
1373 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1374 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1375 struct nvme_id_ctrl ctrl = { 0 };
1376 nvme_print_flags_t flags;
1377 int err = -1;
1378
1379 struct config {
1380 __u32 log_entries;
1381 bool_Bool raw_binary;
1382 struct nvme_error_log_filter flt;
1383 };
1384
1385 struct config cfg = {
1386 .log_entries = 64,
1387 .raw_binary = false0,
1388 };
1389
1390 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1391 OPT_UINT("log-entries", 'e', &cfg.log_entries, log_entries),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1392 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1393 OPT_FLAG("valid-entry", 'V', &cfg.flt.valid, valid_entry),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1394 OPT_SHRT("sqid", 'S', &cfg.flt.sqid, sqid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1395 OPT_SHRT("status", 's', &cfg.flt.status, status),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1396 OPT_SUFFIX("lba", 'l', &cfg.flt.lba, lba),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1397 OPT_UINT("namespace-id", 'n', &cfg.flt.nsid, nsid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1398 OPT_BYTE("trtype", 't', &cfg.flt.trtype, trtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1399 OPT_BYTE("csi", 'c', &cfg.flt.csi, csi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1400 OPT_BYTE("opcode", 'O', &cfg.flt.opcode, opcode))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw, 0, }, {"valid-entry", 'V', ((void
*)0), CFG_FLAG, &cfg.flt.valid, 0, valid_entry, 0, }, {"sqid"
, 'S', "NUM", CFG_SHORT, &cfg.flt.sqid, 1, sqid, 0, }, {"status"
, 's', "NUM", CFG_SHORT, &cfg.flt.status, 1, status, 0, }
, {"lba", 'l', "IONUM", CFG_LONG_SUFFIX, &cfg.flt.lba, 1,
lba, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg
.flt.nsid, 1, nsid, 0, }, {"trtype", 't', "NUM", CFG_BYTE, &
cfg.flt.trtype, 1, trtype, 0, }, {"csi", 'c', "NUM", CFG_BYTE
, &cfg.flt.csi, 1, csi, 0, }, {"opcode", 'O', "NUM", CFG_BYTE
, &cfg.flt.opcode, 1, opcode, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1401
1402 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1403 if (err)
1404 return err;
1405
1406 err = validate_output_format(nvme_args.output_format, &flags);
1407 if (err < 0) {
1408 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1409 return err;
1410 }
1411
1412 if (cfg.raw_binary)
1413 flags = BINARY;
1414
1415 if (!cfg.log_entries) {
1416 nvme_show_error("non-zero log-entries is required param")nvme_show_message(1, "non-zero log-entries is required param"
)
;
1417 return -1;
1418 }
1419
1420 err = nvme_identify_ctrl(hdl, &ctrl);
1421 if (err) {
1422 nvme_show_err(err, "identify controller");
1423 return err;
1424 }
1425
1426 cfg.log_entries = min(cfg.log_entries, ctrl.elpe + 1)((cfg.log_entries) > (ctrl.elpe + 1) ? (ctrl.elpe + 1) : (
cfg.log_entries))
;
1427 err_log = libnvme_alloc(cfg.log_entries * sizeof(struct nvme_error_log_page));
1428 if (!err_log)
1429 return -ENOMEM12;
1430
1431 err = nvme_get_log_error(hdl, NVME_NSID_ALL, cfg.log_entries, err_log);
1432 if (err) {
1433 nvme_show_err(err, "error log");
1434 return err;
1435 }
1436
1437 nvme_show_error_log(err_log, cfg.log_entries,
1438 libnvme_transport_handle_get_name(hdl), &cfg.flt,
1439 flags);
1440
1441 return err;
1442}
1443
1444static int get_fw_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
1445{
1446 const char *desc = "Retrieve the firmware log for the "
1447 "specified device in either decoded format (default) or binary.";
1448
1449 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_firmware_slot *fw_log = NULL((void*)0);
1450 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1451 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1452 nvme_print_flags_t flags;
1453 int err;
1454
1455 struct config {
1456 bool_Bool raw_binary;
1457 };
1458
1459 struct config cfg = {
1460 .raw_binary = false0,
1461 };
1462
1463 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1464 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1465
1466 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1467 if (err)
1468 return err;
1469
1470 err = validate_output_format(nvme_args.output_format, &flags);
1471 if (err < 0) {
1472 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1473 return err;
1474 }
1475
1476 if (cfg.raw_binary)
1477 flags = BINARY;
1478
1479 fw_log = libnvme_alloc(sizeof(*fw_log));
1480 if (!fw_log)
1481 return -ENOMEM12;
1482
1483 err = nvme_get_log_fw_slot(hdl, false0, fw_log);
1484 if (err) {
1485 nvme_show_err(err, "fw log");
1486 return err;
1487 }
1488
1489 nvme_show_fw_log(fw_log, libnvme_transport_handle_get_name(hdl), flags);
1490
1491 return err;
1492}
1493
1494static int get_changed_ns_list_log(int argc, char **argv, bool_Bool alloc)
1495{
1496 __cleanup_free__attribute__((cleanup(shr_freep))) char *desc = NULL((void*)0);
1497 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_ns_list *changed_ns_list_log = NULL((void*)0);
1498 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1499 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1500 nvme_print_flags_t flags;
1501 int err;
1502
1503 struct config {
1504 bool_Bool raw_binary;
1505 };
1506
1507 struct config cfg = {
1508 .raw_binary = false0,
1509 };
1510
1511 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_output, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1512 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_output))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_output, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1513
1514 if (asprintf(&desc, "Retrieve Changed %s Namespaces log for the given device %s",
1515 alloc ? "Allocated" : "Attached",
1516 "in either decoded format (default) or binary.") < 0)
1517 desc = NULL((void*)0);
1518
1519 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1520 if (err)
1521 return err;
1522
1523 err = validate_output_format(nvme_args.output_format, &flags);
1524 if (err < 0) {
1525 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1526 return err;
1527 }
1528
1529 if (cfg.raw_binary)
1530 flags = BINARY;
1531
1532 changed_ns_list_log = libnvme_alloc(sizeof(*changed_ns_list_log));
1533 if (!changed_ns_list_log)
1534 return -ENOMEM12;
1535
1536 if (alloc)
1537 err = nvme_get_log_changed_alloc_ns_list(hdl,
1538 changed_ns_list_log, sizeof(*changed_ns_list_log));
1539 else
1540 err = nvme_get_log_changed_ns_list(hdl, NVME_NSID_NONE,
1541 changed_ns_list_log);
1542 if (err) {
1543 nvme_show_err(err, alloc ? "changed allocated ns list log" :
1544 "changed attached ns list log");
1545 return err;
1546 }
1547
1548 nvme_show_changed_ns_list_log(changed_ns_list_log,
1549 libnvme_transport_handle_get_name(hdl),
1550 flags, alloc);
1551
1552 return err;
1553}
1554
1555static int get_changed_attach_ns_list_log(int argc, char **argv, struct command *acmd,
1556 struct plugin *plugin)
1557{
1558 return get_changed_ns_list_log(argc, argv, false0);
1559}
1560
1561static int get_changed_alloc_ns_list_log(int argc, char **argv, struct command *acmd,
1562 struct plugin *plugin)
1563{
1564 return get_changed_ns_list_log(argc, argv, true1);
1565}
1566
1567static int get_pred_lat_per_nvmset_log(int argc, char **argv,
1568 struct command *command, struct plugin *plugin)
1569{
1570 const char *desc = "Retrieve Predictable latency per nvm set log "
1571 "page and prints it for the given device in either decoded "
1572 "format(default),json or binary.";
1573 const char *nvmset_id = "NVM Set Identifier";
1574
1575 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_nvmset_predictable_lat_log *plpns_log = NULL((void*)0);
1576 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1577 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1578 nvme_print_flags_t flags;
1579 int err;
1580
1581 struct config {
1582 __u16 nvmset_id;
1583 bool_Bool raw_binary;
1584 };
1585
1586 struct config cfg = {
1587 .nvmset_id = 1,
1588 .raw_binary = false0,
1589 };
1590
1591 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"nvmset-id", 'i', "NUM", CFG_SHORT, &cfg.nvmset_id
, 1, nvmset_id, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1592 OPT_SHRT("nvmset-id", 'i', &cfg.nvmset_id, nvmset_id),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"nvmset-id", 'i', "NUM", CFG_SHORT, &cfg.nvmset_id
, 1, nvmset_id, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1593 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"nvmset-id", 'i', "NUM", CFG_SHORT, &cfg.nvmset_id
, 1, nvmset_id, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1594
1595 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1596 if (err)
1597 return err;
1598
1599 err = validate_output_format(nvme_args.output_format, &flags);
1600 if (err < 0) {
1601 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1602 return err;
1603 }
1604
1605 if (cfg.raw_binary)
1606 flags = BINARY;
1607
1608 plpns_log = libnvme_alloc(sizeof(*plpns_log));
1609 if (!plpns_log)
1610 return -ENOMEM12;
1611
1612 err = nvme_get_log_predictable_lat_nvmset(hdl, cfg.nvmset_id,
1613 plpns_log);
1614 if (err) {
1615 nvme_show_err(err, "predictable latency per nvm set");
1616 return err;
1617 }
1618
1619 nvme_show_predictable_latency_per_nvmset(plpns_log, cfg.nvmset_id,
1620 libnvme_transport_handle_get_name(hdl), flags);
1621
1622 return err;
1623}
1624
1625static int get_pred_lat_event_agg_log(int argc, char **argv,
1626 struct command *command, struct plugin *plugin)
1627{
1628 const char *desc = "Retrieve Predictable Latency Event "
1629 "Aggregate Log page and prints it, for the given "
1630 "device in either decoded format(default), json or binary.";
1631 const char *log_entries = "Number of pending NVM Set log Entries list";
1632
1633 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1634 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1635 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
1636 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *pea_log = NULL((void*)0);
1637 nvme_print_flags_t flags;
1638 __u32 log_size;
1639 int err;
1640
1641 struct config {
1642 __u64 log_entries;
1643 bool_Bool rae;
1644 bool_Bool raw_binary;
1645 };
1646
1647 struct config cfg = {
1648 .log_entries = 2044,
1649 .rae = false0,
1650 .raw_binary = false0,
1651 };
1652
1653 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1654 OPT_UINT("log-entries", 'e', &cfg.log_entries, log_entries),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1655 OPT_FLAG("rae", 'r', &cfg.rae, rae),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1656 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1657
1658 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1659 if (err)
1660 return err;
1661
1662 err = validate_output_format(nvme_args.output_format, &flags);
1663 if (err < 0) {
1664 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1665 return err;
1666 }
1667
1668 if (cfg.raw_binary)
1669 flags = BINARY;
1670
1671 if (!cfg.log_entries) {
1672 nvme_show_error("non-zero log-entries is required param")nvme_show_message(1, "non-zero log-entries is required param"
)
;
1673 return -EINVAL22;
1674 }
1675
1676 ctrl = libnvme_alloc(sizeof(*ctrl));
1677 if (!ctrl)
1678 return -ENOMEM12;
1679
1680 err = nvme_identify_ctrl(hdl, ctrl);
1681 if (err) {
1682 nvme_show_err(err, "identify controller");
1683 return err;
1684 }
1685
1686 cfg.log_entries = min(cfg.log_entries, le32_to_cpu(ctrl->nsetidmax))((cfg.log_entries) > (le32_to_cpu(ctrl->nsetidmax)) ? (
le32_to_cpu(ctrl->nsetidmax)) : (cfg.log_entries))
;
1687 log_size = sizeof(__u64) + cfg.log_entries * sizeof(__u16);
1688
1689 pea_log = libnvme_alloc(log_size);
1690 if (!pea_log)
1691 return -ENOMEM12;
1692
1693 err = nvme_get_log_predictable_lat_event(hdl, cfg.rae, 0, pea_log,
1694 log_size);
1695 if (err) {
1696 nvme_show_err(err,
1697 "predictable latency event aggregate log page");
1698 return err;
1699 }
1700
1701 nvme_show_predictable_latency_event_agg_log(pea_log, cfg.log_entries,
1702 log_size, libnvme_transport_handle_get_name(hdl), flags);
1703
1704 return err;
1705}
1706
1707static int get_persistent_event_log(int argc, char **argv,
1708 struct command *command, struct plugin *plugin)
1709{
1710 const char *desc = "Retrieve Persistent Event log info for "
1711 "the given device in either decoded format(default), json or binary.";
1712 const char *action = "action the controller shall take during "
1713 "processing this persistent log page command.";
1714 const char *log_len = "number of bytes to retrieve";
1715
1716 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_persistent_event_log *pevent = NULL((void*)0);
1717 struct nvme_persistent_event_log *pevent_collected = NULL((void*)0);
1718 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
1719 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1720 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1721 nvme_print_flags_t flags;
1722 void *pevent_log_info;
1723 int err;
1724
1725 struct config {
1726 __u8 action;
1727 __u32 log_len;
1728 bool_Bool raw_binary;
1729 };
1730
1731 struct config cfg = {
1732 .action = 0xff,
1733 .log_len = 0,
1734 .raw_binary = false0,
1735 };
1736
1737 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, }, {"log_len", 'l', "NUM", CFG_POSITIVE, &cfg.log_len
, 1, log_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1738 OPT_BYTE("action", 'a', &cfg.action, action),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, }, {"log_len", 'l', "NUM", CFG_POSITIVE, &cfg.log_len
, 1, log_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1739 OPT_UINT("log_len", 'l', &cfg.log_len, log_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, }, {"log_len", 'l', "NUM", CFG_POSITIVE, &cfg.log_len
, 1, log_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1740 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, }, {"log_len", 'l', "NUM", CFG_POSITIVE, &cfg.log_len
, 1, log_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1741
1742 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1743 if (err)
1744 return err;
1745
1746 err = validate_output_format(nvme_args.output_format, &flags);
1747 if (err < 0) {
1748 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1749 return err;
1750 }
1751
1752 if (cfg.raw_binary)
1753 flags = BINARY;
1754
1755 pevent = libnvme_alloc(sizeof(*pevent));
1756 if (!pevent)
1757 return -ENOMEM12;
1758
1759 err = nvme_get_log_persistent_event(hdl, cfg.action, pevent,
1760 sizeof(*pevent));
1761 if (err) {
1762 nvme_show_err(err, "persistent event log");
1763 return err;
1764 }
1765
1766 if (cfg.action == NVME_PEVENT_LOG_RELEASE_CTX) {
1767 nvme_show_error("Releasing Persistent Event Log Context")nvme_show_message(1, "Releasing Persistent Event Log Context"
)
;
1768 return 0;
1769 }
1770
1771 if (!cfg.log_len && cfg.action != NVME_PEVENT_LOG_EST_CTX_AND_READ) {
1772 cfg.log_len = le64_to_cpu(pevent->tll);
1773 } else if (!cfg.log_len && cfg.action == NVME_PEVENT_LOG_EST_CTX_AND_READ) {
1774 nvme_show_error("Establishing Persistent Event Log Context")nvme_show_message(1, "Establishing Persistent Event Log Context"
)
;
1775 return 0;
1776 }
1777
1778 /*
1779 * if header already read with context establish action 0x1,
1780 * action shall not be 0x1 again in the subsequent request,
1781 * until the current context is released by issuing action
1782 * with 0x2, otherwise throws command sequence error, make
1783 * it as zero to read the log page
1784 */
1785 if (cfg.action == NVME_PEVENT_LOG_EST_CTX_AND_READ)
1786 cfg.action = NVME_PEVENT_LOG_READ;
1787
1788 pevent_log_info = libnvme_alloc_huge(cfg.log_len, &mh);
1789 if (!pevent_log_info) {
1790 nvme_show_error("failed to allocate huge memory")nvme_show_message(1, "failed to allocate huge memory");
1791 return -ENOMEM12;
1792 }
1793
1794 err = nvme_get_log_persistent_event(hdl, cfg.action,
1795 pevent_log_info, cfg.log_len);
1796 if (err) {
1797 nvme_show_err(err, "persistent event log");
1798 return err;
1799 }
1800
1801 err = nvme_get_log_persistent_event(hdl, cfg.action, pevent,
1802 sizeof(*pevent));
1803 if (err) {
1804 nvme_show_err(err, "persistent event log");
1805 return err;
1806 }
1807
1808 pevent_collected = pevent_log_info;
1809 if (pevent_collected->gen_number != pevent->gen_number) {
1810 nvme_show_error("Collected Persistent Event Log may be invalid, Re-read the log is required")nvme_show_message(1, "Collected Persistent Event Log may be invalid, Re-read the log is required"
)
;
1811 return -EINVAL22;
1812 }
1813
1814 nvme_show_persistent_event_log(pevent_log_info, cfg.action,
1815 cfg.log_len, libnvme_transport_handle_get_name(hdl), flags);
1816
1817 return err;
1818}
1819
1820static int get_endurance_event_agg_log(int argc, char **argv,
1821 struct command *command, struct plugin *plugin)
1822{
1823 const char *desc = "Retrieve Retrieve Predictable Latency "
1824 "Event Aggregate page and prints it, for the given "
1825 "device in either decoded format(default), json or binary.";
1826 const char *log_entries = "Number of pending Endurance Group Event log Entries list";
1827
1828 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1829 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1830 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
1831 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *endurance_log = NULL((void*)0);
1832 nvme_print_flags_t flags;
1833 __u32 log_size;
1834 int err;
1835
1836 struct config {
1837 __u64 log_entries;
1838 bool_Bool rae;
1839 bool_Bool raw_binary;
1840 };
1841
1842 struct config cfg = {
1843 .log_entries = 2044,
1844 .rae = false0,
1845 .raw_binary = false0,
1846 };
1847
1848 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1849 OPT_UINT("log-entries", 'e', &cfg.log_entries, log_entries),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1850 OPT_FLAG("rae", 'r', &cfg.rae, rae),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1851 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"log-entries", 'e', "NUM", CFG_POSITIVE, &cfg.log_entries
, 1, log_entries, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1852
1853 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1854 if (err)
1855 return err;
1856
1857 err = validate_output_format(nvme_args.output_format, &flags);
1858 if (err < 0) {
1859 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1860 return err;
1861 }
1862
1863 if (cfg.raw_binary)
1864 flags = BINARY;
1865
1866 if (!cfg.log_entries) {
1867 nvme_show_error("non-zero log-entries is required param")nvme_show_message(1, "non-zero log-entries is required param"
)
;
1868 return -EINVAL22;
1869 }
1870
1871 ctrl = libnvme_alloc(sizeof(*ctrl));
1872 if (!ctrl)
1873 return -ENOMEM12;
1874
1875 err = nvme_identify_ctrl(hdl, ctrl);
1876 if (err < 0) {
1877 nvme_show_error("identify controller: %s", libnvme_strerror(-err))nvme_show_message(1, "identify controller: %s", libnvme_strerror
(-err))
;
1878 return err;
1879 } else if (err) {
1880 nvme_show_error("could not identify controller")nvme_show_message(1, "could not identify controller");
1881 return -ENODEV19;
1882 }
1883
1884 cfg.log_entries = min(cfg.log_entries, le16_to_cpu(ctrl->endgidmax))((cfg.log_entries) > (le16_to_cpu(ctrl->endgidmax)) ? (
le16_to_cpu(ctrl->endgidmax)) : (cfg.log_entries))
;
1885 log_size = sizeof(__u64) + cfg.log_entries * sizeof(__u16);
1886
1887 endurance_log = libnvme_alloc(log_size);
1888 if (!endurance_log)
1889 return -ENOMEM12;
1890
1891 err = nvme_get_log_endurance_grp_evt(hdl, cfg.rae, 0, endurance_log,
1892 log_size);
1893 if (err) {
1894 nvme_show_err(err, "endurance group event aggregate log page");
1895 return err;
1896 }
1897
1898 nvme_show_endurance_group_event_agg_log(endurance_log, cfg.log_entries,
1899 log_size, libnvme_transport_handle_get_name(hdl), flags);
1900
1901 return err;
1902}
1903
1904static int get_lba_status_log(int argc, char **argv,
1905 struct command *command, struct plugin *plugin)
1906{
1907 const char *desc = "Retrieve Get LBA Status Info Log and prints it, "
1908 "for the given device in either decoded format(default),json or binary.";
1909
1910 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1911 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1912 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *lba_status = NULL((void*)0);
1913 nvme_print_flags_t flags;
1914 __u32 lslplen;
1915 int err;
1916
1917 struct config {
1918 bool_Bool rae;
1919 };
1920
1921 struct config cfg = {
1922 .rae = false0,
1923 };
1924
1925 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
1926 OPT_FLAG("rae", 'r', &cfg.rae, rae))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1927
1928 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1929 if (err)
1930 return err;
1931
1932 err = validate_output_format(nvme_args.output_format, &flags);
1933 if (err < 0) {
1934 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1935 return err;
1936 }
1937
1938 err = nvme_get_log_lba_status(hdl, false0, 0, &lslplen, sizeof(__u32));
1939 if (err) {
1940 nvme_show_err(err, "lba status log page");
1941 return err;
1942 }
1943
1944 lba_status = libnvme_alloc(lslplen);
1945 if (!lba_status)
1946 return -ENOMEM12;
1947
1948 err = nvme_get_log_lba_status(hdl, cfg.rae, 0, lba_status, lslplen);
1949 if (err) {
1950 nvme_show_err(err, "lba status log page");
1951 return err;
1952 }
1953
1954 nvme_show_lba_status_log(lba_status, lslplen,
1955 libnvme_transport_handle_get_name(hdl), flags);
1956
1957 return err;
1958}
1959
1960static int get_resv_notif_log(int argc, char **argv,
1961 struct command *command, struct plugin *plugin)
1962{
1963
1964 const char *desc = "Retrieve Reservation Notification "
1965 "log page and prints it, for the given "
1966 "device in either decoded format(default), json or binary.";
1967
1968 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_resv_notification_log *resv = NULL((void*)0);
1969 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
1970 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
1971 nvme_print_flags_t flags;
1972 int err;
1973
1974 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
1975
1976 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1977 if (err)
1978 return err;
1979
1980 err = validate_output_format(nvme_args.output_format, &flags);
1981 if (err < 0) {
1982 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
1983 return err;
1984 }
1985
1986 resv = libnvme_alloc(sizeof(*resv));
1987 if (!resv)
1988 return -ENOMEM12;
1989
1990 err = nvme_get_log_reservation(hdl, resv);
1991 if (err) {
1992 nvme_show_err(err, "resv notifi log");
1993 return err;
1994 }
1995
1996 nvme_show_resv_notif_log(resv, libnvme_transport_handle_get_name(hdl),
1997 flags);
1998
1999 return err;
2000
2001}
2002
2003static int get_boot_part_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
2004{
2005 const char *desc = "Retrieve Boot Partition "
2006 "log page and prints it, for the given "
2007 "device in either decoded format(default), json or binary.";
2008 const char *fname = "boot partition data output file name";
2009
2010 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2011 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2012 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_boot_partition *boot = NULL((void*)0);
2013 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) __u8 *bp_log = NULL((void*)0);
2014 nvme_print_flags_t flags;
2015 int err = -1;
2016 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int output = -1;
2017 __u32 bpsz = 0;
2018
2019 struct config {
2020 __u8 lsp;
2021 char *file_name;
2022 };
2023
2024 struct config cfg = {
2025 .lsp = 0,
2026 .file_name = NULL((void*)0),
2027 };
2028
2029 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lsp", 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0,
}, {"output-file", 'f', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((
void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2030 OPT_BYTE("lsp", 's', &cfg.lsp, lsp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lsp", 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0,
}, {"output-file", 'f', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((
void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2031 OPT_FILE("output-file", 'f', &cfg.file_name, fname))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lsp", 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0,
}, {"output-file", 'f', "FILE", CFG_STRING, &cfg.file_name
, 1, fname, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((
void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2032
2033 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2034 if (err)
2035 return err;
2036
2037 err = validate_output_format(nvme_args.output_format, &flags);
2038 if (err < 0) {
2039 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2040 return err;
2041 }
2042
2043 if (!cfg.file_name) {
2044 nvme_show_error("Please provide an output file!")nvme_show_message(1, "Please provide an output file!");
2045 return -1;
2046 }
2047
2048 if (cfg.lsp > 127) {
2049 nvme_show_error("invalid lsp param: %u", cfg.lsp)nvme_show_message(1, "invalid lsp param: %u", cfg.lsp);
2050 return -1;
2051 }
2052
2053 output = nvme_open_rawdata(cfg.file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)open((cfg.file_name), (01 | 0100 | 01000), 0666);
2054 if (output < 0) {
2055 nvme_show_error("Failed to open output file %s: %s!",nvme_show_message(1, "Failed to open output file %s: %s!", cfg
.file_name, libnvme_strerror((*__errno_location ())))
2056 cfg.file_name, libnvme_strerror(errno))nvme_show_message(1, "Failed to open output file %s: %s!", cfg
.file_name, libnvme_strerror((*__errno_location ())))
;
2057 return output;
2058 }
2059
2060 boot = libnvme_alloc(sizeof(*boot));
2061 if (!boot)
2062 return -ENOMEM12;
2063
2064 err = nvme_get_log_boot_partition(hdl, cfg.lsp, boot, sizeof(*boot));
2065 if (err) {
2066 nvme_show_err(err, "boot partition log");
2067 return err;
2068 }
2069
2070 bpsz = (boot->bpinfo & 0x7fff) * 128 * 1024;
2071 bp_log = libnvme_alloc(sizeof(*boot) + bpsz);
2072 if (!bp_log)
2073 return -ENOMEM12;
2074
2075 err = nvme_get_log_boot_partition(hdl, cfg.lsp,
2076 (struct nvme_boot_partition *)bp_log,
2077 sizeof(*boot) + bpsz);
2078 if (err)
2079 nvme_show_err(err, "boot partition log");
2080 else
2081 nvme_show_boot_part_log(&bp_log,
2082 libnvme_transport_handle_get_name(hdl),
2083 sizeof(*boot) + bpsz, flags);
2084
2085 err = write(output, (void *) bp_log + sizeof(*boot), bpsz);
2086 if (err != bpsz)
2087 nvme_show_error("Failed to flush all data to file!")nvme_show_message(1, "Failed to flush all data to file!");
2088 else
2089 nvme_show_result("Data flushed into file %s", cfg.file_name)nvme_show_message(0, "Data flushed into file %s", cfg.file_name
)
;
2090
2091 return 0;
2092}
2093
2094static int get_phy_rx_eom_log(int argc, char **argv, struct command *acmd,
2095 struct plugin *plugin)
2096{
2097 const char *desc = "Retrieve Physical Interface Receiver Eye Opening "
2098 "Measurement log for the given device in decoded format "
2099 "(default), json or binary.";
2100 const char *controller = "Target Controller ID.";
2101 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_phy_rx_eom_log *phy_rx_eom_log = NULL((void*)0);
2102 size_t phy_rx_eom_log_len;
2103 nvme_print_flags_t flags;
2104 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2105 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2106 int err = -1;
2107 __u8 lsp_tmp;
2108
2109 struct config {
2110 __u8 lsp;
2111 __u16 controller;
2112 };
2113
2114 struct config cfg = {
2115 .lsp = 0,
2116 .controller = NVME_LOG_LSI_NONE,
2117 };
2118
2119 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lsp", 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0,
}, {"controller", 'c', "NUM", CFG_SHORT, &cfg.controller
, 1, controller, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2120 OPT_BYTE("lsp", 's', &cfg.lsp, lsp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lsp", 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0,
}, {"controller", 'c', "NUM", CFG_SHORT, &cfg.controller
, 1, controller, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2121 OPT_SHRT("controller", 'c', &cfg.controller, controller))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lsp", 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0,
}, {"controller", 'c', "NUM", CFG_SHORT, &cfg.controller
, 1, controller, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2122
2123 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2124 if (err)
2125 return err;
2126
2127 err = validate_output_format(nvme_args.output_format, &flags);
2128 if (err < 0) {
2129 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2130 return err;
2131 }
2132
2133 if (cfg.lsp > 127) {
2134 nvme_show_error("invalid lsp param: %u", cfg.lsp)nvme_show_message(1, "invalid lsp param: %u", cfg.lsp);
2135 return -1;
2136 } else if ((cfg.lsp & 3) == 3) {
2137 nvme_show_error("invalid measurement quality: %u", cfg.lsp & 3)nvme_show_message(1, "invalid measurement quality: %u", cfg.lsp
& 3)
;
2138 return -1;
2139 } else if ((cfg.lsp & 12) == 12) {
2140 nvme_show_error("invalid action: %u", cfg.lsp & 12)nvme_show_message(1, "invalid action: %u", cfg.lsp & 12);
2141 return -1;
2142 }
2143
2144 /* Fetching header to calculate total log length */
2145 phy_rx_eom_log_len = sizeof(struct nvme_phy_rx_eom_log);
2146 phy_rx_eom_log = libnvme_alloc(phy_rx_eom_log_len);
2147 if (!phy_rx_eom_log)
2148 return -ENOMEM12;
2149
2150 /* Just read measurement, take given action when fetching full log */
2151 lsp_tmp = cfg.lsp & 0xf3;
2152
2153 err = nvme_get_log_phy_rx_eom(hdl, lsp_tmp, cfg.controller,
2154 phy_rx_eom_log, phy_rx_eom_log_len);
2155 if (err) {
2156 nvme_show_err(err, "phy-rx-eom-log");
2157 return err;
2158 }
2159
2160 if (phy_rx_eom_log->eomip == NVME_PHY_RX_EOM_COMPLETED)
2161 phy_rx_eom_log_len = le16_to_cpu(phy_rx_eom_log->hsize) +
2162 le32_to_cpu(phy_rx_eom_log->dsize) *
2163 le16_to_cpu(phy_rx_eom_log->nd);
2164 else
2165 phy_rx_eom_log_len = le16_to_cpu(phy_rx_eom_log->hsize);
2166
2167 phy_rx_eom_log = libnvme_realloc(phy_rx_eom_log, phy_rx_eom_log_len);
2168 if (!phy_rx_eom_log)
2169 return -ENOMEM12;
2170
2171 err = nvme_get_log_phy_rx_eom(hdl, cfg.lsp, cfg.controller,
2172 phy_rx_eom_log, phy_rx_eom_log_len);
2173 if (err) {
2174 nvme_show_err(err, "phy-rx-eom-log");
2175 return err;
2176 }
2177
2178 nvme_show_phy_rx_eom_log(phy_rx_eom_log, cfg.controller, flags);
2179
2180 return err;
2181}
2182
2183static int get_media_unit_stat_log(int argc, char **argv, struct command *acmd,
2184 struct plugin *plugin)
2185{
2186 const char *desc = "Retrieve the configuration and wear of media units and print it";
2187
2188 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_media_unit_stat_log *mus = NULL((void*)0);
2189 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2190 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2191 nvme_print_flags_t flags;
2192 int err = -1;
2193
2194 struct config {
2195 __u16 domainid;
2196 bool_Bool raw_binary;
2197 };
2198
2199 struct config cfg = {
2200 .domainid = 0,
2201 .raw_binary = false0,
2202 };
2203
2204 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"domain-id", 'd', "NUM", CFG_POSITIVE, &cfg.domainid
, 1, domainid, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2205 OPT_UINT("domain-id", 'd', &cfg.domainid, domainid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"domain-id", 'd', "NUM", CFG_POSITIVE, &cfg.domainid
, 1, domainid, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2206 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"domain-id", 'd', "NUM", CFG_POSITIVE, &cfg.domainid
, 1, domainid, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2207
2208 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2209 if (err)
2210 return err;
2211
2212 err = validate_output_format(nvme_args.output_format, &flags);
2213 if (err < 0) {
2214 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2215 return err;
2216 }
2217
2218 if (cfg.raw_binary)
2219 flags = BINARY;
2220
2221 mus = libnvme_alloc(sizeof(*mus));
2222 if (!mus)
2223 return -ENOMEM12;
2224
2225 err = nvme_get_log_media_unit_stat(hdl, cfg.domainid, mus);
2226 if (err) {
2227 nvme_show_err(err, "media unit status log");
2228 return err;
2229 }
2230
2231 nvme_show_media_unit_stat_log(mus, flags);
2232
2233 return err;
2234}
2235
2236static int get_supp_cap_config_log(int argc, char **argv, struct command *acmd,
2237 struct plugin *plugin)
2238{
2239 const char *desc = "Retrieve the list of Supported Capacity Configuration Descriptors";
2240
2241 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_supported_cap_config_list_log *cap_log = NULL((void*)0);
2242 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2243 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2244 nvme_print_flags_t flags;
2245 int err = -1;
2246
2247 struct config {
2248 __u16 domainid;
2249 bool_Bool raw_binary;
2250 };
2251
2252 struct config cfg = {
2253 .domainid = 0,
2254 .raw_binary = false0,
2255 };
2256
2257 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"domain-id", 'd', "NUM", CFG_POSITIVE, &cfg.domainid
, 1, domainid, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2258 OPT_UINT("domain-id", 'd', &cfg.domainid, domainid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"domain-id", 'd', "NUM", CFG_POSITIVE, &cfg.domainid
, 1, domainid, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2259 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_use))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"domain-id", 'd', "NUM", CFG_POSITIVE, &cfg.domainid
, 1, domainid, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_use, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2260
2261 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2262 if (err)
2263 return err;
2264
2265 err = validate_output_format(nvme_args.output_format, &flags);
2266 if (err < 0) {
2267 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2268 return err;
2269 }
2270
2271 if (cfg.raw_binary)
2272 flags = BINARY;
2273
2274 cap_log = libnvme_alloc(sizeof(*cap_log));
2275 if (!cap_log)
2276 return -ENOMEM12;
2277
2278 err = nvme_get_log_support_cap_config_list(hdl, cfg.domainid, cap_log);
2279 if (err) {
2280 nvme_show_err(err, "supported capacity configuration list log");
2281 return err;
2282 }
2283
2284 nvme_show_supported_cap_config_log(cap_log, flags);
2285
2286 return err;
2287}
2288
2289static int io_mgmt_send(int argc, char **argv, struct command *acmd, struct plugin *plugin)
2290{
2291 const char *desc = "I/O Management Send";
2292 const char *data = "optional file for data (default stdin)";
2293
2294 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2295 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2296 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int dfd = STDIN_FILENO0;
2297 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *buf = NULL((void*)0);
2298 struct libnvme_passthru_cmd cmd;
2299 int err = -1;
2300
2301 struct config {
2302 __u32 nsid;
2303 __u16 mos;
2304 __u8 mo;
2305 char *file;
2306 __u32 data_len;
2307 };
2308
2309 struct config cfg = {
2310 .mos = 0,
2311 };
2312
2313 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2314 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2315 OPT_SHRT("mos", 's', &cfg.mos, mos),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2316 OPT_BYTE("mo", 'm', &cfg.mo, mo),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2317 OPT_FILE("data", 'd', &cfg.file, data),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2318 OPT_UINT("data-len", 'l', &cfg.data_len, buf_len))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2319
2320 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2321 if (err)
2322 return err;
2323
2324 if (!cfg.nsid) {
2325 err = libnvme_get_nsid(hdl, &cfg.nsid);
2326 if (err < 0) {
2327 nvme_show_err(err, "get-namespace-id");
2328 return err;
2329 }
2330 }
2331
2332 if (cfg.data_len) {
2333 buf = libnvme_alloc(cfg.data_len);
2334 if (!buf)
2335 return -ENOMEM12;
2336 }
2337
2338 if (cfg.file) {
2339 dfd = nvme_open_rawdata(cfg.file, O_RDONLY)open((cfg.file), (00));
2340 if (dfd < 0) {
2341 nvme_show_perror(cfg.file);
2342 return -errno(*__errno_location ());
2343 }
2344 }
2345
2346 err = read(dfd, buf, cfg.data_len);
2347 if (err < 0) {
2348 nvme_show_perror("read");
2349 return err;
2350 }
2351
2352 nvme_init_io_mgmt_send(&cmd, cfg.nsid, cfg.mo, cfg.mos, buf, cfg.data_len);
2353 err = libnvme_exec_io_passthru(hdl, &cmd);
2354 if (err) {
2355 nvme_show_err(err, "io-mgmt-send");
2356 return err;
2357 }
2358
2359 nvme_show_verbose_result("io-mgmt-send: Success, mos:%u mo:%u nsid:%d",nvme_show_verbose_message("io-mgmt-send: Success, mos:%u mo:%u nsid:%d"
, cfg.mos, cfg.mo, cfg.nsid)
2360 cfg.mos, cfg.mo, cfg.nsid)nvme_show_verbose_message("io-mgmt-send: Success, mos:%u mo:%u nsid:%d"
, cfg.mos, cfg.mo, cfg.nsid)
;
2361
2362 return err;
2363}
2364
2365static int io_mgmt_recv(int argc, char **argv, struct command *acmd, struct plugin *plugin)
2366{
2367 const char *desc = "I/O Management Receive";
2368 const char *data = "optional file for data (default stdout)";
2369
2370 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2371 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2372 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *buf = NULL((void*)0);
2373 struct libnvme_passthru_cmd cmd;
2374 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int dfd = -1;
2375 int err = -1;
2376
2377 struct config {
2378 __u16 mos;
2379 __u8 mo;
2380 __u32 nsid;
2381 char *file;
2382 __u32 data_len;
2383 };
2384
2385 struct config cfg = {
2386 .mos = 0,
2387 };
2388
2389 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2390 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2391 OPT_SHRT("mos", 's', &cfg.mos, mos),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2392 OPT_BYTE("mo", 'm', &cfg.mo, mo),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2393 OPT_FILE("data", 'd', &cfg.file, data),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2394 OPT_UINT("data-len", 'l', &cfg.data_len, buf_len))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"mos", 's', "NUM", CFG_SHORT
, &cfg.mos, 1, mos, 0, }, {"mo", 'm', "NUM", CFG_BYTE, &
cfg.mo, 1, mo, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &
cfg.data_len, 1, buf_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2395
2396 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2397 if (err)
2398 return err;
2399
2400 if (!cfg.nsid) {
2401 err = libnvme_get_nsid(hdl, &cfg.nsid);
2402 if (err < 0) {
2403 nvme_show_err(err, "get-namespace-id");
2404 return err;
2405 }
2406 }
2407
2408 if (cfg.data_len) {
2409 buf = libnvme_alloc(cfg.data_len);
2410 if (!buf)
2411 return -ENOMEM12;
2412 }
2413
2414 nvme_init_io_mgmt_recv(&cmd, cfg.nsid, cfg.mo, cfg.mos, buf,
2415 cfg.data_len);
2416 err = libnvme_exec_io_passthru(hdl, &cmd);
2417 if (err) {
2418 nvme_show_err(err, "io-mgmt-recv");
2419 return err;
2420 }
2421
2422 nvme_show_verbose_result("io-mgmt-recv: Success, mos:%u mo:%u nsid:%d",nvme_show_verbose_message("io-mgmt-recv: Success, mos:%u mo:%u nsid:%d"
, cfg.mos, cfg.mo, cfg.nsid)
2423 cfg.mos, cfg.mo, cfg.nsid)nvme_show_verbose_message("io-mgmt-recv: Success, mos:%u mo:%u nsid:%d"
, cfg.mos, cfg.mo, cfg.nsid)
;
2424
2425 if (cfg.file) {
2426 dfd = nvme_open_rawdata(cfg.file, O_WRONLY | O_CREAT | O_TRUNC, 0644)open((cfg.file), (01 | 0100 | 01000), 0644);
2427 if (dfd < 0) {
2428 nvme_show_perror(cfg.file);
2429 return -errno(*__errno_location ());
2430 }
2431
2432 err = write(dfd, buf, cfg.data_len);
2433 if (err < 0) {
2434 nvme_show_perror("write");
2435 return -errno(*__errno_location ());
2436 }
2437 } else {
2438 d((unsigned char *)buf, cfg.data_len, 16, 1);
2439 }
2440
2441 return err;
2442}
2443
2444static int get_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
2445{
2446 const char *desc = "Retrieve desired number of bytes "
2447 "from a given log on a specified device in either "
2448 "hex-dump (default) or binary format";
2449 const char *log_id = "identifier of log to retrieve";
2450 const char *log_len = "how many bytes to retrieve";
2451 const char *aen = "result of the aen, use to override log id";
2452 const char *lpo = "log page offset specifies the location within a log page from where to start returning data";
2453 const char *lsi = "log specific identifier specifies an identifier that is required for a particular log page";
2454 const char *raw = "output in raw format";
2455 const char *offset_type = "offset type";
2456 const char *xfer_len = "read chunk size (default 4k)";
2457
2458 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2459 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2460 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) unsigned char *log = NULL((void*)0);
2461 struct libnvme_passthru_cmd cmd;
2462 int err;
2463 nvme_print_flags_t flags;
2464
2465 struct config {
2466 bool_Bool ish;
2467 __u32 namespace_id;
2468 __u8 log_id;
2469 __u32 log_len;
2470 __u32 aen;
2471 __u64 lpo;
2472 __u8 lsp;
2473 __u16 lsi;
2474 bool_Bool rae;
2475 __u8 uuid_index;
2476 bool_Bool raw_binary;
2477 __u8 csi;
2478 bool_Bool ot;
2479 __u32 xfer_len;
2480 };
2481
2482 struct config cfg = {
2483 .ish = false0,
2484 .namespace_id = NVME_NSID_ALL,
2485 .log_id = 0xff,
2486 .log_len = 0,
2487 .aen = 0,
2488 .lpo = NVME_LOG_LPO_NONE,
2489 .lsp = NVME_LOG_LSP_NONE,
2490 .lsi = NVME_LOG_LSI_NONE,
2491 .rae = false0,
2492 .uuid_index = NVME_UUID_NONE,
2493 .raw_binary = false0,
2494 .csi = NVME_CSI_NVM,
2495 .ot = false0,
2496 .xfer_len = NVME_LOG_PAGE_PDU_SIZE4096,
2497 };
2498
2499 OPT_VALS(log_name)struct argconfig_opt_val log_name[] = {
2500 VAL_BYTE("supported-log-pages", NVME_LOG_LID_SUPPORTED_LOG_PAGES){"supported-log-pages", CFG_BYTE, .val.byte = NVME_LOG_LID_SUPPORTED_LOG_PAGES
}
,
2501 VAL_BYTE("error", NVME_LOG_LID_ERROR){"error", CFG_BYTE, .val.byte = NVME_LOG_LID_ERROR},
2502 VAL_BYTE("smart", NVME_LOG_LID_SMART){"smart", CFG_BYTE, .val.byte = NVME_LOG_LID_SMART},
2503 VAL_BYTE("fw-slot", NVME_LOG_LID_FW_SLOT){"fw-slot", CFG_BYTE, .val.byte = NVME_LOG_LID_FW_SLOT},
2504 VAL_BYTE("changed-ns", NVME_LOG_LID_CHANGED_NS){"changed-ns", CFG_BYTE, .val.byte = NVME_LOG_LID_CHANGED_NS},
2505 VAL_BYTE("cmd-effects", NVME_LOG_LID_CMD_EFFECTS){"cmd-effects", CFG_BYTE, .val.byte = NVME_LOG_LID_CMD_EFFECTS
}
,
2506 VAL_BYTE("device-self-test", NVME_LOG_LID_DEVICE_SELF_TEST){"device-self-test", CFG_BYTE, .val.byte = NVME_LOG_LID_DEVICE_SELF_TEST
}
,
2507 VAL_BYTE("telemetry-host", NVME_LOG_LID_TELEMETRY_HOST){"telemetry-host", CFG_BYTE, .val.byte = NVME_LOG_LID_TELEMETRY_HOST
}
,
2508 VAL_BYTE("telemetry-ctrl", NVME_LOG_LID_TELEMETRY_CTRL){"telemetry-ctrl", CFG_BYTE, .val.byte = NVME_LOG_LID_TELEMETRY_CTRL
}
,
2509 VAL_BYTE("endurance-group", NVME_LOG_LID_ENDURANCE_GROUP){"endurance-group", CFG_BYTE, .val.byte = NVME_LOG_LID_ENDURANCE_GROUP
}
,
2510 VAL_BYTE("predictable-lat-nvmset", NVME_LOG_LID_PREDICTABLE_LAT_NVMSET){"predictable-lat-nvmset", CFG_BYTE, .val.byte = NVME_LOG_LID_PREDICTABLE_LAT_NVMSET
}
,
2511 VAL_BYTE("predictable-lat-agg", NVME_LOG_LID_PREDICTABLE_LAT_AGG){"predictable-lat-agg", CFG_BYTE, .val.byte = NVME_LOG_LID_PREDICTABLE_LAT_AGG
}
,
2512 VAL_BYTE("ana", NVME_LOG_LID_ANA){"ana", CFG_BYTE, .val.byte = NVME_LOG_LID_ANA},
2513 VAL_BYTE("persistent-event", NVME_LOG_LID_PERSISTENT_EVENT){"persistent-event", CFG_BYTE, .val.byte = NVME_LOG_LID_PERSISTENT_EVENT
}
,
2514 VAL_BYTE("lba-status", NVME_LOG_LID_LBA_STATUS){"lba-status", CFG_BYTE, .val.byte = NVME_LOG_LID_LBA_STATUS},
2515 VAL_BYTE("endurance-grp-evt", NVME_LOG_LID_ENDURANCE_GRP_EVT){"endurance-grp-evt", CFG_BYTE, .val.byte = NVME_LOG_LID_ENDURANCE_GRP_EVT
}
,
2516 VAL_BYTE("media-unit-status", NVME_LOG_LID_MEDIA_UNIT_STATUS){"media-unit-status", CFG_BYTE, .val.byte = NVME_LOG_LID_MEDIA_UNIT_STATUS
}
,
2517 VAL_BYTE("supported-cap-config-list", NVME_LOG_LID_SUPPORTED_CAP_CONFIG_LIST){"supported-cap-config-list", CFG_BYTE, .val.byte = NVME_LOG_LID_SUPPORTED_CAP_CONFIG_LIST
}
,
2518 VAL_BYTE("fid-supported-effects", NVME_LOG_LID_FID_SUPPORTED_EFFECTS){"fid-supported-effects", CFG_BYTE, .val.byte = NVME_LOG_LID_FID_SUPPORTED_EFFECTS
}
,
2519 VAL_BYTE("mi-cmd-supported-effects", NVME_LOG_LID_MI_CMD_SUPPORTED_EFFECTS){"mi-cmd-supported-effects", CFG_BYTE, .val.byte = NVME_LOG_LID_MI_CMD_SUPPORTED_EFFECTS
}
,
2520 VAL_BYTE("cmd-and-feat-lockdown", NVME_LOG_LID_CMD_AND_FEAT_LOCKDOWN){"cmd-and-feat-lockdown", CFG_BYTE, .val.byte = NVME_LOG_LID_CMD_AND_FEAT_LOCKDOWN
}
,
2521 VAL_BYTE("boot-partition", NVME_LOG_LID_BOOT_PARTITION){"boot-partition", CFG_BYTE, .val.byte = NVME_LOG_LID_BOOT_PARTITION
}
,
2522 VAL_BYTE("rotational-media-info",{"rotational-media-info", CFG_BYTE, .val.byte = NVME_LOG_LID_ROTATIONAL_MEDIA_INFO
}
2523 NVME_LOG_LID_ROTATIONAL_MEDIA_INFO){"rotational-media-info", CFG_BYTE, .val.byte = NVME_LOG_LID_ROTATIONAL_MEDIA_INFO
}
,
2524 VAL_BYTE("dispersed-ns-participating-ns",{"dispersed-ns-participating-ns", CFG_BYTE, .val.byte = NVME_LOG_LID_DISPERSED_NS_PARTICIPATING_NSS
}
2525 NVME_LOG_LID_DISPERSED_NS_PARTICIPATING_NSS){"dispersed-ns-participating-ns", CFG_BYTE, .val.byte = NVME_LOG_LID_DISPERSED_NS_PARTICIPATING_NSS
}
,
2526 VAL_BYTE("mgmt-addr-list", NVME_LOG_LID_MGMT_ADDR_LIST){"mgmt-addr-list", CFG_BYTE, .val.byte = NVME_LOG_LID_MGMT_ADDR_LIST
}
,
2527 VAL_BYTE("phy-rx-eom", NVME_LOG_LID_PHY_RX_EOM){"phy-rx-eom", CFG_BYTE, .val.byte = NVME_LOG_LID_PHY_RX_EOM},
2528 VAL_BYTE("reachability-groups", NVME_LOG_LID_REACHABILITY_GROUPS){"reachability-groups", CFG_BYTE, .val.byte = NVME_LOG_LID_REACHABILITY_GROUPS
}
,
2529 VAL_BYTE("reachability-associations", NVME_LOG_LID_REACHABILITY_ASSOCIATIONS){"reachability-associations", CFG_BYTE, .val.byte = NVME_LOG_LID_REACHABILITY_ASSOCIATIONS
}
,
2530 VAL_BYTE("changed-alloc-ns-list", NVME_LOG_LID_CHANGED_ALLOC_NS){"changed-alloc-ns-list", CFG_BYTE, .val.byte = NVME_LOG_LID_CHANGED_ALLOC_NS
}
,
2531 VAL_BYTE("fdp-configs", NVME_LOG_LID_FDP_CONFIGS){"fdp-configs", CFG_BYTE, .val.byte = NVME_LOG_LID_FDP_CONFIGS
}
,
2532 VAL_BYTE("fdp-ruh-usage", NVME_LOG_LID_FDP_RUH_USAGE){"fdp-ruh-usage", CFG_BYTE, .val.byte = NVME_LOG_LID_FDP_RUH_USAGE
}
,
2533 VAL_BYTE("fdp-stats", NVME_LOG_LID_FDP_STATS){"fdp-stats", CFG_BYTE, .val.byte = NVME_LOG_LID_FDP_STATS},
2534 VAL_BYTE("fdp-events", NVME_LOG_LID_FDP_EVENTS){"fdp-events", CFG_BYTE, .val.byte = NVME_LOG_LID_FDP_EVENTS},
2535 VAL_BYTE("discover", NVME_LOG_LID_DISCOVERY){"discover", CFG_BYTE, .val.byte = NVME_LOG_LID_DISCOVERY},
2536 VAL_BYTE("host-discover", NVME_LOG_LID_HOST_DISCOVERY){"host-discover", CFG_BYTE, .val.byte = NVME_LOG_LID_HOST_DISCOVERY
}
,
2537 VAL_BYTE("ave-discover", NVME_LOG_LID_AVE_DISCOVERY){"ave-discover", CFG_BYTE, .val.byte = NVME_LOG_LID_AVE_DISCOVERY
}
,
2538 VAL_BYTE("pull-model-ddc-req", NVME_LOG_LID_PULL_MODEL_DDC_REQ){"pull-model-ddc-req", CFG_BYTE, .val.byte = NVME_LOG_LID_PULL_MODEL_DDC_REQ
}
,
2539 VAL_BYTE("reservation", NVME_LOG_LID_RESERVATION){"reservation", CFG_BYTE, .val.byte = NVME_LOG_LID_RESERVATION
}
,
2540 VAL_BYTE("sanitize", NVME_LOG_LID_SANITIZE){"sanitize", CFG_BYTE, .val.byte = NVME_LOG_LID_SANITIZE},
2541 VAL_BYTE("zns-changed-zones", NVME_LOG_LID_ZNS_CHANGED_ZONES){"zns-changed-zones", CFG_BYTE, .val.byte = NVME_LOG_LID_ZNS_CHANGED_ZONES
}
,
2542 VAL_END(){ ((void*)0) }
2543 };
2544
2545 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2546 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2547 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2548 OPT_BYTE("log-id", 'i', &cfg.log_id, log_id, log_name),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2549 OPT_UINT("log-len", 'l', &cfg.log_len, log_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2550 OPT_UINT("aen", 'a', &cfg.aen, aen),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2551 OPT_SUFFIX("lpo", 'L', &cfg.lpo, lpo),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2552 OPT_BYTE("lsp", 's', &cfg.lsp, lsp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2553 OPT_SHRT("lsi", 'S', &cfg.lsi, lsi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2554 OPT_FLAG("rae", 'r', &cfg.rae, rae),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2555 OPT_BYTE("uuid-index", 'U', &cfg.uuid_index, uuid_index),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2556 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2557 OPT_BYTE("csi", 'y', &cfg.csi, csi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2558 OPT_FLAG("ot", 'O', &cfg.ot, offset_type),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2559 OPT_UINT("xfer-len", 'x', &cfg.xfer_len, xfer_len))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"log-id", 'i', "NUM", CFG_BYTE
, &cfg.log_id, 1, log_id, 0, log_name}, {"log-len", 'l', "NUM"
, CFG_POSITIVE, &cfg.log_len, 1, log_len, 0, }, {"aen", 'a'
, "NUM", CFG_POSITIVE, &cfg.aen, 1, aen, 0, }, {"lpo", 'L'
, "IONUM", CFG_LONG_SUFFIX, &cfg.lpo, 1, lpo, 0, }, {"lsp"
, 's', "NUM", CFG_BYTE, &cfg.lsp, 1, lsp, 0, }, {"lsi", 'S'
, "NUM", CFG_SHORT, &cfg.lsi, 1, lsi, 0, }, {"rae", 'r', (
(void*)0), CFG_FLAG, &cfg.rae, 0, rae, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0
, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"csi", 'y', "NUM", CFG_BYTE, &cfg.csi, 1
, csi, 0, }, {"ot", 'O', ((void*)0), CFG_FLAG, &cfg.ot, 0
, offset_type, 0, }, {"xfer-len", 'x', "NUM", CFG_POSITIVE, &
cfg.xfer_len, 1, xfer_len, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2560
2561 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2562 if (err)
2563 return err;
2564
2565 err = validate_output_format(nvme_args.output_format, &flags);
2566 if (err < 0) {
2567 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2568 return err;
2569 }
2570
2571 if (cfg.aen) {
2572 cfg.log_len = 4096;
2573 cfg.log_id = (cfg.aen >> 16) & 0xff;
2574 }
2575
2576 if (!cfg.log_len || cfg.log_len & 0x3) {
2577 nvme_show_error("non-zero or non-dw alignment log-len is required param")nvme_show_message(1, "non-zero or non-dw alignment log-len is required param"
)
;
2578 return -EINVAL22;
2579 }
2580
2581 if (cfg.lsp > 127) {
2582 nvme_show_error("invalid lsp param")nvme_show_message(1, "invalid lsp param");
2583 return -EINVAL22;
2584 }
2585
2586 if (cfg.uuid_index > 127) {
2587 nvme_show_error("invalid uuid index param")nvme_show_message(1, "invalid uuid index param");
2588 return -EINVAL22;
2589 }
2590
2591 if (cfg.xfer_len == 0 || cfg.xfer_len % 4096) {
2592 nvme_show_error("xfer-len argument invalid. It needs to be multiple of 4k")nvme_show_message(1, "xfer-len argument invalid. It needs to be multiple of 4k"
)
;
2593 return -EINVAL22;
2594 }
2595
2596 log = libnvme_alloc(cfg.log_len);
2597 if (!log)
2598 return -ENOMEM12;
2599
2600 struct nvme_get_log_args args = {
2601 .nsid = cfg.namespace_id,
2602 .rae = cfg.rae,
2603 .lsp = cfg.lsp,
2604 .lid = cfg.log_id,
2605 .lsi = cfg.lsi,
2606 .csi = cfg.csi,
2607 .ot = cfg.ot,
2608 .uidx = cfg.uuid_index,
2609 .lpo = cfg.lpo,
2610 .log = log,
2611 .len = cfg.log_len,
2612 .result = NULL((void*)0),
2613 };
2614 nvme_init_get_log(&cmd, cfg.namespace_id, cfg.log_id,
2615 cfg.csi, log, cfg.log_len);
2616 if (cfg.ish) {
2617 if (libnvme_transport_handle_is_mi(hdl))
2618 nvme_init_mi_cmd_flags(&cmd, ish);
2619 else
2620 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
2621 }
2622 cmd.cdw10 |= NVME_FIELD_ENCODE(cfg.lsp,(((__u32)(cfg.lsp) & (NVME_LOG_CDW10_LSP_MASK)) << (
NVME_LOG_CDW10_LSP_SHIFT))
2623 NVME_LOG_CDW10_LSP_SHIFT,(((__u32)(cfg.lsp) & (NVME_LOG_CDW10_LSP_MASK)) << (
NVME_LOG_CDW10_LSP_SHIFT))
2624 NVME_LOG_CDW10_LSP_MASK)(((__u32)(cfg.lsp) & (NVME_LOG_CDW10_LSP_MASK)) << (
NVME_LOG_CDW10_LSP_SHIFT))
;
2625 cmd.cdw11 |= NVME_FIELD_ENCODE(cfg.lsi,(((__u32)(cfg.lsi) & (NVME_LOG_CDW11_LSI_MASK)) << (
NVME_LOG_CDW11_LSI_SHIFT))
2626 NVME_LOG_CDW11_LSI_SHIFT,(((__u32)(cfg.lsi) & (NVME_LOG_CDW11_LSI_MASK)) << (
NVME_LOG_CDW11_LSI_SHIFT))
2627 NVME_LOG_CDW11_LSI_MASK)(((__u32)(cfg.lsi) & (NVME_LOG_CDW11_LSI_MASK)) << (
NVME_LOG_CDW11_LSI_SHIFT))
;
2628 cmd.cdw12 = cfg.lpo & 0xffffffff;
2629 cmd.cdw13 = cfg.lpo >> 32;
2630 cmd.cdw14 |= NVME_FIELD_ENCODE(cfg.uuid_index,(((__u32)(cfg.uuid_index) & (NVME_LOG_CDW14_UUID_MASK)) <<
(NVME_LOG_CDW14_UUID_SHIFT))
2631 NVME_LOG_CDW14_UUID_SHIFT,(((__u32)(cfg.uuid_index) & (NVME_LOG_CDW14_UUID_MASK)) <<
(NVME_LOG_CDW14_UUID_SHIFT))
2632 NVME_LOG_CDW14_UUID_MASK)(((__u32)(cfg.uuid_index) & (NVME_LOG_CDW14_UUID_MASK)) <<
(NVME_LOG_CDW14_UUID_SHIFT))
|
2633 NVME_FIELD_ENCODE(cfg.ot,(((__u32)(cfg.ot) & (NVME_LOG_CDW14_OT_MASK)) << (NVME_LOG_CDW14_OT_SHIFT
))
2634 NVME_LOG_CDW14_OT_SHIFT,(((__u32)(cfg.ot) & (NVME_LOG_CDW14_OT_MASK)) << (NVME_LOG_CDW14_OT_SHIFT
))
2635 NVME_LOG_CDW14_OT_MASK)(((__u32)(cfg.ot) & (NVME_LOG_CDW14_OT_MASK)) << (NVME_LOG_CDW14_OT_SHIFT
))
;
2636
2637 err = libnvme_get_log(hdl, &cmd, cfg.rae, cfg.xfer_len);
2638 if (err) {
2639 nvme_show_err(err, "log page");
2640 return err;
2641 }
2642
2643 if (!cfg.raw_binary) {
2644 nvme_show_result("Device:%s log-id:%d namespace-id:%#x",nvme_show_message(0, "Device:%s log-id:%d namespace-id:%#x", libnvme_transport_handle_get_name
(hdl), cfg.log_id, cfg.namespace_id)
2645 libnvme_transport_handle_get_name(hdl), cfg.log_id,nvme_show_message(0, "Device:%s log-id:%d namespace-id:%#x", libnvme_transport_handle_get_name
(hdl), cfg.log_id, cfg.namespace_id)
2646 cfg.namespace_id)nvme_show_message(0, "Device:%s log-id:%d namespace-id:%#x", libnvme_transport_handle_get_name
(hdl), cfg.log_id, cfg.namespace_id)
;
2647 d(log, cfg.log_len, 16, 1);
2648 if (nvme_args.verbose)
2649 nvme_show_log(libnvme_transport_handle_get_name(hdl),
2650 &args, VERBOSE);
2651 } else {
2652 d_raw((unsigned char *)log, cfg.log_len);
2653 }
2654
2655 return err;
2656}
2657
2658static int sanitize_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
2659{
2660 const char *desc = "Retrieve sanitize log and show it.";
2661
2662 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_sanitize_log_page *sanitize_log = NULL((void*)0);
2663 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2664 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2665 nvme_print_flags_t flags;
2666 int err;
2667
2668 struct config {
2669 bool_Bool rae;
2670 bool_Bool raw_binary;
2671 };
2672
2673 struct config cfg = {
2674 .rae = false0,
2675 .raw_binary = false0,
2676 };
2677
2678 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_log, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2679 OPT_FLAG("rae", 'r', &cfg.rae, rae),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_log, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2680 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_log))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_log, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2681
2682 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2683 if (err)
2684 return err;
2685
2686 err = validate_output_format(nvme_args.output_format, &flags);
2687 if (err < 0) {
2688 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2689 return err;
2690 }
2691
2692 if (cfg.raw_binary)
2693 flags = BINARY;
2694
2695 if (nvme_args.verbose)
2696 flags |= VERBOSE;
2697
2698 sanitize_log = libnvme_alloc(sizeof(*sanitize_log));
2699 if (!sanitize_log)
2700 return -ENOMEM12;
2701
2702 err = nvme_get_log_sanitize(hdl, cfg.rae, sanitize_log);
2703 if (err) {
2704 nvme_show_err(err, "sanitize status log");
2705 return err;
2706 }
2707
2708 nvme_show_sanitize_log(sanitize_log,
2709 libnvme_transport_handle_get_name(hdl), flags);
2710
2711 return err;
2712}
2713
2714static int get_fid_support_effects_log(int argc, char **argv, struct command *acmd,
2715 struct plugin *plugin)
2716{
2717 const char *desc = "Retrieve FID Support and Effects log and show it.";
2718
2719 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_fid_supported_effects_log *fid_support_log = NULL((void*)0);
2720 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2721 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2722 nvme_print_flags_t flags;
2723 int err = -1;
2724
2725 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2726
2727 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2728 if (err)
2729 return err;
2730
2731 err = validate_output_format(nvme_args.output_format, &flags);
2732 if (err < 0) {
2733 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2734 return err;
2735 }
2736
2737 if (nvme_args.verbose)
2738 flags |= VERBOSE;
2739
2740 fid_support_log = libnvme_alloc(sizeof(*fid_support_log));
2741 if (!fid_support_log)
2742 return -ENOMEM12;
2743
2744 err = nvme_get_log_fid_supported_effects(hdl, false0, fid_support_log);
2745 if (err) {
2746 nvme_show_err(err, "fid support effects log");
2747 return err;
2748 }
2749
2750 nvme_show_fid_support_effects_log(fid_support_log,
2751 libnvme_transport_handle_get_name(hdl),
2752 flags);
2753
2754 return err;
2755}
2756
2757static int get_mi_cmd_support_effects_log(int argc, char **argv, struct command *acmd,
2758 struct plugin *plugin)
2759{
2760 const char *desc = "Retrieve NVMe-MI Command Support and Effects log and show it.";
2761
2762 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_mi_cmd_supported_effects_log *mi_cmd_support_log = NULL((void*)0);
2763 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2764 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2765 nvme_print_flags_t flags;
2766 int err = -1;
2767
2768 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2769
2770 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2771 if (err)
2772 return err;
2773
2774 err = validate_output_format(nvme_args.output_format, &flags);
2775 if (err < 0) {
2776 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2777 return err;
2778 }
2779
2780 if (nvme_args.verbose)
2781 flags |= VERBOSE;
2782
2783 mi_cmd_support_log = libnvme_alloc(sizeof(*mi_cmd_support_log));
2784 if (!mi_cmd_support_log)
2785 return -ENOMEM12;
2786
2787 err = nvme_get_log_mi_cmd_supported_effects(hdl, mi_cmd_support_log);
2788 if (err) {
2789 nvme_show_err(err, "mi command support effects log");
2790 return err;
2791 }
2792
2793 nvme_show_mi_cmd_support_effects_log(mi_cmd_support_log,
2794 libnvme_transport_handle_get_name(hdl), flags);
2795
2796 return err;
2797}
2798
2799static int list_ctrl(int argc, char **argv, struct command *acmd, struct plugin *plugin)
2800{
2801 const char *desc = "Show controller list information for the subsystem the "
2802 "given device is part of, or optionally controllers attached to a specific namespace.";
2803 const char *controller = "controller to display";
2804
2805 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_ctrl_list *cntlist = NULL((void*)0);
2806 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2807 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2808 struct libnvme_passthru_cmd cmd;
2809 nvme_print_flags_t flags;
2810 int err;
2811
2812 struct config {
2813 __u16 cntid;
2814 __u32 namespace_id;
2815 };
2816
2817 struct config cfg = {
2818 .cntid = 0,
2819 .namespace_id = NVME_NSID_NONE,
2820 };
2821
2822 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, 1, controller
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_optional, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2823 OPT_SHRT("cntid", 'c', &cfg.cntid, controller),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, 1, controller
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_optional, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2824 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_optional))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, 1, controller
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_optional, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2825
2826 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2827 if (err)
2828 return err;
2829
2830 err = validate_output_format(nvme_args.output_format, &flags);
2831 if (err < 0 || (flags != JSON && flags != NORMAL)) {
2832 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2833 return err;
2834 }
2835
2836 cntlist = libnvme_alloc(sizeof(*cntlist));
2837 if (!cntlist)
2838 return -ENOMEM12;
2839
2840 if (cfg.namespace_id == NVME_NSID_NONE)
2841 nvme_init_identify_ctrl_list(&cmd, cfg.cntid, cntlist);
2842 else
2843 nvme_init_identify_ns_ctrl_list(&cmd, cfg.namespace_id,
2844 cfg.cntid, cntlist);
2845
2846 err = libnvme_exec_admin_passthru(hdl, &cmd);
2847 if (err) {
2848 nvme_show_err(err, "id controller list");
2849 return err;
2850 }
2851
2852 nvme_show_list_ctrl(cntlist, flags);
2853
2854 return err;
2855}
2856
2857static int list_ns(int argc, char **argv, struct command *acmd, struct plugin *plugin)
2858{
2859 const char *desc = "For the specified controller handle, show the "
2860 "namespace list in the associated NVMe subsystem, optionally starting with a given nsid.";
2861 const char *namespace_id = "first nsid returned list should start from";
2862 const char *csi = "I/O command set identifier";
2863 const char *all = "show all namespaces in the subsystem, whether attached or inactive";
2864
2865 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_ns_list *ns_list = NULL((void*)0);
2866 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2867 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2868 enum nvme_identify_cns cns;
2869 nvme_print_flags_t flags;
2870 int err;
2871
2872 struct config {
2873 __u32 namespace_id;
2874 int csi;
2875 bool_Bool all;
2876 };
2877
2878 struct config cfg = {
2879 .namespace_id = 1,
2880 .csi = -1,
2881 .all = false0,
2882 };
2883
2884 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"csi", 'y', "NUM", CFG_INT, &cfg
.csi, 1, csi, 0, }, {"all", 'a', ((void*)0), CFG_FLAG, &cfg
.all, 0, all, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2885 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"csi", 'y', "NUM", CFG_INT, &cfg
.csi, 1, csi, 0, }, {"all", 'a', ((void*)0), CFG_FLAG, &cfg
.all, 0, all, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2886 OPT_INT("csi", 'y', &cfg.csi, csi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"csi", 'y', "NUM", CFG_INT, &cfg
.csi, 1, csi, 0, }, {"all", 'a', ((void*)0), CFG_FLAG, &cfg
.all, 0, all, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2887 OPT_FLAG("all", 'a', &cfg.all, all))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"csi", 'y', "NUM", CFG_INT, &cfg
.csi, 1, csi, 0, }, {"all", 'a', ((void*)0), CFG_FLAG, &cfg
.all, 0, all, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, (
(void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2888
2889 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2890 if (err)
2891 return err;
2892
2893 err = validate_output_format(nvme_args.output_format, &flags);
2894 if (err < 0 || (flags != JSON && flags != NORMAL)) {
2895 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2896 return -EINVAL22;
2897 }
2898
2899 if (!cfg.namespace_id) {
2900 nvme_show_error("invalid nsid parameter")nvme_show_message(1, "invalid nsid parameter");
2901 return -EINVAL22;
2902 }
2903
2904 if (nvme_args.verbose)
2905 flags |= VERBOSE;
2906
2907 ns_list = libnvme_alloc(sizeof(*ns_list));
2908 if (!ns_list)
2909 return -ENOMEM12;
2910
2911 if (cfg.csi < 0) {
2912 cns = cfg.all ? NVME_IDENTIFY_CNS_ALLOCATED_NS_LIST :
2913 NVME_IDENTIFY_CNS_NS_ACTIVE_LIST;
2914 cfg.csi = 0;
2915 } else {
2916 cns = cfg.all ? NVME_IDENTIFY_CNS_CSI_ALLOCATED_NS_LIST :
2917 NVME_IDENTIFY_CNS_CSI_NS_ACTIVE_LIST;
2918 }
2919
2920 err = nvme_identify(hdl, cfg.namespace_id - 1, cfg.csi, cns, ns_list,
2921 sizeof(*ns_list));
2922 if (err) {
2923 nvme_show_err(err, "id namespace list");
2924 return err;
2925 }
2926
2927 nvme_show_list_ns(ns_list, flags);
2928
2929 return err;
2930}
2931
2932static int id_ns_lba_format(int argc, char **argv, struct command *acmd, struct plugin *plugin)
2933{
2934 const char *desc = "Send an Identify Namespace command to the given "
2935 "device, returns capability field properties of the specified "
2936 "LBA Format index in various formats.";
2937
2938 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2939 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2940 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
2941 nvme_print_flags_t flags;
2942 int err = -1;
2943
2944 struct config {
2945 __u16 lba_format_index;
2946 __u8 uuid_index;
2947 };
2948
2949 struct config cfg = {
2950 .lba_format_index = 0,
2951 .uuid_index = NVME_UUID_NONE,
2952 };
2953
2954 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lba-format-index", 'i', "NUM", CFG_POSITIVE, &cfg
.lba_format_index, 1, lba_format_index, 0, }, {"uuid-index", 'U'
, "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2955 OPT_UINT("lba-format-index", 'i', &cfg.lba_format_index, lba_format_index),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lba-format-index", 'i', "NUM", CFG_POSITIVE, &cfg
.lba_format_index, 1, lba_format_index, 0, }, {"uuid-index", 'U'
, "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
2956 OPT_BYTE("uuid-index", 'U', &cfg.uuid_index, uuid_index))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lba-format-index", 'i', "NUM", CFG_POSITIVE, &cfg
.lba_format_index, 1, lba_format_index, 0, }, {"uuid-index", 'U'
, "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
2957
2958 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
2959 if (err)
2960 return err;
2961
2962 err = validate_output_format(nvme_args.output_format, &flags);
2963 if (err < 0) {
2964 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
2965 return err;
2966 }
2967
2968 if (nvme_args.verbose)
2969 flags |= VERBOSE;
2970
2971 ns = libnvme_alloc(sizeof(*ns));
2972 if (!ns)
2973 return -ENOMEM12;
2974
2975 err = nvme_identify_csi_ns_user_data_format(hdl, NVME_CSI_NVM,
2976 cfg.lba_format_index,
2977 cfg.uuid_index, ns);
2978 if (err) {
2979 nvme_show_err(err,
2980 "identify namespace for specific LBA format");
2981 return err;
2982 }
2983
2984 nvme_show_id_ns(ns, 0, cfg.lba_format_index, true1, flags);
2985
2986 return err;
2987}
2988
2989static int id_endurance_grp_list(int argc, char **argv, struct command *acmd,
2990 struct plugin *plugin)
2991{
2992 const char *desc = "Show endurance group list information for the given endurance group id";
2993 const char *endurance_grp_id = "Endurance Group ID";
2994
2995 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_endurance_group_list *endgrp_list = NULL((void*)0);
2996 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
2997 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
2998 struct libnvme_passthru_cmd cmd;
2999 nvme_print_flags_t flags;
3000 int err = -1;
3001
3002 struct config {
3003 __u16 endgrp_id;
3004 };
3005
3006 struct config cfg = {
3007 .endgrp_id = 0,
3008 };
3009
3010 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"endgrp-id", 'i', "NUM", CFG_SHORT, &cfg.endgrp_id
, 1, endurance_grp_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3011 OPT_SHRT("endgrp-id", 'i', &cfg.endgrp_id, endurance_grp_id))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"endgrp-id", 'i', "NUM", CFG_SHORT, &cfg.endgrp_id
, 1, endurance_grp_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3012
3013 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3014 if (err)
3015 return err;
3016
3017 err = validate_output_format(nvme_args.output_format, &flags);
3018 if (err < 0 || (flags != JSON && flags != NORMAL)) {
3019 nvme_show_error("invalid output format")nvme_show_message(1, "invalid output format");
3020 return -EINVAL22;
3021 }
3022
3023 endgrp_list = libnvme_alloc(sizeof(*endgrp_list));
3024 if (!endgrp_list)
3025 return -ENOMEM12;
3026
3027 nvme_init_identify_endurance_group_id(&cmd, cfg.endgrp_id,
3028 endgrp_list);
3029 err = libnvme_exec_admin_passthru(hdl, &cmd);
3030 if (err) {
3031 nvme_show_err(err, "Id endurance group list");
3032 return err;
3033 }
3034
3035 nvme_show_endurance_group_list(endgrp_list, flags);
3036
3037 return err;
3038}
3039
3040static bool_Bool is_ns_mgmt_support(struct libnvme_transport_handle *hdl)
3041{
3042 int err;
3043
3044 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = libnvme_alloc(sizeof(*ctrl));
3045
3046 if (!ctrl)
3047 return false0;
3048
3049 err = nvme_identify_ctrl(hdl, ctrl);
3050 if (err)
3051 return false0;
3052
3053 return le16_to_cpu(ctrl->oacs) & NVME_CTRL_OACS_NS_MGMT;
3054}
3055
3056static void ns_mgmt_show_status(struct libnvme_transport_handle *hdl, int err, char *cmd, __u32 nsid)
3057{
3058 if (err < 0) {
3059 nvme_show_error("%s: %s", cmd, libnvme_strerror(-err))nvme_show_message(1, "%s: %s", cmd, libnvme_strerror(-err));
3060 return;
3061 } else if (err > 0) {
3062 nvme_show_status(err);
3063 if (!is_ns_mgmt_support(hdl))
3064 nvme_show_error("NS management and attachment not supported")nvme_show_message(1, "NS management and attachment not supported"
)
;
3065 return;
3066 }
3067
3068 nvme_show_verbose_key_value(cmd, "success");
3069 nvme_show_verbose_key_value("nsid", "%d", nsid);
3070}
3071
3072static int delete_ns(int argc, char **argv, struct command *acmd, struct plugin *plugin)
3073{
3074 const char *desc = "Delete the given namespace by "
3075 "sending a namespace management command to "
3076 "the provided device. All controllers should be detached from "
3077 "the namespace prior to namespace deletion. A namespace ID "
3078 "becomes inactive when that namespace is detached or, if "
3079 "the namespace is not already inactive, once deleted.";
3080 const char *namespace_id = "namespace to delete";
3081
3082 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
3083 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3084 struct libnvme_passthru_cmd cmd;
3085 nvme_print_flags_t flags;
3086 int err;
3087
3088 struct config {
3089 bool_Bool ish;
3090 __u32 namespace_id;
3091 };
3092
3093 struct config cfg = {
3094 .ish = false0,
3095 .namespace_id = 0,
3096 };
3097
3098 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3099 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3100 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3101
3102 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3103 if (err)
3104 return err;
3105
3106 err = validate_output_format(nvme_args.output_format, &flags);
3107 if (err < 0) {
3108 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3109 return err;
3110 }
3111
3112 if (!cfg.namespace_id) {
3113 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
3114 if (err < 0) {
3115 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
3116 return err;
3117 }
3118 }
3119
3120 nvme_init_ns_mgmt_delete(&cmd, cfg.namespace_id);
3121 if (cfg.ish) {
3122 if (libnvme_transport_handle_is_mi(hdl))
3123 nvme_init_mi_cmd_flags(&cmd, ish);
3124 else
3125 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
3126 }
3127 err = libnvme_exec_admin_passthru(hdl, &cmd);
3128 ns_mgmt_show_status(hdl, err, acmd->name, cfg.namespace_id);
3129
3130 return err;
3131}
3132
3133static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, struct command *acmd)
3134{
3135 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
3136 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3137
3138 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_ctrl_list *cntlist = NULL((void*)0);
3139 __u16 list[NVME_ID_CTRL_LIST_MAX];
3140 struct libnvme_passthru_cmd cmd;
3141 nvme_print_flags_t flags;
3142 int err, num;
3143
3144 const char *namespace_id = "namespace to attach";
3145 const char *cont = "optional comma-sep controller id list";
3146
3147 struct config {
3148 bool_Bool ish;
3149 __u32 nsid;
3150 char *cntlist;
3151 };
3152
3153 struct config cfg = {
3154 .ish = false0,
3155 .nsid = 0,
3156 .cntlist = "",
3157 };
3158
3159 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id, 0, }, {"controllers", 'c', "LIST", CFG_STRING
, &cfg.cntlist, 1, cont, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3160 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id, 0, }, {"controllers", 'c', "LIST", CFG_STRING
, &cfg.cntlist, 1, cont, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3161 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id, 0, }, {"controllers", 'c', "LIST", CFG_STRING
, &cfg.cntlist, 1, cont, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3162 OPT_LIST("controllers", 'c', &cfg.cntlist, cont))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id, 0, }, {"controllers", 'c', "LIST", CFG_STRING
, &cfg.cntlist, 1, cont, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3163
3164 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3165 if (err)
3166 return err;
3167
3168 err = validate_output_format(nvme_args.output_format, &flags);
3169 if (err < 0) {
3170 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3171 return err;
3172 }
3173
3174 if (libnvme_transport_handle_is_ns(hdl)) {
3175 nvme_show_error("%s: a namespace device opened (dev: %s, nsid: %d)", acmd->name,nvme_show_message(1, "%s: a namespace device opened (dev: %s, nsid: %d)"
, acmd->name, libnvme_transport_handle_get_name(hdl), cfg.
nsid)
3176 libnvme_transport_handle_get_name(hdl), cfg.nsid)nvme_show_message(1, "%s: a namespace device opened (dev: %s, nsid: %d)"
, acmd->name, libnvme_transport_handle_get_name(hdl), cfg.
nsid)
;
3177 return -EINVAL22;
3178 }
3179
3180 if (!cfg.nsid) {
3181 nvme_show_error("%s: namespace-id parameter required", acmd->name)nvme_show_message(1, "%s: namespace-id parameter required", acmd
->name)
;
3182 return -EINVAL22;
3183 }
3184
3185 num = shr_parse_csv_u16(cfg.cntlist, list, ARRAY_SIZE(list))shr_parse_csv_ushort(cfg.cntlist, (unsigned short *)(list) + (
sizeof(char [1 - 2*!(sizeof(*(list)) == sizeof(unsigned short
))]) - 1), (sizeof(list) / sizeof((list)[0])))
;
3186 if (num == -1) {
3187 nvme_show_error("%s: controller id list is malformed", acmd->name)nvme_show_message(1, "%s: controller id list is malformed", acmd
->name)
;
3188 return -EINVAL22;
3189 }
3190
3191 cntlist = libnvme_alloc(sizeof(*cntlist));
3192 if (!cntlist)
3193 return -ENOMEM12;
3194
3195 if (argconfig_parse_seen(opts, "controllers")) {
3196 nvme_init_ctrl_list(cntlist, num, list);
3197 } else {
3198 struct nvme_id_ctrl ctrl = { 0 };
3199
3200 err = nvme_identify_ctrl(hdl, &ctrl);
3201 if (err) {
3202 nvme_show_error("identify-ctrl %s", libnvme_strerror(-err))nvme_show_message(1, "identify-ctrl %s", libnvme_strerror(-err
))
;
3203 return err;
3204 }
3205 cntlist->num = cpu_to_le16(1);
3206 cntlist->identifier[0] = ctrl.cntlid;
3207 }
3208
3209 if (attach)
3210 nvme_init_ns_attach_ctrls(&cmd, cfg.nsid, cntlist);
3211 else
3212 nvme_init_ns_detach_ctrls(&cmd, cfg.nsid, cntlist);
3213
3214 if (cfg.ish) {
3215 if (libnvme_transport_handle_is_mi(hdl))
3216 nvme_init_mi_cmd_flags(&cmd, ish);
3217 else
3218 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
3219 }
3220 err = libnvme_exec_admin_passthru(hdl, &cmd);
3221 ns_mgmt_show_status(hdl, err, acmd->name, cfg.nsid);
3222
3223 return err;
3224}
3225
3226static int attach_ns(int argc, char **argv, struct command *acmd, struct plugin *plugin)
3227{
3228 const char *desc = "Attach the given namespace to the "
3229 "given controller or comma-sep list of controllers. ID of the "
3230 "given namespace becomes active upon attachment to a "
3231 "controller. A namespace must be attached to a controller "
3232 "before IO commands may be directed to that namespace.";
3233
3234 return nvme_attach_ns(argc, argv, 1, desc, acmd);
3235}
3236
3237static int detach_ns(int argc, char **argv, struct command *acmd, struct plugin *plugin)
3238{
3239 const char *desc = "Detach the given namespace from the "
3240 "given controller; de-activates the given namespace's ID. A "
3241 "namespace must be attached to a controller before IO "
3242 "commands may be directed to that namespace.";
3243
3244 return nvme_attach_ns(argc, argv, 0, desc, acmd);
3245}
3246
3247static int parse_lba_num_si(struct libnvme_transport_handle *hdl, const char *opt,
3248 const char *val, __u8 flbas, __u64 *num, __u64 align)
3249{
3250 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_ns_list *ns_list = NULL((void*)0);
3251 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
3252 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
3253 __u32 nsid = 1;
3254 __u8 lbaf;
3255 unsigned int remainder;
3256 char *endptr;
3257 int err = -EINVAL22;
3258 int lbas;
3259
3260 if (!val)
3261 return 0;
3262
3263 if (*num) {
3264 nvme_show_error(nvme_show_message(1, "Invalid specification of both %s and its SI argument, please specify only one"
, opt)
3265 "Invalid specification of both %s and its SI argument, please specify only one",nvme_show_message(1, "Invalid specification of both %s and its SI argument, please specify only one"
, opt)
3266 opt)nvme_show_message(1, "Invalid specification of both %s and its SI argument, please specify only one"
, opt)
;
3267 return err;
3268 }
3269
3270 ctrl = libnvme_alloc(sizeof(*ctrl));
3271 if (!ctrl)
3272 return -ENOMEM12;
3273
3274 err = nvme_identify_ctrl(hdl, ctrl);
3275 if (err) {
3276 nvme_show_err(err, "identify controller");
3277 return err;
3278 }
3279
3280 ns_list = libnvme_alloc(sizeof(*ns_list));
3281 if (!ns_list)
3282 return -ENOMEM12;
3283
3284 if ((ctrl->oacs & 0x8) >> 3) {
3285 nsid = NVME_NSID_ALL;
3286 } else {
3287 err = nvme_identify_active_ns_list(hdl, nsid - 1, ns_list);
3288 if (err) {
3289 nvme_show_err(err, "identify namespace list");
3290 return err;
3291 }
3292 nsid = le32_to_cpu(ns_list->ns[0]);
3293 }
3294
3295 ns = libnvme_alloc(sizeof(*ns));
3296 if (!ns)
3297 return -ENOMEM12;
3298
3299 err = nvme_identify_ns(hdl, nsid, ns);
3300 if (err) {
3301 nvme_show_err(err, "identify namespace");
3302 return err;
3303 }
3304
3305 nvme_id_ns_flbas_to_lbaf_inuse(flbas, &lbaf);
3306 lbas = (1 << ns->lbaf[lbaf].ds) + le16_to_cpu(ns->lbaf[lbaf].ms);
3307
3308 err = shr_suffix_si_parse(val, &endptr, (uint64_t *)num);
3309 if (err) {
3310 nvme_show_error("Expected long suffixed integer argument for '%s-si' but got '%s'!",nvme_show_message(1, "Expected long suffixed integer argument for '%s-si' but got '%s'!"
, opt, val)
3311 opt, val)nvme_show_message(1, "Expected long suffixed integer argument for '%s-si' but got '%s'!"
, opt, val)
;
3312 return -err;
3313 }
3314
3315 if (endptr[0]) {
3316 remainder = *num % align;
3317 if (remainder)
3318 *num += align - remainder;
3319 }
3320
3321 if (endptr[0] != '\0')
3322 *num /= lbas;
3323
3324 return 0;
3325}
3326
3327static int create_ns(int argc, char **argv, struct command *acmd, struct plugin *plugin)
3328{
3329 const char *desc = "Send a namespace management command "
3330 "to the specified device to create a namespace with the given "
3331 "parameters. The next available namespace ID is used for the "
3332 "create operation. Note that create-ns does not attach the "
3333 "namespace to a controller, the attach-ns command is needed.";
3334 const char *nsze = "size of ns (NSZE)";
3335 const char *ncap = "capacity of ns (NCAP)";
3336 const char *flbas =
3337 "Formatted LBA size (FLBAS), if entering this value ignore \'block-size\' field";
3338 const char *dps = "data protection settings (DPS)";
3339 const char *nmic = "multipath and sharing capabilities (NMIC)";
3340 const char *anagrpid = "ANA Group Identifier (ANAGRPID)";
3341 const char *nvmsetid = "NVM Set Identifier (NVMSETID)";
3342 const char *csi = "command set identifier (CSI)";
3343 const char *lbstm = "logical block storage tag mask (LBSTM)";
3344 const char *nphndls = "Number of Placement Handles (NPHNDLS)";
3345 const char *bs = "target block size, specify only if \'FLBAS\' value not entered";
3346 const char *nsze_si = "size of ns (NSZE) in standard SI units";
3347 const char *ncap_si = "capacity of ns (NCAP) in standard SI units";
3348 const char *azr = "Allocate ZRWA Resources (AZR) for Zoned Namespace Command Set";
3349 const char *rar = "Requested Active Resources (RAR) for Zoned Namespace Command Set";
3350 const char *ror = "Requested Open Resources (ROR) for Zoned Namespace Command Set";
3351 const char *rnumzrwa =
3352 "Requested Number of ZRWA Resources (RNUMZRWA) for Zoned Namespace Command Set";
3353 const char *phndls = "Comma separated list of Placement Handle Associated RUH";
3354
3355 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
3356 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_ns_mgmt_host_sw_specified *data = NULL((void*)0);
3357 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns_granularity_list *gr_list = NULL((void*)0);
3358 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3359 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *id = NULL((void*)0);
3360 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
3361 __u64 align_nsze = 1 << 20; /* Default 1 MiB */
3362 __u64 align_ncap = align_nsze;
3363 struct libnvme_passthru_cmd cmd;
3364 uint16_t phndl[128] = { 0, };
3365 nvme_print_flags_t flags;
3366 uint16_t num_phandle;
3367 int err = 0, i;
3368 __u32 nsid;
3369
3370 struct config {
3371 bool_Bool ish;
3372 __u64 nsze;
3373 __u64 ncap;
3374 __u8 flbas;
3375 __u8 dps;
3376 __u8 nmic;
3377 __u32 anagrpid;
3378 __u16 nvmsetid;
3379 __u16 endgid;
3380 __u64 bs;
3381 __u8 csi;
3382 __u64 lbstm;
3383 __u16 nphndls;
3384 char *nsze_si;
3385 char *ncap_si;
3386 bool_Bool azr;
3387 __u32 rar;
3388 __u32 ror;
3389 __u32 rnumzrwa;
3390 char *phndls;
3391 };
3392
3393 struct config cfg = {
3394 .ish = false0,
3395 .nsze = 0,
3396 .ncap = 0,
3397 .flbas = 0xff,
3398 .dps = 0,
3399 .nmic = 0,
3400 .anagrpid = 0,
3401 .nvmsetid = 0,
3402 .endgid = 0,
3403 .bs = 0x00,
3404 .csi = 0,
3405 .lbstm = 0,
3406 .nphndls = 0,
3407 .nsze_si = NULL((void*)0),
3408 .ncap_si = NULL((void*)0),
3409 .azr = false0,
3410 .rar = 0,
3411 .ror = 0,
3412 .rnumzrwa = 0,
3413 .phndls = "",
3414 };
3415
3416 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3417 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3418 OPT_SUFFIX("nsze", 's', &cfg.nsze, nsze),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3419 OPT_SUFFIX("ncap", 'c', &cfg.ncap, ncap),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3420 OPT_BYTE("flbas", 'f', &cfg.flbas, flbas),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3421 OPT_BYTE("dps", 'd', &cfg.dps, dps),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3422 OPT_BYTE("nmic", 'm', &cfg.nmic, nmic),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3423 OPT_UINT("anagrp-id", 'a', &cfg.anagrpid, anagrpid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3424 OPT_SHRT("nvmset-id", 'i', &cfg.nvmsetid, nvmsetid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3425 OPT_SHRT("endg-id", 'e', &cfg.endgid, endgid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3426 OPT_SUFFIX("block-size", 'b', &cfg.bs, bs),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3427 OPT_BYTE("csi", 'y', &cfg.csi, csi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3428 OPT_SUFFIX("lbstm", 'l', &cfg.lbstm, lbstm),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3429 OPT_SHRT("nphndls", 'n', &cfg.nphndls, nphndls),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3430 OPT_STR("nsze-si", 'S', &cfg.nsze_si, nsze_si),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3431 OPT_STR("ncap-si", 'C', &cfg.ncap_si, ncap_si),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3432 OPT_FLAG("azr", 'z', &cfg.azr, azr),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3433 OPT_UINT("rar", 'r', &cfg.rar, rar),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3434 OPT_UINT("ror", 'O', &cfg.ror, ror),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3435 OPT_UINT("rnumzrwa", 'u', &cfg.rnumzrwa, rnumzrwa),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3436 OPT_LIST("phndls", 'p', &cfg.phndls, phndls))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"nsze", 's', "IONUM", CFG_LONG_SUFFIX, &cfg.nsze
, 1, nsze, 0, }, {"ncap", 'c', "IONUM", CFG_LONG_SUFFIX, &
cfg.ncap, 1, ncap, 0, }, {"flbas", 'f', "NUM", CFG_BYTE, &
cfg.flbas, 1, flbas, 0, }, {"dps", 'd', "NUM", CFG_BYTE, &
cfg.dps, 1, dps, 0, }, {"nmic", 'm', "NUM", CFG_BYTE, &cfg
.nmic, 1, nmic, 0, }, {"anagrp-id", 'a', "NUM", CFG_POSITIVE,
&cfg.anagrpid, 1, anagrpid, 0, }, {"nvmset-id", 'i', "NUM"
, CFG_SHORT, &cfg.nvmsetid, 1, nvmsetid, 0, }, {"endg-id"
, 'e', "NUM", CFG_SHORT, &cfg.endgid, 1, endgid, 0, }, {"block-size"
, 'b', "IONUM", CFG_LONG_SUFFIX, &cfg.bs, 1, bs, 0, }, {"csi"
, 'y', "NUM", CFG_BYTE, &cfg.csi, 1, csi, 0, }, {"lbstm",
'l', "IONUM", CFG_LONG_SUFFIX, &cfg.lbstm, 1, lbstm, 0, }
, {"nphndls", 'n', "NUM", CFG_SHORT, &cfg.nphndls, 1, nphndls
, 0, }, {"nsze-si", 'S', "STRING", CFG_STRING, &cfg.nsze_si
, 1, nsze_si, 0, }, {"ncap-si", 'C', "STRING", CFG_STRING, &
cfg.ncap_si, 1, ncap_si, 0, }, {"azr", 'z', ((void*)0), CFG_FLAG
, &cfg.azr, 0, azr, 0, }, {"rar", 'r', "NUM", CFG_POSITIVE
, &cfg.rar, 1, rar, 0, }, {"ror", 'O', "NUM", CFG_POSITIVE
, &cfg.ror, 1, ror, 0, }, {"rnumzrwa", 'u', "NUM", CFG_POSITIVE
, &cfg.rnumzrwa, 1, rnumzrwa, 0, }, {"phndls", 'p', "LIST"
, CFG_STRING, &cfg.phndls, 1, phndls, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3437
3438 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3439 if (err)
3440 return err;
3441
3442 err = validate_output_format(nvme_args.output_format, &flags);
3443 if (err < 0) {
3444 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3445 return err;
3446 }
3447
3448 if (cfg.flbas != 0xff && cfg.bs != 0x00) {
3449 nvme_show_error(nvme_show_message(1, "Invalid specification of both FLBAS and Block Size, please specify only one"
)
3450 "Invalid specification of both FLBAS and Block Size, please specify only one")nvme_show_message(1, "Invalid specification of both FLBAS and Block Size, please specify only one"
)
;
3451 return -EINVAL22;
3452 }
3453 if (cfg.bs) {
3454 if ((cfg.bs & (~cfg.bs + 1)) != cfg.bs) {
3455 nvme_show_error(nvme_show_message(1, "Invalid value for block size (%""l" "u"
"). Block size must be a power of two", (uint64_t)cfg.bs)
3456 "Invalid value for block size (%"PRIu64"). Block size must be a power of two",nvme_show_message(1, "Invalid value for block size (%""l" "u"
"). Block size must be a power of two", (uint64_t)cfg.bs)
3457 (uint64_t)cfg.bs)nvme_show_message(1, "Invalid value for block size (%""l" "u"
"). Block size must be a power of two", (uint64_t)cfg.bs)
;
3458 return -EINVAL22;
3459 }
3460
3461
3462 ns = libnvme_alloc(sizeof(*ns));
3463 if (!ns)
3464 return -ENOMEM12;
3465
3466 err = nvme_identify_ns(hdl, NVME_NSID_ALL, ns);
3467 if (err) {
3468 if (err > 0)
3469 nvme_show_error("identify failed")nvme_show_message(1, "identify failed");
3470 nvme_show_err(err, "identify-namespace");
3471 return err;
3472 }
3473 for (i = 0; i <= ns->nlbaf; ++i) {
3474 if ((1 << ns->lbaf[i].ds) == cfg.bs && ns->lbaf[i].ms == 0) {
3475 cfg.flbas = i;
3476 break;
3477 }
3478 }
3479
3480 }
3481 if (cfg.flbas == 0xff) {
3482 nvme_show_error("FLBAS corresponding to block size %"PRIu64" not found",nvme_show_message(1, "FLBAS corresponding to block size %""l"
"u"" not found", (uint64_t)cfg.bs)
3483 (uint64_t)cfg.bs)nvme_show_message(1, "FLBAS corresponding to block size %""l"
"u"" not found", (uint64_t)cfg.bs)
;
3484 nvme_show_error("Please correct block size, or specify FLBAS directly")nvme_show_message(1, "Please correct block size, or specify FLBAS directly"
)
;
3485
3486 return -EINVAL22;
3487 }
3488
3489 id = libnvme_alloc(sizeof(*id));
3490 if (!id)
3491 return -ENOMEM12;
3492
3493 err = nvme_identify_ctrl(hdl, id);
3494 if (err) {
3495 if (err > 0)
3496 nvme_show_error("identify controller failed")nvme_show_message(1, "identify controller failed");
3497 nvme_show_err(err, "identify-controller");
3498 return err;
3499 }
3500
3501 if (id->ctratt & NVME_CTRL_CTRATT_NAMESPACE_GRANULARITY) {
3502 gr_list = libnvme_alloc(sizeof(*gr_list));
3503 if (!gr_list)
3504 return -ENOMEM12;
3505
3506 if (!nvme_identify_ns_granularity(hdl, gr_list)) {
3507 struct nvme_id_ns_granularity_desc *desc;
3508 int index = cfg.flbas;
3509
3510 /* FIXME: add a proper bitmask to libnvme */
3511 if (!(le32_to_cpu(gr_list->attributes) & 1)) {
3512 /* Only the first descriptor is valid */
3513 index = 0;
3514 } else if (index > gr_list->num_descriptors) {
3515 /*
3516 * The descriptor will contain only zeroes
3517 * so we don't need to read it.
3518 */
3519 goto parse_lba;
3520 }
3521 desc = &gr_list->entry[index];
3522
3523 if (desc->nszegran) {
3524 print_info("enforce nsze alignment to %"PRIx64do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("enforce nsze alignment to %"
"l" "x" " because of namespace granularity requirements\n", le64_to_cpu
(desc->nszegran)); } while (0)
3525 " because of namespace granularity requirements\n",do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("enforce nsze alignment to %"
"l" "x" " because of namespace granularity requirements\n", le64_to_cpu
(desc->nszegran)); } while (0)
3526 le64_to_cpu(desc->nszegran))do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("enforce nsze alignment to %"
"l" "x" " because of namespace granularity requirements\n", le64_to_cpu
(desc->nszegran)); } while (0)
;
3527 align_nsze = le64_to_cpu(desc->nszegran);
3528 }
3529 if (desc->ncapgran) {
3530 print_info("enforce ncap alignment to %"PRIx64do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("enforce ncap alignment to %"
"l" "x" " because of namespace granularity requirements\n", le64_to_cpu
(desc->ncapgran)); } while (0)
3531 " because of namespace granularity requirements\n",do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("enforce ncap alignment to %"
"l" "x" " because of namespace granularity requirements\n", le64_to_cpu
(desc->ncapgran)); } while (0)
3532 le64_to_cpu(desc->ncapgran))do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("enforce ncap alignment to %"
"l" "x" " because of namespace granularity requirements\n", le64_to_cpu
(desc->ncapgran)); } while (0)
;
3533 align_ncap = le64_to_cpu(desc->ncapgran);
3534 }
3535 }
3536 }
3537
3538parse_lba:
3539 err = parse_lba_num_si(hdl, "nsze", cfg.nsze_si, cfg.flbas, &cfg.nsze, align_nsze);
3540 if (err)
3541 return err;
3542
3543 err = parse_lba_num_si(hdl, "ncap", cfg.ncap_si, cfg.flbas, &cfg.ncap, align_ncap);
3544 if (err)
3545 return err;
3546
3547 if (cfg.csi != NVME_CSI_ZNS && (cfg.azr || cfg.rar || cfg.ror || cfg.rnumzrwa)) {
3548 nvme_show_error("Invalid ZNS argument is given (CSI:%#x)", cfg.csi)nvme_show_message(1, "Invalid ZNS argument is given (CSI:%#x)"
, cfg.csi)
;
3549 return -EINVAL22;
3550 }
3551
3552 data = libnvme_alloc(sizeof(*data));
3553 if (!data)
3554 return -ENOMEM12;
3555
3556 data->nsze = cpu_to_le64(cfg.nsze);
3557 data->ncap = cpu_to_le64(cfg.ncap);
3558 data->flbas = cfg.flbas;
3559 data->dps = cfg.dps;
3560 data->nmic = cfg.nmic;
3561 data->anagrpid = cpu_to_le32(cfg.anagrpid);
3562 data->nvmsetid = cpu_to_le16(cfg.nvmsetid);
3563 data->endgid = cpu_to_le16(cfg.endgid);
3564 data->lbstm = cpu_to_le64(cfg.lbstm);
3565 data->zns.znsco = cfg.azr;
3566 data->zns.rar = cpu_to_le32(cfg.rar);
3567 data->zns.ror = cpu_to_le32(cfg.ror);
3568 data->zns.rnumzrwa = cpu_to_le32(cfg.rnumzrwa);
3569 data->nphndls = cpu_to_le16(cfg.nphndls);
3570
3571 num_phandle = shr_parse_csv_ushort(cfg.phndls, phndl, ARRAY_SIZE(phndl)(sizeof(phndl) / sizeof((phndl)[0])));
3572 if (cfg.nphndls != num_phandle) {
3573 nvme_show_error("Invalid Placement handle list")nvme_show_message(1, "Invalid Placement handle list");
3574 return -EINVAL22;
3575 }
3576
3577 for (i = 0; i < num_phandle; i++)
3578 data->phndl[i] = cpu_to_le16(phndl[i]);
3579
3580 nvme_init_ns_mgmt_create(&cmd, cfg.csi, data);
3581 if (cfg.ish) {
3582 if (libnvme_transport_handle_is_mi(hdl))
3583 nvme_init_mi_cmd_flags(&cmd, ish);
3584 else
3585 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
3586 }
3587 err = libnvme_exec_admin_passthru(hdl, &cmd);
3588 nsid = cmd.result;
3589 ns_mgmt_show_status(hdl, err, acmd->name, nsid);
3590
3591 return err;
3592}
3593
3594static bool_Bool nvme_match_devname(char *devname, libnvme_ns_t ns)
3595{
3596 libnvme_ctrl_t c = libnvme_ns_get_ctrl(ns);
3597
3598 if (!strcmp(devname, libnvme_ns_get_name(ns)) ||
3599 (c && !strcmp(devname, libnvme_ctrl_get_name(c))) ||
3600 !strcmp(devname, libnvme_ns_get_generic_name(ns)))
3601 return true1;
3602
3603 return false0;
3604}
3605
3606static bool_Bool nvme_match_device_filter(libnvme_subsystem_t s,
3607 libnvme_ctrl_t c, libnvme_ns_t ns, void *f_args)
3608{
3609 char *devname = f_args;
3610 libnvme_ns_t n;
3611
3612 if (ns && nvme_match_devname(devname, ns))
3613 return true1;
3614
3615 if (c) {
3616 s = libnvme_ctrl_get_subsystem(c);
3617 libnvme_ctrl_for_each_ns(c, n)for (n = libnvme_ctrl_first_ns(c); n != ((void*)0); n = libnvme_ctrl_next_ns
(c, n))
{
3618 if (nvme_match_devname(devname, n))
3619 return true1;
3620 }
3621 }
3622 if (s) {
3623 libnvme_subsystem_for_each_ns(s, n)for (n = libnvme_subsystem_first_ns(s); n != ((void*)0); n = libnvme_subsystem_next_ns
(s, n))
{
3624 if (!strcmp(devname, libnvme_ns_get_name(n)))
3625 return true1;
3626 }
3627 }
3628
3629 return false0;
3630}
3631
3632static int handle_scan_topology_error(int err)
3633{
3634 /* Do not report an error when nvme_core module is not loaded */
3635 if (err == -ENOENT2) {
3636 if (log_level >= LIBNVME_LOG_INFO)
3637 nvme_show_error("nvme modules not loaded")nvme_show_message(1, "nvme modules not loaded");
3638 return 0;
3639 }
3640
3641 nvme_show_error("Failed to scan topology: %s", libnvme_strerror(-err))nvme_show_message(1, "Failed to scan topology: %s", libnvme_strerror
(-err))
;
3642 return err;
3643}
3644
3645static int list_subsys(int argc, char **argv, struct command *acmd,
3646 struct plugin *plugin)
3647{
3648 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3649 nvme_print_flags_t flags;
3650 const char *desc = "Retrieve information for subsystems";
3651 libnvme_scan_filter_t filter = NULL((void*)0);
3652 char *devname;
3653 int err;
3654 int nsid = NVME_NSID_ALL;
3655
3656 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3657
3658 err = parse_args(argc, argv, desc, opts);
3659 if (err)
3660 return err;
3661
3662 devname = NULL((void*)0);
3663 if (optind < argc)
3664 devname = basename__xpg_basename(argv[optind++]);
3665
3666 err = validate_output_format(nvme_args.output_format, &flags);
3667 if (err < 0 || (flags != JSON && flags != NORMAL)) {
3668 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3669 return -EINVAL22;
3670 }
3671
3672 if (nvme_args.verbose)
3673 flags |= VERBOSE;
3674
3675 err = nvme_create_global_ctx(&ctx);
3676 if (err) {
3677 if (devname)
3678 nvme_show_error("Failed to scan nvme subsystem for %s", devname)nvme_show_message(1, "Failed to scan nvme subsystem for %s", devname
)
;
3679 else
3680 nvme_show_error("Failed to scan nvme subsystem")nvme_show_message(1, "Failed to scan nvme subsystem");
3681 return err;
3682 }
3683
3684 if (devname) {
3685 int subsys_num;
3686
3687 if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) < 1 &&
3688 sscanf(devname, "ng%dn%d", &subsys_num, &nsid) != 2) {
3689 nvme_show_error("Invalid device name %s", devname)nvme_show_message(1, "Invalid device name %s", devname);
3690 return -EINVAL22;
3691 }
3692 filter = nvme_match_device_filter;
3693 }
3694
3695 err = libnvme_scan_topology(ctx, filter, (void *)devname);
3696 if (err)
3697 return handle_scan_topology_error(err);
3698
3699 nvme_show_subsystem_list(ctx, nsid != NVME_NSID_ALL, flags);
3700
3701 return 0;
3702}
3703
3704#ifdef CONFIG_TOP
3705static int top(int argc, char **argv, struct command *acmd,
3706 struct plugin *plugin)
3707{
3708 int err;
3709 nvme_print_flags_t flags = 0;
3710 const char *desc = "show nvme top output";
3711 const char *delay = "refresh interval in seconds";
3712
3713 struct config {
3714 int delay;
3715 };
3716
3717 struct config cfg = {
3718 .delay = 1,
3719 };
3720
3721 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"delay", 'd', "NUM", CFG_INT, &cfg.delay, 1, delay
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3722 OPT_INT("delay", 'd', &cfg.delay, delay))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"delay", 'd', "NUM", CFG_INT, &cfg.delay, 1, delay
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3723
3724 err = parse_args(argc, argv, desc, opts);
3725 if (err)
3726 return err;
3727
3728 err = validate_output_format(nvme_args.output_format, &flags);
3729 if (err < 0 || flags != NORMAL) {
3730 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3731 return -EINVAL22;
3732 }
3733
3734 if (cfg.delay < 1) {
3735 nvme_show_error("delay must be greater than or equal to 1")nvme_show_message(1, "delay must be greater than or equal to 1"
)
;
3736 return -EINVAL22;
3737 }
3738
3739 err = shr_install_sigwinch_handler();
3740 if (err) {
3741 nvme_show_error("failed to install sig handler for SIGWINCH")nvme_show_message(1, "failed to install sig handler for SIGWINCH"
)
;
3742 return err;
3743 }
3744
3745 nvme_show_top(flags, cfg.delay);
3746
3747 return err;
3748}
3749#endif
3750
3751static int list(int argc, char **argv, struct command *acmd, struct plugin *plugin)
3752{
3753 const char *desc = "Retrieve basic information for all NVMe namespaces";
3754 nvme_print_flags_t flags;
3755 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3756 int err = 0;
3757
3758 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3759
3760 err = parse_args(argc, argv, desc, opts);
3761 if (err)
3762 return err;
3763
3764 err = validate_output_format(nvme_args.output_format, &flags);
3765 if (err < 0 || (flags != JSON && flags != NORMAL)) {
3766 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3767 return -EINVAL22;
3768 }
3769
3770 if (nvme_args.verbose)
3771 flags |= VERBOSE;
3772
3773 err = nvme_create_global_ctx(&ctx);
3774 if (err)
3775 return err;
3776
3777 err = libnvme_scan_topology(ctx, NULL((void*)0), NULL((void*)0));
3778 if (err < 0)
3779 return handle_scan_topology_error(err);
3780
3781 nvme_show_list_items(ctx, flags);
3782
3783 return err;
3784}
3785
3786int __id_ctrl(int argc, char **argv, struct command *acmd, struct plugin *plugin,
3787 void (*vs)(__u8 *vs, struct json_object *root))
3788{
3789 const char *desc = "Send an Identify Controller command to "
3790 "the given device and report information about the specified "
3791 "controller in human-readable or "
3792 "binary format. May also return vendor-specific "
3793 "controller attributes in hex-dump if requested.";
3794 const char *vendor_specific = "dump binary vendor field";
3795
3796 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
3797 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3798 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
3799 nvme_print_flags_t flags;
3800 int err;
3801
3802 struct config {
3803 bool_Bool vendor_specific;
3804 bool_Bool raw_binary;
3805 };
3806
3807 struct config cfg = {
3808 .vendor_specific = false0,
3809 .raw_binary = false0,
3810 };
3811
3812 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"vendor-specific", 'V', ((void*)0), CFG_FLAG, &cfg
.vendor_specific, 0, vendor_specific, 0, }, {"raw-binary", 'b'
, ((void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_identify,
0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3813 OPT_FLAG("vendor-specific", 'V', &cfg.vendor_specific, vendor_specific),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"vendor-specific", 'V', ((void*)0), CFG_FLAG, &cfg
.vendor_specific, 0, vendor_specific, 0, }, {"raw-binary", 'b'
, ((void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_identify,
0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3814 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_identify))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"vendor-specific", 'V', ((void*)0), CFG_FLAG, &cfg
.vendor_specific, 0, vendor_specific, 0, }, {"raw-binary", 'b'
, ((void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_identify,
0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3815
3816 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3817 if (err)
3818 return err;
3819
3820 err = validate_output_format(nvme_args.output_format, &flags);
3821 if (err < 0) {
3822 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3823 return err;
3824 }
3825
3826 if (cfg.raw_binary)
3827 flags = BINARY;
3828
3829 if (cfg.vendor_specific)
3830 flags |= VS;
3831
3832 if (nvme_args.verbose)
3833 flags |= VERBOSE;
3834
3835 ctrl = libnvme_alloc(sizeof(*ctrl));
3836 if (!ctrl)
3837 return -ENOMEM12;
3838
3839 err = nvme_identify_ctrl(hdl, ctrl);
3840 if (err) {
3841 nvme_show_err(err, "identify controller");
3842 return err;
3843 }
3844
3845 nvme_show_id_ctrl(ctx, hdl, ctrl, flags, vs);
3846
3847 return err;
3848}
3849
3850static int id_ctrl(int argc, char **argv, struct command *acmd, struct plugin *plugin)
3851{
3852 return __id_ctrl(argc, argv, acmd, plugin, NULL((void*)0));
3853}
3854
3855static int nvm_id_ctrl(int argc, char **argv, struct command *acmd,
3856 struct plugin *plugin)
3857{
3858 const char *desc = "Send an Identify Controller NVM Command Set "
3859 "command to the given device and report information about "
3860 "the specified controller in various formats.";
3861
3862 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl_nvm *ctrl_nvm = NULL((void*)0);
3863 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3864 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
3865 struct libnvme_passthru_cmd cmd;
3866 nvme_print_flags_t flags;
3867 int err = -1;
3868
3869 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3870
3871 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3872 if (err)
3873 return err;
3874
3875 err = validate_output_format(nvme_args.output_format, &flags);
3876 if (err < 0) {
3877 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3878 return err;
3879 }
3880
3881 if (nvme_args.verbose)
3882 flags |= VERBOSE;
3883
3884 ctrl_nvm = libnvme_alloc(sizeof(*ctrl_nvm));
3885 if (!ctrl_nvm)
3886 return -ENOMEM12;
3887
3888 nvme_init_identify_csi_ctrl(&cmd, NVME_CSI_NVM, ctrl_nvm);
3889 err = libnvme_exec_admin_passthru(hdl, &cmd);
3890 if (err) {
3891 nvme_show_err(err, "nvm identify controller");
3892 return err;
3893 }
3894
3895 nvme_show_id_ctrl_nvm(ctrl_nvm, flags);
3896
3897 return err;
3898}
3899
3900static int nvm_id_ns(int argc, char **argv, struct command *acmd,
3901 struct plugin *plugin)
3902{
3903 const char *desc = "Send an Identify Namespace NVM Command Set "
3904 "command to the given device and report information about "
3905 "the specified namespace in various formats.";
3906
3907 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_nvm_id_ns *id_ns = NULL((void*)0);
3908 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
3909 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3910 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
3911 nvme_print_flags_t flags;
3912 int err = -1;
3913
3914 struct config {
3915 __u32 namespace_id;
3916 __u8 uuid_index;
3917 };
3918
3919 struct config cfg = {
3920 .namespace_id = 0,
3921 .uuid_index = NVME_UUID_NONE,
3922 };
3923
3924 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3925 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3926 OPT_BYTE("uuid-index", 'U', &cfg.uuid_index, uuid_index))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
3927
3928 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
3929 if (err)
3930 return err;
3931
3932 err = validate_output_format(nvme_args.output_format, &flags);
3933 if (err < 0) {
3934 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
3935 return err;
3936 }
3937
3938 if (nvme_args.verbose)
3939 flags |= VERBOSE;
3940
3941 if (!cfg.namespace_id) {
3942 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
3943 if (err < 0) {
3944 nvme_show_err(err, "get-namespace-id");
3945 return err;
3946 }
3947 }
3948
3949 ns = libnvme_alloc(sizeof(*ns));
3950 if (!ns)
3951 return -ENOMEM12;
3952
3953 err = nvme_identify_ns(hdl, cfg.namespace_id, ns);
3954 if (err) {
3955 nvme_show_err(err, "nvm identify namespace");
3956 return err;
3957 }
3958
3959 id_ns = libnvme_alloc(sizeof(*id_ns));
3960 if (!id_ns)
3961 return -ENOMEM12;
3962
3963 err = nvme_identify_csi_ns(hdl, cfg.namespace_id, NVME_CSI_NVM,
3964 cfg.uuid_index, id_ns);
3965 if (err) {
3966 nvme_show_err(err, "nvm identify csi namespace");
3967 return err;
3968 }
3969
3970 nvme_show_nvm_id_ns(id_ns, cfg.namespace_id, ns, 0, false0, flags);
3971
3972 return err;
3973}
3974
3975static int nvm_id_ns_lba_format(int argc, char **argv, struct command *acmd, struct plugin *plugin)
3976{
3977 const char *desc = "Send an NVM Command Set specific Identify Namespace "
3978 "command to the given device, returns capability field properties of "
3979 "the specified LBA Format index in the specified namespace in various formats.";
3980
3981 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_nvm_id_ns *nvm_ns = NULL((void*)0);
3982 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
3983 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
3984 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
3985 nvme_print_flags_t flags;
3986 int err = -1;
3987
3988 struct config {
3989 __u16 lba_format_index;
3990 __u8 uuid_index;
3991 };
3992
3993 struct config cfg = {
3994 .lba_format_index = 0,
3995 .uuid_index = NVME_UUID_NONE,
3996 };
3997
3998 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lba-format-index", 'i', "NUM", CFG_POSITIVE, &cfg
.lba_format_index, 1, lba_format_index, 0, }, {"uuid-index", 'U'
, "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
3999 OPT_UINT("lba-format-index", 'i', &cfg.lba_format_index, lba_format_index),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lba-format-index", 'i', "NUM", CFG_POSITIVE, &cfg
.lba_format_index, 1, lba_format_index, 0, }, {"uuid-index", 'U'
, "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4000 OPT_BYTE("uuid-index", 'U', &cfg.uuid_index, uuid_index))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"lba-format-index", 'i', "NUM", CFG_POSITIVE, &cfg
.lba_format_index, 1, lba_format_index, 0, }, {"uuid-index", 'U'
, "NUM", CFG_BYTE, &cfg.uuid_index, 1, uuid_index, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4001
4002 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4003 if (err)
4004 return err;
4005
4006 err = validate_output_format(nvme_args.output_format, &flags);
4007 if (err < 0) {
4008 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4009 return err;
4010 }
4011
4012 if (nvme_args.verbose)
4013 flags |= VERBOSE;
4014
4015 ns = libnvme_alloc(sizeof(*ns));
4016 if (!ns)
4017 return -ENOMEM12;
4018
4019 err = nvme_identify_ns(hdl, NVME_NSID_ALL, ns);
4020 if (err) {
4021 ns->nlbaf = NVME_FEAT_LBA_RANGE_MAX - 1;
4022 ns->nulbaf = 0;
4023 }
4024
4025 nvm_ns = libnvme_alloc(sizeof(*nvm_ns));
4026 if (!nvm_ns)
4027 return -ENOMEM12;
4028
4029 err = nvme_identify_csi_ns_user_data_format(hdl, NVME_CSI_NVM,
4030 cfg.lba_format_index,
4031 cfg.uuid_index, nvm_ns);
4032 if (err) {
4033 nvme_show_err(err,
4034 "NVM identify namespace for specific LBA format");
4035 return err;
4036 }
4037
4038 nvme_show_nvm_id_ns(nvm_ns, 0, ns, cfg.lba_format_index, true1, flags);
4039
4040 return err;
4041}
4042
4043static int ns_descs(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4044{
4045 const char *desc = "Send Namespace Identification Descriptors command to the "
4046 "given device, returns the namespace identification descriptors "
4047 "of the specific namespace in either human-readable or binary format.";
4048 const char *raw = "show descriptors in binary format";
4049
4050 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4051 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4052 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *nsdescs = NULL((void*)0);
4053 nvme_print_flags_t flags;
4054 int err;
4055
4056 struct config {
4057 __u32 namespace_id;
4058 bool_Bool raw_binary;
4059 };
4060
4061 struct config cfg = {
4062 .namespace_id = 0,
4063 .raw_binary = false0,
4064 };
4065
4066 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"raw-binary", 'b', ((void*)
0), CFG_FLAG, &cfg.raw_binary, 0, raw, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4067 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"raw-binary", 'b', ((void*)
0), CFG_FLAG, &cfg.raw_binary, 0, raw, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4068 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"raw-binary", 'b', ((void*)
0), CFG_FLAG, &cfg.raw_binary, 0, raw, 0, }, {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0
, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4069
4070 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4071 if (err)
4072 return err;
4073
4074 err = validate_output_format(nvme_args.output_format, &flags);
4075 if (err < 0) {
4076 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4077 return err;
4078 }
4079
4080 if (cfg.raw_binary)
4081 flags = BINARY;
4082
4083 if (nvme_args.verbose)
4084 flags |= VERBOSE;
4085
4086 if (!cfg.namespace_id) {
4087 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
4088 if (err < 0) {
4089 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
4090 return err;
4091 }
4092 }
4093
4094 nsdescs = libnvme_alloc(NVME_IDENTIFY_DATA_SIZE);
4095 if (!nsdescs)
4096 return -ENOMEM12;
4097
4098 err = nvme_identify_ns_descs_list(hdl, cfg.namespace_id, nsdescs);
4099 if (err) {
4100 nvme_show_err(err, "identify namespace");
4101 return err;
4102 }
4103
4104 nvme_show_id_ns_descs(nsdescs, cfg.namespace_id, flags);
4105
4106 return err;
4107}
4108
4109static int id_ns(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4110{
4111 const char *desc = "Send an Identify Namespace command to the "
4112 "given device, returns properties of the specified namespace "
4113 "in either human-readable or binary format. Can also return "
4114 "binary vendor-specific namespace attributes.";
4115 const char *force = "Return this namespace, even if not attached (1.2 devices only)";
4116 const char *vendor_specific = "dump binary vendor fields";
4117
4118 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4119 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4120 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
4121 struct libnvme_passthru_cmd cmd;
4122 nvme_print_flags_t flags;
4123 int err;
4124
4125 struct config {
4126 __u32 namespace_id;
4127 bool_Bool force;
4128 bool_Bool vendor_specific;
4129 bool_Bool raw_binary;
4130 };
4131
4132 struct config cfg = {
4133 .namespace_id = 0,
4134 .force = false0,
4135 .vendor_specific = false0,
4136 .raw_binary = false0,
4137 };
4138
4139 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"force", 0, ((void*)0), CFG_FLAG
, &cfg.force, 0, force, 0, }, {"vendor-specific", 'V', ((
void*)0), CFG_FLAG, &cfg.vendor_specific, 0, vendor_specific
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_identify, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4140 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"force", 0, ((void*)0), CFG_FLAG
, &cfg.force, 0, force, 0, }, {"vendor-specific", 'V', ((
void*)0), CFG_FLAG, &cfg.vendor_specific, 0, vendor_specific
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_identify, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4141 OPT_FLAG("force", 0, &cfg.force, force),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"force", 0, ((void*)0), CFG_FLAG
, &cfg.force, 0, force, 0, }, {"vendor-specific", 'V', ((
void*)0), CFG_FLAG, &cfg.vendor_specific, 0, vendor_specific
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_identify, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4142 OPT_FLAG("vendor-specific", 'V', &cfg.vendor_specific, vendor_specific),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"force", 0, ((void*)0), CFG_FLAG
, &cfg.force, 0, force, 0, }, {"vendor-specific", 'V', ((
void*)0), CFG_FLAG, &cfg.vendor_specific, 0, vendor_specific
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_identify, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4143 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_identify))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"force", 0, ((void*)0), CFG_FLAG
, &cfg.force, 0, force, 0, }, {"vendor-specific", 'V', ((
void*)0), CFG_FLAG, &cfg.vendor_specific, 0, vendor_specific
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_identify, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4144
4145 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4146 if (err)
4147 return err;
4148
4149 err = validate_output_format(nvme_args.output_format, &flags);
4150 if (err < 0) {
4151 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4152 return err;
4153 }
4154
4155 if (cfg.raw_binary)
4156 flags = BINARY;
4157
4158 if (cfg.vendor_specific)
4159 flags |= VS;
4160
4161 if (nvme_args.verbose)
4162 flags |= VERBOSE;
4163
4164 if (!cfg.namespace_id) {
4165 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
4166 if (err < 0) {
4167 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
4168 return err;
4169 }
4170 }
4171
4172 ns = libnvme_alloc(sizeof(*ns));
4173 if (!ns)
4174 return -ENOMEM12;
4175
4176 if (cfg.force) {
4177 nvme_init_identify_allocated_ns(&cmd, cfg.namespace_id, ns);
4178 err = libnvme_exec_admin_passthru(hdl, &cmd);
4179 } else {
4180 err = nvme_identify_ns(hdl, cfg.namespace_id, ns);
4181 }
4182
4183 if (err) {
4184 nvme_show_err(err, "identify namespace");
4185 return err;
4186 }
4187
4188 nvme_show_id_ns(ns, cfg.namespace_id, 0, false0, flags);
4189
4190 return err;
4191}
4192
4193static int cmd_set_independent_id_ns(int argc, char **argv, struct command *acmd,
4194 struct plugin *plugin)
4195{
4196 const char *desc = "Send an I/O Command Set Independent Identify "
4197 "Namespace command to the given device, returns properties of the "
4198 "specified namespace in human-readable or binary or json format.";
4199
4200 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_independent_id_ns *ns = NULL((void*)0);
4201 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4202 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4203 struct libnvme_passthru_cmd cmd;
4204 nvme_print_flags_t flags;
4205 int err = -1;
4206
4207 struct config {
4208 __u32 namespace_id;
4209 bool_Bool raw_binary;
4210 };
4211
4212 struct config cfg = {
4213 .namespace_id = 0,
4214 .raw_binary = false0,
4215 };
4216
4217 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"raw-binary", 'b', ((void*)
0), CFG_FLAG, &cfg.raw_binary, 0, raw_identify, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4218 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"raw-binary", 'b', ((void*)
0), CFG_FLAG, &cfg.raw_binary, 0, raw_identify, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4219 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_identify))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"raw-binary", 'b', ((void*)
0), CFG_FLAG, &cfg.raw_binary, 0, raw_identify, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4220
4221 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4222 if (err)
4223 return err;
4224
4225 err = validate_output_format(nvme_args.output_format, &flags);
4226 if (err < 0) {
4227 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4228 return err;
4229 }
4230
4231 if (cfg.raw_binary)
4232 flags = BINARY;
4233
4234 if (nvme_args.verbose)
4235 flags |= VERBOSE;
4236
4237 if (!cfg.namespace_id) {
4238 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
4239 if (err < 0) {
4240 nvme_show_err(err, "get-namespace-id");
4241 return err;
4242 }
4243 }
4244
4245 ns = libnvme_alloc(sizeof(*ns));
4246 if (!ns)
4247 return -ENOMEM12;
4248
4249 nvme_init_identify_csi_independent_identify_id_ns(&cmd,
4250 cfg.namespace_id, ns);
4251 err = libnvme_exec_admin_passthru(hdl, &cmd);
4252 if (err) {
4253 nvme_show_err(err,
4254 "I/O command set independent identify namespace");
4255 return err;
4256 }
4257
4258 nvme_show_cmd_set_independent_id_ns(ns, cfg.namespace_id, flags);
4259
4260 return err;
4261}
4262
4263static int id_ns_granularity(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4264{
4265 const char *desc = "Send an Identify Namespace Granularity List command to the "
4266 "given device, returns namespace granularity list "
4267 "in either human-readable or binary format.";
4268
4269 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns_granularity_list *granularity_list = NULL((void*)0);
4270 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4271 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4272 nvme_print_flags_t flags;
4273 int err;
4274
4275 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4276
4277 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4278 if (err)
4279 return err;
4280
4281 err = validate_output_format(nvme_args.output_format, &flags);
4282 if (err < 0) {
4283 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4284 return err;
4285 }
4286
4287 granularity_list = libnvme_alloc(NVME_IDENTIFY_DATA_SIZE);
4288 if (!granularity_list)
4289 return -ENOMEM12;
4290
4291 err = nvme_identify_ns_granularity(hdl, granularity_list);
4292 if (err) {
4293 nvme_show_err(err, "identify namespace granularity");
4294 return err;
4295 }
4296
4297 nvme_show_id_ns_granularity_list(granularity_list, flags);
4298
4299 return err;
4300}
4301
4302static int id_nvmset(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4303{
4304 const char *desc = "Send an Identify NVM Set List command to the "
4305 "given device, returns entries for NVM Set identifiers greater "
4306 "than or equal to the value specified CDW11.NVMSETID "
4307 "in either binary format or json format";
4308 const char *nvmset_id = "NVM Set Identify value";
4309
4310 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_nvmset_list *nvmset = NULL((void*)0);
4311 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4312 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4313 struct libnvme_passthru_cmd cmd;
4314 nvme_print_flags_t flags;
4315 int err;
4316
4317 struct config {
4318 __u16 nvmset_id;
4319 };
4320
4321 struct config cfg = {
4322 .nvmset_id = 0,
4323 };
4324
4325 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"nvmset_id", 'i', "NUM", CFG_SHORT, &cfg.nvmset_id
, 1, nvmset_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4326 OPT_SHRT("nvmset_id", 'i', &cfg.nvmset_id, nvmset_id))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"nvmset_id", 'i', "NUM", CFG_SHORT, &cfg.nvmset_id
, 1, nvmset_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4327
4328 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4329 if (err)
4330 return err;
4331
4332 err = validate_output_format(nvme_args.output_format, &flags);
4333 if (err < 0) {
4334 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4335 return err;
4336 }
4337
4338 nvmset = libnvme_alloc(sizeof(*nvmset));
4339 if (!nvmset)
4340 return -ENOMEM12;
4341
4342 nvme_init_identify_nvmset_list(&cmd, NVME_NSID_NONE,
4343 cfg.nvmset_id, nvmset);
4344 err = libnvme_exec_admin_passthru(hdl, &cmd);
4345 if (err) {
4346 nvme_show_err(err, "identify nvm set list");
4347 return err;
4348 }
4349
4350 nvme_show_id_nvmset(nvmset, cfg.nvmset_id, flags);
4351
4352 return err;
4353}
4354
4355static int id_uuid(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4356{
4357 const char *desc = "Send an Identify UUID List command to the "
4358 "given device, returns list of supported Vendor Specific UUIDs "
4359 "in either human-readable or binary format.";
4360 const char *raw = "show uuid in binary format";
4361
4362 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_uuid_list *uuid_list = NULL((void*)0);
4363 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4364 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4365 nvme_print_flags_t flags;
4366 int err;
4367
4368 struct config {
4369 bool_Bool raw_binary;
4370 };
4371
4372 struct config cfg = {
4373 .raw_binary = false0,
4374 };
4375
4376 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4377 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4378
4379 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4380 if (err)
4381 return err;
4382
4383 err = validate_output_format(nvme_args.output_format, &flags);
4384 if (err < 0) {
4385 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4386 return err;
4387 }
4388
4389 if (cfg.raw_binary)
4390 flags = BINARY;
4391
4392 if (nvme_args.verbose)
4393 flags |= VERBOSE;
4394
4395 uuid_list = libnvme_alloc(sizeof(*uuid_list));
4396 if (!uuid_list)
4397 return -ENOMEM12;
4398
4399 err = nvme_identify_uuid_list(hdl, uuid_list);
4400 if (err) {
4401 nvme_show_err(err, "identify UUID list");
4402 return err;
4403 }
4404
4405 nvme_show_id_uuid_list(uuid_list, flags);
4406
4407 return err;
4408}
4409
4410static int id_iocs(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4411{
4412 const char *desc = "Send an Identify Command Set Data command to "
4413 "the given device, returns properties of the specified controller "
4414 "in either human-readable or binary format.";
4415 const char *controller_id = "identifier of desired controller";
4416
4417 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_iocs *iocs = NULL((void*)0);
4418 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4419 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4420 struct libnvme_passthru_cmd cmd;
4421 nvme_print_flags_t flags;
4422 int err;
4423
4424 struct config {
4425 __u16 cntid;
4426 };
4427
4428 struct config cfg = {
4429 .cntid = 0xffff,
4430 };
4431
4432 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"controller-id", 'c', "NUM", CFG_SHORT, &cfg.cntid
, 1, controller_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4433 OPT_SHRT("controller-id", 'c', &cfg.cntid, controller_id))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"controller-id", 'c', "NUM", CFG_SHORT, &cfg.cntid
, 1, controller_id, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4434
4435 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4436 if (err)
4437 return err;
4438
4439 err = validate_output_format(nvme_args.output_format, &flags);
4440 if (err < 0) {
4441 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4442 return err;
4443 }
4444
4445 if (nvme_args.verbose)
4446 flags |= VERBOSE;
4447
4448 iocs = libnvme_alloc(sizeof(*iocs));
4449 if (!iocs)
4450 return -ENOMEM12;
4451
4452 nvme_init_identify_command_set_structure(&cmd, cfg.cntid, iocs);
4453 err = libnvme_exec_admin_passthru(hdl, &cmd);
4454 if (err) {
4455 nvme_show_err(err, "NVMe Identify I/O Command Set");
4456 return err;
4457 }
4458
4459 nvme_show_result("NVMe Identify I/O Command Set:")nvme_show_message(0, "NVMe Identify I/O Command Set:");
4460 nvme_show_id_iocs(iocs, flags);
4461
4462 return err;
4463}
4464
4465static int id_domain(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4466{
4467 const char *desc = "Send an Identify Domain List command to the "
4468 "given device, returns properties of the specified domain "
4469 "in either normal|json|binary format.";
4470 const char *domain_id = "identifier of desired domain";
4471
4472 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_domain_list *id_domain = NULL((void*)0);
4473 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4474 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4475 struct libnvme_passthru_cmd cmd;
4476 nvme_print_flags_t flags;
4477 int err;
4478
4479 struct config {
4480 __u16 dom_id;
4481 };
4482
4483 struct config cfg = {
4484 .dom_id = 0xffff,
4485 };
4486
4487 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"dom-id", 'd', "NUM", CFG_SHORT, &cfg.dom_id, 1, domain_id
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4488 OPT_SHRT("dom-id", 'd', &cfg.dom_id, domain_id))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"dom-id", 'd', "NUM", CFG_SHORT, &cfg.dom_id, 1, domain_id
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4489
4490 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4491 if (err)
4492 return err;
4493
4494 err = validate_output_format(nvme_args.output_format, &flags);
4495 if (err < 0) {
4496 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4497 return err;
4498 }
4499
4500 id_domain = libnvme_alloc(sizeof(*id_domain));
4501 if (!id_domain)
4502 return -ENOMEM12;
4503
4504 nvme_init_identify_domain_list(&cmd, cfg.dom_id, id_domain);
4505 err = libnvme_exec_admin_passthru(hdl, &cmd);
4506 if (err) {
4507 nvme_show_err(err, "NVMe Identify Domain List");
4508 return err;
4509 }
4510
4511 nvme_show_verbose_result("NVMe Identify command for Domain List is successful:")nvme_show_verbose_message("NVMe Identify command for Domain List is successful:"
)
;
4512 nvme_show_verbose_result("NVMe Identify Domain List:")nvme_show_verbose_message("NVMe Identify Domain List:");
4513 nvme_show_id_domain_list(id_domain, flags);
4514
4515 return err;
4516}
4517
4518static int get_ns_id(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4519{
4520 const char *desc = "Get namespace ID of a the block device.";
4521
4522 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4523 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4524 unsigned int nsid;
4525 int err;
4526 nvme_print_flags_t flags;
4527
4528 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4529
4530 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4531 if (err)
4532 return err;
4533
4534 err = validate_output_format(nvme_args.output_format, &flags);
4535 if (err < 0) {
4536 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4537 return err;
4538 }
4539
4540 err = libnvme_get_nsid(hdl, &nsid);
4541 if (err < 0) {
4542 nvme_show_error("get namespace ID: %s", libnvme_strerror(-err))nvme_show_message(1, "get namespace ID: %s", libnvme_strerror
(-err))
;
4543 return -errno(*__errno_location ());
4544 }
4545
4546 nvme_show_result("%s: namespace-id:%d", libnvme_transport_handle_get_name(hdl), nsid)nvme_show_message(0, "%s: namespace-id:%d", libnvme_transport_handle_get_name
(hdl), nsid)
;
4547
4548 return 0;
4549}
4550
4551static int virtual_mgmt(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4552{
4553 const char *desc = "The Virtualization Management command is supported by primary controllers "
4554 "that support the Virtualization Enhancements capability. This command is used for:\n"
4555 " 1. Modifying Flexible Resource allocation for the primary controller\n"
4556 " 2. Assigning Flexible Resources for secondary controllers\n"
4557 " 3. Setting the Online and Offline state for secondary controllers";
4558 const char *cntlid = "Controller Identifier(CNTLID)";
4559 const char *rt = "Resource Type(RT): [0,1]\n"
4560 "0h: VQ Resources\n"
4561 "1h: VI Resources";
4562 const char *act = "Action(ACT): [1,7,8,9]\n"
4563 "1h: Primary Flexible\n"
4564 "7h: Secondary Offline\n"
4565 "8h: Secondary Assign\n"
4566 "9h: Secondary Online";
4567 const char *nr = "Number of Controller Resources(NR)";
4568
4569 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4570 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4571 struct libnvme_passthru_cmd cmd;
4572 int err;
4573
4574 struct config {
4575 __u16 cntlid;
4576 __u8 rt;
4577 __u8 act;
4578 __u16 nr;
4579 };
4580
4581 struct config cfg = {
4582 .cntlid = 0,
4583 .rt = 0,
4584 .act = 0,
4585 .nr = 0,
4586 };
4587
4588 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"rt", 'r', "NUM", CFG_BYTE, &cfg.rt, 1, rt, 0, }
, {"act", 'a', "NUM", CFG_BYTE, &cfg.act, 1, act, 0, }, {
"nr", 'n', "NUM", CFG_SHORT, &cfg.nr, 1, nr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4589 OPT_SHRT("cntlid", 'c', &cfg.cntlid, cntlid),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"rt", 'r', "NUM", CFG_BYTE, &cfg.rt, 1, rt, 0, }
, {"act", 'a', "NUM", CFG_BYTE, &cfg.act, 1, act, 0, }, {
"nr", 'n', "NUM", CFG_SHORT, &cfg.nr, 1, nr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4590 OPT_BYTE("rt", 'r', &cfg.rt, rt),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"rt", 'r', "NUM", CFG_BYTE, &cfg.rt, 1, rt, 0, }
, {"act", 'a', "NUM", CFG_BYTE, &cfg.act, 1, act, 0, }, {
"nr", 'n', "NUM", CFG_SHORT, &cfg.nr, 1, nr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4591 OPT_BYTE("act", 'a', &cfg.act, act),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"rt", 'r', "NUM", CFG_BYTE, &cfg.rt, 1, rt, 0, }
, {"act", 'a', "NUM", CFG_BYTE, &cfg.act, 1, act, 0, }, {
"nr", 'n', "NUM", CFG_SHORT, &cfg.nr, 1, nr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4592 OPT_SHRT("nr", 'n', &cfg.nr, nr))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntlid", 'c', "NUM", CFG_SHORT, &cfg.cntlid, 1, cntlid
, 0, }, {"rt", 'r', "NUM", CFG_BYTE, &cfg.rt, 1, rt, 0, }
, {"act", 'a', "NUM", CFG_BYTE, &cfg.act, 1, act, 0, }, {
"nr", 'n', "NUM", CFG_SHORT, &cfg.nr, 1, nr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4593
4594 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4595 if (err)
4596 return err;
4597
4598 nvme_init_virtual_mgmt(&cmd, cfg.act, cfg.rt, cfg.cntlid, cfg.nr);
4599 err = libnvme_exec_admin_passthru(hdl, &cmd);
4600 if (err) {
4601 nvme_show_err(err, "virt-mgmt");
4602 return err;
4603 }
4604
4605 nvme_show_verbose_result(nvme_show_verbose_message("success, Number of Controller Resources Modified (NRM):%"
"l" "u", (uint64_t)cmd.result)
4606 "success, Number of Controller Resources Modified (NRM):%" PRIu64,nvme_show_verbose_message("success, Number of Controller Resources Modified (NRM):%"
"l" "u", (uint64_t)cmd.result)
4607 (uint64_t)cmd.result)nvme_show_verbose_message("success, Number of Controller Resources Modified (NRM):%"
"l" "u", (uint64_t)cmd.result)
;
4608
4609 return err;
4610}
4611
4612static int primary_ctrl_caps(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4613{
4614 const char *cntlid = "Controller ID";
4615 const char *desc = "Send an Identify Primary Controller Capabilities "
4616 "command to the given device and report the information in a "
4617 "decoded format (default), json or binary.";
4618
4619 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_primary_ctrl_cap *caps = NULL((void*)0);
4620 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4621 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4622 struct libnvme_passthru_cmd cmd;
4623 nvme_print_flags_t flags;
4624 int err;
4625
4626 struct config {
4627 __u16 cntlid;
4628 };
4629
4630 struct config cfg = {
4631 .cntlid = 0,
4632 };
4633
4634 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntlid", 'c', "NUM", CFG_POSITIVE, &cfg.cntlid, 1
, cntlid, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4635 OPT_UINT("cntlid", 'c', &cfg.cntlid, cntlid))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntlid", 'c', "NUM", CFG_POSITIVE, &cfg.cntlid, 1
, cntlid, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4636
4637 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4638 if (err)
4639 return err;
4640
4641 err = validate_output_format(nvme_args.output_format, &flags);
4642 if (err < 0) {
4643 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4644 return err;
4645 }
4646
4647 if (nvme_args.verbose)
4648 flags |= VERBOSE;
4649
4650 caps = libnvme_alloc(sizeof(*caps));
4651 if (!caps)
4652 return -ENOMEM12;
4653
4654 nvme_init_identify_primary_ctrl_cap(&cmd, cfg.cntlid, caps);
4655 err = libnvme_exec_admin_passthru(hdl, &cmd);
4656 if (err) {
4657 nvme_show_err(err, "identify primary controller capabilities");
4658 return err;
4659 }
4660
4661 nvme_show_primary_ctrl_cap(caps, flags);
4662
4663 return err;
4664}
4665
4666static int list_secondary_ctrl(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4667{
4668 const char *desc =
4669 "Show secondary controller list associated with the primary controller of the given device.";
4670 const char *controller = "lowest controller identifier to display";
4671 const char *num_entries = "number of entries to retrieve";
4672
4673 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_secondary_ctrl_list *sc_list = NULL((void*)0);
4674 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4675 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4676 struct libnvme_passthru_cmd cmd;
4677 nvme_print_flags_t flags;
4678 int err;
4679
4680 struct config {
4681 __u16 cntid;
4682 __u32 num_entries;
4683 };
4684
4685 struct config cfg = {
4686 .cntid = 0,
4687 .num_entries = ARRAY_SIZE(sc_list->sc_entry)(sizeof(sc_list->sc_entry) / sizeof((sc_list->sc_entry)
[0]))
,
4688 };
4689
4690 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, 1, controller
, 0, }, {"num-entries", 'e', "NUM", CFG_POSITIVE, &cfg.num_entries
, 1, num_entries, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4691 OPT_SHRT("cntid", 'c', &cfg.cntid, controller),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, 1, controller
, 0, }, {"num-entries", 'e', "NUM", CFG_POSITIVE, &cfg.num_entries
, 1, num_entries, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4692 OPT_UINT("num-entries", 'e', &cfg.num_entries, num_entries))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"cntid", 'c', "NUM", CFG_SHORT, &cfg.cntid, 1, controller
, 0, }, {"num-entries", 'e', "NUM", CFG_POSITIVE, &cfg.num_entries
, 1, num_entries, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4693
4694 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4695 if (err)
4696 return err;
4697
4698 err = validate_output_format(nvme_args.output_format, &flags);
4699 if (err < 0) {
4700 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4701 return err;
4702 }
4703
4704 if (!cfg.num_entries) {
4705 nvme_show_error("non-zero num-entries is required param")nvme_show_message(1, "non-zero num-entries is required param"
)
;
4706 return -EINVAL22;
4707 }
4708
4709 sc_list = libnvme_alloc(sizeof(*sc_list));
4710 if (!sc_list)
4711 return -ENOMEM12;
4712
4713 nvme_init_identify_secondary_ctrl_list(&cmd, cfg.cntid, sc_list);
4714 err = libnvme_exec_admin_passthru(hdl, &cmd);
4715 if (err) {
4716 nvme_show_err(err, "id secondary controller list");
4717 return err;
4718 }
4719
4720 nvme_show_list_secondary_ctrl(sc_list, cfg.num_entries, flags);
4721
4722 return err;
4723}
4724
4725static int nvme_sleep(unsigned int seconds)
4726{
4727 shr_sigint_received = false0;
4728
4729 sleep(seconds);
4730
4731 if (shr_sigint_received) {
4732 nvme_show_error("Interrupted device self-test operation by SIGINT")nvme_show_message(1, "Interrupted device self-test operation by SIGINT"
)
;
4733 return -SIGINT2;
4734 }
4735
4736 return 0;
4737}
4738
4739static int wait_self_test(struct libnvme_transport_handle *hdl)
4740{
4741 static const char spin[] = {'-', '\\', '|', '/' };
4742 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_self_test_log *log = NULL((void*)0);
4743 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
4744 int err, i = 0, p = 0, cnt = 0;
4745 int wthr;
4746
4747 ctrl = libnvme_alloc(sizeof(*ctrl));
4748 if (!ctrl)
4749 return -ENOMEM12;
4750
4751 log = libnvme_alloc(sizeof(*log));
4752 if (!log)
4753 return -ENOMEM12;
4754
4755 err = nvme_identify_ctrl(hdl, ctrl);
4756 if (err) {
4757 nvme_show_err(err, "identify-ctrl");
4758 return err;
4759 }
4760
4761 wthr = le16_to_cpu(ctrl->edstt) * 60 / 100 + 60;
4762
4763 nvme_show_result("Waiting for self test completion...")nvme_show_message(0, "Waiting for self test completion...");
4764 while (true1) {
4765 if (nvme_is_output_format_normal()) {
4766 print_info("\r[%.*s%c%.*s] %3d%%", p / 2, dash, spin[i % 4], 49 - p / 2, space, p)do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\r[%.*s%c%.*s] %3d%%"
, p / 2, dash, spin[i % 4], 49 - p / 2, space, p); } while (0
)
;
4767 fflush(stdoutstdout);
4768 }
4769 err = nvme_sleep(1);
4770 if (err)
4771 return err;
4772
4773 err = nvme_get_log_device_self_test(hdl, log);
4774 if (err) {
4775 if (nvme_is_output_format_normal())
4776 print_info("\n")do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\n"
); } while (0)
;
4777 nvme_show_err(err, "self test log\n");
4778 return err;
4779 }
4780
4781 if (++cnt > wthr) {
4782 nvme_show_error("no progress for %d seconds, stop waiting", wthr)nvme_show_message(1, "no progress for %d seconds, stop waiting"
, wthr)
;
4783 return -EIO5;
4784 }
4785
4786 if (log->completion == 0 && p > 0) {
4787 if (nvme_is_output_format_normal())
4788 print_info("\r[%.*s] %3d%%\n", 50, dash, 100)do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\r[%.*s] %3d%%\n"
, 50, dash, 100); } while (0)
;
4789 break;
4790 }
4791
4792 if (log->completion < p) {
4793 if (nvme_is_output_format_normal())
4794 print_info("\n")do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\n"
); } while (0)
;
4795 nvme_show_error("progress broken")nvme_show_message(1, "progress broken");
4796 return -EIO5;
4797 } else if (log->completion != p) {
4798 p = log->completion;
4799 cnt = 0;
4800 }
4801
4802 i++;
4803 }
4804
4805 return 0;
4806}
4807
4808static void abort_self_test(struct libnvme_transport_handle *hdl, bool_Bool ish,
4809 __u32 nsid)
4810{
4811 struct libnvme_passthru_cmd cmd;
4812 int err;
4813
4814 nvme_init_dev_self_test(&cmd, nsid, NVME_DST_STC_ABORT);
4815 if (ish) {
4816 if (libnvme_transport_handle_is_mi(hdl))
4817 nvme_init_mi_cmd_flags(&cmd, ish);
4818 else
4819 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
4820 }
4821 err = libnvme_exec_admin_passthru(hdl, &cmd);
4822 if (err) {
4823 nvme_show_err(err, "Device self-test");
4824 return;
4825 }
4826
4827 nvme_show_result("Aborting device self-test operation")nvme_show_message(0, "Aborting device self-test operation");
4828}
4829
4830static int device_self_test(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4831{
4832 const char *desc = "Implementing the device self-test feature "
4833 "which provides the necessary log to determine the state of the device";
4834 const char *namespace_id =
4835 "Indicate the namespace in which the device self-test has to be carried out";
4836 const char *self_test_code =
4837 "This field specifies the action taken by the device self-test command :\n"
4838 "0h Show current state of device self-test operation\n"
4839 "1h Start a short device self-test operation\n"
4840 "2h Start a extended device self-test operation\n"
4841 "3h Start a Host-Initiated Refresh operation\n"
4842 "eh Start a vendor specific device self-test operation\n"
4843 "fh Abort the device self-test operation";
4844 const char *wait = "Wait for the test to finish";
4845
4846 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4847 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4848 struct libnvme_passthru_cmd cmd;
4849 nvme_print_flags_t flags;
4850 int err;
4851
4852 struct config {
4853 bool_Bool ish;
4854 __u32 namespace_id;
4855 __u8 stc;
4856 bool_Bool wait;
4857 };
4858
4859 struct config cfg = {
4860 .ish = false0,
4861 .namespace_id = NVME_NSID_ALL,
4862 .stc = NVME_ST_CODE_RESERVED,
4863 .wait = false0,
4864 };
4865
4866 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"self-test-code", 's', "NUM", CFG_BYTE
, &cfg.stc, 1, self_test_code, 0, }, {"wait", 'w', ((void
*)0), CFG_FLAG, &cfg.wait, 0, wait, 0, }, {"", 0, ((void*
)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0,
((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4867 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"self-test-code", 's', "NUM", CFG_BYTE
, &cfg.stc, 1, self_test_code, 0, }, {"wait", 'w', ((void
*)0), CFG_FLAG, &cfg.wait, 0, wait, 0, }, {"", 0, ((void*
)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0,
((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4868 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"self-test-code", 's', "NUM", CFG_BYTE
, &cfg.stc, 1, self_test_code, 0, }, {"wait", 'w', ((void
*)0), CFG_FLAG, &cfg.wait, 0, wait, 0, }, {"", 0, ((void*
)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0,
((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4869 OPT_BYTE("self-test-code", 's', &cfg.stc, self_test_code),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"self-test-code", 's', "NUM", CFG_BYTE
, &cfg.stc, 1, self_test_code, 0, }, {"wait", 'w', ((void
*)0), CFG_FLAG, &cfg.wait, 0, wait, 0, }, {"", 0, ((void*
)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0,
((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4870 OPT_FLAG("wait", 'w', &cfg.wait, wait))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id, 0, }, {"self-test-code", 's', "NUM", CFG_BYTE
, &cfg.stc, 1, self_test_code, 0, }, {"wait", 'w', ((void
*)0), CFG_FLAG, &cfg.wait, 0, wait, 0, }, {"", 0, ((void*
)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0,
((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4871
4872 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4873 if (err)
4874 return err;
4875
4876 err = validate_output_format(nvme_args.output_format, &flags);
4877 if (err < 0) {
4878 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4879 return err;
4880 }
4881
4882 if (cfg.stc == NVME_ST_CODE_RESERVED) {
4883 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_self_test_log *log = NULL((void*)0);
4884
4885 log = libnvme_alloc(sizeof(*log));
4886 if (!log)
4887 return -ENOMEM12;
4888
4889 err = nvme_get_log_device_self_test(hdl, log);
4890 if (err) {
4891 if (nvme_is_output_format_normal())
4892 print_info("\n")do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\n"
); } while (0)
;
4893 nvme_show_err(err, "self test log\n");
4894 }
4895
4896 if (log->completion == 0) {
4897 nvme_show_result("no self test running")nvme_show_message(0, "no self test running");
4898 } else {
4899 if (cfg.wait)
4900 err = wait_self_test(hdl);
4901 else
4902 nvme_show_result("progress %d%%", log->completion)nvme_show_message(0, "progress %d%%", log->completion);
4903 }
4904
4905 goto check_abort;
4906 }
4907
4908 nvme_init_dev_self_test(&cmd, cfg.namespace_id, cfg.stc);
4909 if (cfg.ish) {
4910 if (libnvme_transport_handle_is_mi(hdl))
4911 nvme_init_mi_cmd_flags(&cmd, ish);
4912 else
4913 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
4914 }
4915 err = libnvme_exec_admin_passthru(hdl, &cmd);
4916 if (err) {
4917 nvme_show_err(err, "Device self-test");
4918 goto check_abort;
4919 }
4920
4921 if (cfg.stc == NVME_ST_CODE_ABORT)
4922 nvme_show_result("Aborting device self-test operation")nvme_show_message(0, "Aborting device self-test operation");
4923 else if (cfg.stc == NVME_ST_CODE_EXTENDED)
4924 nvme_show_result("Extended Device self-test started")nvme_show_message(0, "Extended Device self-test started");
4925 else if (cfg.stc == NVME_ST_CODE_SHORT)
4926 nvme_show_result("Short Device self-test started")nvme_show_message(0, "Short Device self-test started");
4927 else if (cfg.stc == NVME_ST_CODE_HOST_INIT)
4928 nvme_show_result("Host-Initiated Refresh started")nvme_show_message(0, "Host-Initiated Refresh started");
4929
4930 if (cfg.wait && cfg.stc != NVME_ST_CODE_ABORT)
4931 err = wait_self_test(hdl);
4932
4933check_abort:
4934 if (err == -EINTR4)
4935 abort_self_test(hdl, cfg.ish, cfg.namespace_id);
4936
4937 return err;
4938}
4939
4940static int self_test_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
4941{
4942 const char *desc = "Retrieve the self-test log for the given device and given test "
4943 "(or optionally a namespace) in either decoded format (default) or binary.";
4944 const char *dst_entries = "Indicate how many DST log entries to be retrieved, "
4945 "by default all the 20 entries will be retrieved";
4946
4947 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_self_test_log *log = NULL((void*)0);
4948 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
4949 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
4950 nvme_print_flags_t flags;
4951 int err;
4952
4953 struct config {
4954 __u8 dst_entries;
4955 };
4956
4957 struct config cfg = {
4958 .dst_entries = NVME_LOG_ST_MAX_RESULTS,
4959 };
4960
4961 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"dst-entries", 'e', "NUM", CFG_BYTE, &cfg.dst_entries
, 1, dst_entries, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
4962 OPT_BYTE("dst-entries", 'e', &cfg.dst_entries, dst_entries))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"dst-entries", 'e', "NUM", CFG_BYTE, &cfg.dst_entries
, 1, dst_entries, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
4963
4964 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
4965 if (err)
4966 return err;
4967
4968 err = validate_output_format(nvme_args.output_format, &flags);
4969 if (err < 0) {
4970 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
4971 return err;
4972 }
4973
4974 if (nvme_args.verbose)
4975 flags |= VERBOSE;
4976
4977 log = libnvme_alloc(sizeof(*log));
4978 if (!log)
4979 return -ENOMEM12;
4980
4981 err = nvme_get_log_device_self_test(hdl, log);
4982 if (err) {
4983 nvme_show_err(err, "self test log");
4984 return err;
4985 }
4986
4987 nvme_show_self_test_log(log, cfg.dst_entries, 0,
4988 libnvme_transport_handle_get_name(hdl), flags);
4989
4990 return err;
4991}
4992
4993static int get_feature_id(struct libnvme_transport_handle *hdl, struct feat_cfg *cfg,
4994 void **buf, __u64 *result)
4995{
4996 if (!cfg->data_len)
4997 libnvme_get_feature_length(cfg->feature_id, cfg->cdw11,
4998 NVME_DATA_TFR_CTRL_TO_HOST,
4999 &cfg->data_len);
5000
5001 if (cfg->feature_id == NVME_FEAT_FID_FDP_EVENTS) {
5002 cfg->data_len = 0xff * sizeof(__u16);
5003 cfg->cdw11 |= 0xff << 16;
5004 }
5005
5006 if (NVME_CHECK(cfg->sel, GET_FEATURES_SEL, SUPPORTED)((cfg->sel) == NVME_GET_FEATURES_SEL_SUPPORTED))
5007 cfg->data_len = 0;
5008
5009 if (cfg->data_len) {
5010 *buf = libnvme_alloc(cfg->data_len - 1);
5011 if (!*buf)
5012 return -1;
5013 }
5014
5015 return nvme_get_features(hdl, cfg->namespace_id, cfg->feature_id, cfg->sel,
5016 cfg->cdw11, cfg->uuid_index, *buf, cfg->data_len, result);
5017}
5018
5019static int filter_out_flags(int status)
5020{
5021 return status & (NVME_VAL(SCT)(NVME_SCT_MASK << NVME_SCT_SHIFT) | NVME_VAL(SC)(NVME_SC_MASK << NVME_SC_SHIFT));
5022}
5023
5024static void get_feature_id_print(struct feat_cfg cfg, int err, __u64 result,
5025 void *buf, nvme_print_flags_t flags)
5026{
5027 int status = err > 0 ? filter_out_flags(err) : err;
5028 enum nvme_status_type type = NVME_STATUS_TYPE_NVME;
5029
5030 if (err) {
5031 if (nvme_status_equals(status, type, NVME_SC_INVALID_FIELD) ||
5032 nvme_status_equals(status, type, NVME_SC_INVALID_NS))
5033 return;
5034 nvme_show_err(err, "get-feature");
5035 return;
5036 }
5037
5038 nvme_show_feature(cfg.feature_id, cfg.sel, result, buf, cfg.data_len,
5039 flags);
5040}
5041
5042static bool_Bool is_get_feature_result_set(enum nvme_features_id feature_id)
5043{
5044 switch (feature_id) {
5045 case NVME_FEAT_FID_PERF_CHARACTERISTICS:
5046 case NVME_FEAT_FID_HOST_ID:
5047 return false0;
5048 default:
5049 break;
5050 }
5051
5052 return true1;
5053}
5054
5055static int get_feature_id_changed(struct libnvme_transport_handle *hdl, struct feat_cfg cfg,
5056 nvme_print_flags_t flags)
5057{
5058 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *buf_def = NULL((void*)0);
5059 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *buf = NULL((void*)0);
5060 __u64 result_def = 0;
5061 __u64 result = 0;
5062 int err_def = 0;
5063 int err;
5064
5065 if (cfg.changed)
5066 cfg.sel = NVME_GET_FEATURES_SEL_CURRENT;
5067
5068 err = get_feature_id(hdl, &cfg, &buf, &result);
5069
5070 if (!err && cfg.changed) {
5071 cfg.sel = NVME_GET_FEATURES_SEL_DEFAULT;
5072 err_def = get_feature_id(hdl, &cfg, &buf_def, &result_def);
5073 }
5074
5075 if (!err && !is_get_feature_result_set(cfg.feature_id))
5076 result = cfg.cdw11;
5077
5078 if (err || !cfg.changed || err_def || result != result_def ||
5079 (buf && buf_def && !strcmp(buf, buf_def)))
5080 get_feature_id_print(cfg, err, result, buf, flags);
5081
5082 return err;
5083}
5084
5085static int get_feature_ids(struct libnvme_transport_handle *hdl, struct feat_cfg cfg,
5086 nvme_print_flags_t flags)
5087{
5088 int err = 0;
5089 int i;
5090 int feat_max = 0x100;
5091 int feat_num = 0;
5092 int status = 0;
5093 enum nvme_status_type type = NVME_STATUS_TYPE_NVME;
5094
5095 if (cfg.feature_id)
5096 feat_max = cfg.feature_id + 1;
5097
5098 for (i = cfg.feature_id; i < feat_max; i++, feat_num++) {
5099 cfg.feature_id = i;
5100 err = get_feature_id_changed(hdl, cfg, flags);
5101 if (!err)
5102 continue;
5103 status = filter_out_flags(err);
5104 if (nvme_status_equals(status, type, NVME_SC_INVALID_FIELD))
5105 continue;
5106 if (!nvme_status_equals(status, type, NVME_SC_INVALID_NS))
5107 break;
5108 nvme_show_error_status(err, "get-feature:%#0*x (%s)", cfg.feature_id ? 4 : 2,
5109 cfg.feature_id, nvme_feature_to_string(cfg.feature_id));
5110 }
5111
5112 if (feat_num == 1 && nvme_status_equals(status, type, NVME_SC_INVALID_FIELD))
5113 nvme_show_status(err);
5114
5115 return err;
5116}
5117
5118static int get_feature(int argc, char **argv, struct command *acmd,
5119 struct plugin *plugin)
5120{
5121 const char *desc = "Read operating parameters of the "
5122 "specified controller. Operating parameters are grouped "
5123 "and identified by Feature Identifiers; each Feature "
5124 "Identifier contains one or more attributes that may affect "
5125 "behavior of the feature. Each Feature has three possible "
5126 "settings: default, saveable, and current. If a Feature is "
5127 "saveable, it may be modified by set-feature. Default values "
5128 "are vendor-specific and not changeable. Use set-feature to "
5129 "change saveable Features.";
5130 const char *raw = "show feature in binary format";
5131 const char *feature_id = "feature identifier";
5132 const char *sel = "[0-3]: current/default/saved/supported";
5133 const char *cdw11 = "feature specific dword 11";
5134 const char *changed = "show feature changed";
5135 nvme_print_flags_t flags = NORMAL;
5136
5137 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
5138 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
5139 int err;
5140
5141 struct feat_cfg cfg = {
5142 .feature_id = 0,
5143 .namespace_id = 0,
5144 .sel = NVME_GET_FEATURES_SEL_CURRENT,
5145 .data_len = 0,
5146 .raw_binary = false0,
5147 .cdw11 = 0,
5148 .uuid_index = 0,
5149 };
5150
5151 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5152 OPT_BYTE("feature-id", 'f', &cfg.feature_id, feature_id, feature_name),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5153 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5154 OPT_BYTE("sel", 's', &cfg.sel, sel),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5155 OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5156 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5157 OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5158 OPT_BYTE("uuid-index", 'U', &cfg.uuid_index, uuid_index_specify),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5159 OPT_FLAG("changed", 'C', &cfg.changed, changed))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"feature-id", 'f', "NUM", CFG_BYTE, &cfg.feature_id
, 1, feature_id, 0, feature_name}, {"namespace-id", 'n', "NUM"
, CFG_POSITIVE, &cfg.namespace_id, 1, namespace_id_desired
, 0, }, {"sel", 's', "NUM", CFG_BYTE, &cfg.sel, 1, sel, 0
, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG,
&cfg.raw_binary, 0, raw, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"uuid-index", 'U', "NUM", CFG_BYTE
, &cfg.uuid_index, 1, uuid_index_specify, 0, }, {"changed"
, 'C', ((void*)0), CFG_FLAG, &cfg.changed, 0, changed, 0,
}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
5160
5161 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
5162 if (err)
5163 return err;
5164
5165 err = validate_output_format(nvme_args.output_format, &flags);
5166 if (err < 0) {
5167 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
5168 return err;
5169 }
5170
5171 if (!argconfig_parse_seen(opts, "namespace-id")) {
5172 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
5173 if (err < 0) {
5174 if (errno(*__errno_location ()) != ENOTTY25) {
5175 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
5176 return err;
5177 }
5178 cfg.namespace_id = NVME_NSID_ALL;
5179 }
5180 }
5181
5182 if (cfg.sel > NVME_GET_FEATURES_SEL_SUPPORTED) {
5183 nvme_show_error("invalid 'select' param:%d", cfg.sel)nvme_show_message(1, "invalid 'select' param:%d", cfg.sel);
5184 return -EINVAL22;
5185 }
5186
5187 if (cfg.uuid_index > 127) {
5188 nvme_show_error("invalid uuid index param: %u", cfg.uuid_index)nvme_show_message(1, "invalid uuid index param: %u", cfg.uuid_index
)
;
5189 return -1;
5190 }
5191
5192 if (nvme_args.verbose)
5193 flags |= VERBOSE;
5194
5195 err = get_feature_ids(hdl, cfg, flags);
5196
5197 return err;
5198}
5199
5200/*
5201 * Transfers one chunk of firmware to the device, and decodes & reports any
5202 * errors. Returns -1 on (fatal) error; signifying that the transfer should
5203 * be aborted.
5204 */
5205static int fw_download_single(struct libnvme_transport_handle *hdl, void *fw_buf,
5206 bool_Bool ish, unsigned int fw_len, uint32_t offset,
5207 uint32_t len, bool_Bool progress, bool_Bool ignore_ovr)
5208{
5209 const unsigned int max_retries = 3;
5210 struct libnvme_passthru_cmd cmd;
5211 bool_Bool retryable, ovr;
5212 int err, try;
5213
5214 if (progress) {
5215 print_info("Firmware download: transferring 0x%08x/0x%08x bytes: %03d%%\r",do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("Firmware download: transferring 0x%08x/0x%08x bytes: %03d%%\r"
, offset, fw_len, (int)(100 * offset / fw_len)); } while (0)
5216 offset, fw_len, (int)(100 * offset / fw_len))do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("Firmware download: transferring 0x%08x/0x%08x bytes: %03d%%\r"
, offset, fw_len, (int)(100 * offset / fw_len)); } while (0)
;
5217 }
5218
5219 if (libnvme_transport_handle_is_mi(hdl))
5220 nvme_init_mi_cmd_flags(&cmd, ish);
5221
5222 for (try = 0; try < max_retries; try++) {
5223 if (try > 0) {
5224 nvme_show_error("retrying offset %x (%u/%u)",nvme_show_message(1, "retrying offset %x (%u/%u)", offset, try
, max_retries)
5225 offset, try, max_retries)nvme_show_message(1, "retrying offset %x (%u/%u)", offset, try
, max_retries)
;
5226 }
5227
5228 err = nvme_init_fw_download(&cmd, fw_buf, len, offset);
5229 if (err)
5230 return err;
5231
5232 err = libnvme_exec_admin_passthru(hdl, &cmd);
5233 if (!err)
5234 return 0;
5235
5236 /*
5237 * don't retry if the NVMe-type error indicates Do Not Resend.
5238 */
5239 retryable = !((err > 0) &&
5240 (nvme_status_get_type(err) == NVME_STATUS_TYPE_NVME) &&
5241 (nvme_status_get_value(err) & NVME_SC_DNR));
5242
5243 /*
5244 * detect overwrite errors, which are handled differently
5245 * depending on ignore_ovr
5246 */
5247 ovr = (err > 0) &&
5248 (nvme_status_get_type(err) == NVME_STATUS_TYPE_NVME) &&
5249 (NVME_GET(err, SCT)(((err) >> NVME_SCT_SHIFT) & NVME_SCT_MASK) == NVME_SCT_CMD_SPECIFIC) &&
5250 (NVME_GET(err, SC)(((err) >> NVME_SC_SHIFT) & NVME_SC_MASK) == NVME_SC_OVERLAPPING_RANGE);
5251
5252 if (ovr && ignore_ovr)
5253 return 0;
5254
5255 /*
5256 * if we're printing progress, we'll need a newline to separate
5257 * error output from the progress data (which doesn't have a
5258 * \n), and flush before we write to stderr.
5259 */
5260 if (progress) {
5261 print_info("\n")do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\n"
); } while (0)
;
5262 fflush(stdoutstdout);
5263 }
5264
5265 nvme_show_error("fw-download: error on offset 0x%08x/0x%08x",nvme_show_message(1, "fw-download: error on offset 0x%08x/0x%08x"
, offset, fw_len)
5266 offset, fw_len)nvme_show_message(1, "fw-download: error on offset 0x%08x/0x%08x"
, offset, fw_len)
;
5267
5268 nvme_show_err(err, "fw-download");
5269 if (err > 0 && ovr) {
5270 /*
5271 * non-ignored ovr error: print a little extra info
5272 * about recovering
5273 */
5274 nvme_show_error("Use --ignore-ovr to ignore overwrite errors")nvme_show_message(1, "Use --ignore-ovr to ignore overwrite errors"
)
;
5275
5276 /*
5277 * We'll just be attempting more overwrites if
5278 * we retry. DNR will likely be set, but force
5279 * an exit anyway.
5280 */
5281 retryable = false0;
5282 }
5283
5284 if (!retryable)
5285 break;
5286 }
5287
5288 return -1;
5289}
5290
5291static int fw_download(int argc, char **argv, struct command *acmd, struct plugin *plugin)
5292{
5293 const char *desc = "Copy all or part of a firmware image to "
5294 "a controller for future update. Optionally, specify how "
5295 "many KiB of the firmware to transfer at once. The offset will "
5296 "start at 0 and automatically adjust based on xfer size "
5297 "unless fw is split across multiple files. May be submitted "
5298 "while outstanding commands exist on the Admin and IO "
5299 "Submission Queues. Activate downloaded firmware with "
5300 "fw-activate, and then reset the device to apply the downloaded firmware.";
5301 const char *fw = "firmware file (required)";
5302 const char *xfer = "transfer chunksize limit";
5303 const char *offset = "starting dword offset, default 0";
5304 const char *progress = "display firmware transfer progress";
5305 const char *ignore_ovr = "ignore overwrite errors";
5306
5307 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
5308 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
5309 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
5310 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int fw_fd = -1;
5311 unsigned int fw_size, pos;
5312 int err;
5313 struct stat sb;
5314 void *fw_buf;
5315 struct nvme_id_ctrl ctrl = { 0 };
5316 nvme_print_flags_t flags;
5317
5318 struct config {
5319 char *fw;
5320 bool_Bool ish;
5321 __u32 xfer;
5322 __u32 offset;
5323 bool_Bool progress;
5324 bool_Bool ignore_ovr;
5325 };
5326
5327 struct config cfg = {
5328 .fw = "",
5329 .ish = false0,
5330 .xfer = 0,
5331 .offset = 0,
5332 .progress = false0,
5333 .ignore_ovr = false0,
5334 };
5335
5336 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, 1, fw, 0,
}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish, 0
, }, {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, 1, xfer
, 0, }, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset,
1, offset, 0, }, {"progress", 'p', ((void*)0), CFG_FLAG, &
cfg.progress, 0, progress, 0, }, {"ignore-ovr", 'i', ((void*)
0), CFG_FLAG, &cfg.ignore_ovr, 0, ignore_ovr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5337 OPT_FILE("fw", 'f', &cfg.fw, fw),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, 1, fw, 0,
}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish, 0
, }, {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, 1, xfer
, 0, }, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset,
1, offset, 0, }, {"progress", 'p', ((void*)0), CFG_FLAG, &
cfg.progress, 0, progress, 0, }, {"ignore-ovr", 'i', ((void*)
0), CFG_FLAG, &cfg.ignore_ovr, 0, ignore_ovr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5338 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, 1, fw, 0,
}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish, 0
, }, {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, 1, xfer
, 0, }, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset,
1, offset, 0, }, {"progress", 'p', ((void*)0), CFG_FLAG, &
cfg.progress, 0, progress, 0, }, {"ignore-ovr", 'i', ((void*)
0), CFG_FLAG, &cfg.ignore_ovr, 0, ignore_ovr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5339 OPT_UINT("xfer", 'x', &cfg.xfer, xfer),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, 1, fw, 0,
}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish, 0
, }, {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, 1, xfer
, 0, }, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset,
1, offset, 0, }, {"progress", 'p', ((void*)0), CFG_FLAG, &
cfg.progress, 0, progress, 0, }, {"ignore-ovr", 'i', ((void*)
0), CFG_FLAG, &cfg.ignore_ovr, 0, ignore_ovr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5340 OPT_UINT("offset", 'O', &cfg.offset, offset),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, 1, fw, 0,
}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish, 0
, }, {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, 1, xfer
, 0, }, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset,
1, offset, 0, }, {"progress", 'p', ((void*)0), CFG_FLAG, &
cfg.progress, 0, progress, 0, }, {"ignore-ovr", 'i', ((void*)
0), CFG_FLAG, &cfg.ignore_ovr, 0, ignore_ovr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5341 OPT_FLAG("progress", 'p', &cfg.progress, progress),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, 1, fw, 0,
}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish, 0
, }, {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, 1, xfer
, 0, }, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset,
1, offset, 0, }, {"progress", 'p', ((void*)0), CFG_FLAG, &
cfg.progress, 0, progress, 0, }, {"ignore-ovr", 'i', ((void*)
0), CFG_FLAG, &cfg.ignore_ovr, 0, ignore_ovr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5342 OPT_FLAG("ignore-ovr", 'i', &cfg.ignore_ovr, ignore_ovr))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"fw", 'f', "FILE", CFG_STRING, &cfg.fw, 1, fw, 0,
}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish, 0
, }, {"xfer", 'x', "NUM", CFG_POSITIVE, &cfg.xfer, 1, xfer
, 0, }, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset,
1, offset, 0, }, {"progress", 'p', ((void*)0), CFG_FLAG, &
cfg.progress, 0, progress, 0, }, {"ignore-ovr", 'i', ((void*)
0), CFG_FLAG, &cfg.ignore_ovr, 0, ignore_ovr, 0, }, {"", 0
, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
5343
5344 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
5345 if (err)
5346 return err;
5347
5348 err = validate_output_format(nvme_args.output_format, &flags);
5349 if (err < 0) {
5350 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
5351 return err;
5352 }
5353
5354 fw_fd = nvme_open_rawdata(cfg.fw, O_RDONLY)open((cfg.fw), (00));
5355 cfg.offset <<= 2;
5356 if (fw_fd < 0) {
5357 nvme_show_error("Failed to open firmware file %s: %s", cfg.fw, libnvme_strerror(errno))nvme_show_message(1, "Failed to open firmware file %s: %s", cfg
.fw, libnvme_strerror((*__errno_location ())))
;
5358 return -EINVAL22;
5359 }
5360
5361 err = fstat(fw_fd, &sb);
5362 if (err < 0) {
5363 nvme_show_perror("fstat");
5364 return err;
5365 }
5366
5367 fw_size = sb.st_size;
5368 if ((fw_size & 0x3) || (fw_size == 0)) {
5369 nvme_show_error("Invalid size:%d for f/w image", fw_size)nvme_show_message(1, "Invalid size:%d for f/w image", fw_size
)
;
5370 return -EINVAL22;
5371 }
5372
5373 if (cfg.xfer == 0) {
5374 err = nvme_identify_ctrl(hdl, &ctrl);
5375 if (err) {
5376 nvme_show_error("identify-ctrl: %s", libnvme_strerror(err))nvme_show_message(1, "identify-ctrl: %s", libnvme_strerror(err
))
;
5377 return err;
5378 }
5379 if (ctrl.fwug == 0 || ctrl.fwug == 0xff)
5380 cfg.xfer = 4096;
5381 else
5382 cfg.xfer = ctrl.fwug * 4096;
5383 } else if (cfg.xfer % 4096)
5384 cfg.xfer = 4096;
5385
5386 if (ctrl.fwug && ctrl.fwug != 0xff && fw_size % cfg.xfer)
5387 nvme_show_error("WARNING: firmware file size %u not conform to FWUG alignment %lu",nvme_show_message(1, "WARNING: firmware file size %u not conform to FWUG alignment %lu"
, fw_size, cfg.xfer)
5388 fw_size, cfg.xfer)nvme_show_message(1, "WARNING: firmware file size %u not conform to FWUG alignment %lu"
, fw_size, cfg.xfer)
;
5389
5390 fw_buf = libnvme_alloc_huge(fw_size, &mh);
5391 if (!fw_buf) {
5392 nvme_show_error("failed to allocate huge memory")nvme_show_message(1, "failed to allocate huge memory");
5393 return -ENOMEM12;
5394 }
5395
5396 if (read(fw_fd, fw_buf, fw_size) != ((ssize_t)(fw_size))) {
5397 err = -errno(*__errno_location ());
5398 nvme_show_error("read :%s :%s", cfg.fw, libnvme_strerror(errno))nvme_show_message(1, "read :%s :%s", cfg.fw, libnvme_strerror
((*__errno_location ())))
;
5399 return err;
5400 }
5401
5402 if (cfg.ish && !libnvme_transport_handle_is_mi(hdl)) {
5403 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
5404 }
5405
5406 for (pos = 0; pos < fw_size; pos += cfg.xfer) {
5407 cfg.xfer = min(cfg.xfer, fw_size - pos)((cfg.xfer) > (fw_size - pos) ? (fw_size - pos) : (cfg.xfer
))
;
5408
5409 err = fw_download_single(hdl, fw_buf + pos, cfg.ish, fw_size,
5410 cfg.offset + pos, cfg.xfer,
5411 cfg.progress, cfg.ignore_ovr);
5412 if (err)
5413 break;
5414 }
5415
5416 if (!err) {
5417 /* end the progress output */
5418 if (cfg.progress)
5419 print_info("\n")do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\n"
); } while (0)
;
5420 nvme_show_verbose_result("Firmware download success")nvme_show_verbose_message("Firmware download success");
5421 }
5422
5423 return err;
5424}
5425
5426static char *nvme_fw_status_reset_type(__u16 status)
5427{
5428 switch (status & 0x7ff) {
5429 case NVME_SC_FW_NEEDS_CONV_RESET:
5430 return "conventional";
5431 case NVME_SC_FW_NEEDS_SUBSYS_RESET:
5432 return "subsystem";
5433 case NVME_SC_FW_NEEDS_RESET:
5434 return "any controller";
5435 default:
5436 return "unknown";
5437 }
5438}
5439
5440static bool_Bool fw_commit_support_mud(struct libnvme_transport_handle *hdl)
5441{
5442 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
5443 int err;
5444
5445 ctrl = libnvme_alloc(sizeof(*ctrl));
5446 if (!ctrl)
5447 return false0;
5448
5449 err = nvme_identify_ctrl(hdl, ctrl);
5450
5451 if (err)
5452 nvme_show_error("identify-ctrl: %s", libnvme_strerror(err))nvme_show_message(1, "identify-ctrl: %s", libnvme_strerror(err
))
;
5453 else if (ctrl->frmw >> 5 & 0x1)
5454 return true1;
5455
5456 return false0;
5457}
5458
5459static void fw_commit_print_mud(bool_Bool mud_supported, __u64 result)
5460{
5461 if (!mud_supported)
5462 return;
5463
5464 nvme_show_result("Multiple Update Detected (MUD) Value: %#" PRIx64,nvme_show_message(0, "Multiple Update Detected (MUD) Value: %#"
"l" "x", (uint64_t)result)
5465 (uint64_t)result)nvme_show_message(0, "Multiple Update Detected (MUD) Value: %#"
"l" "x", (uint64_t)result)
;
5466
5467 if (result & 0x1)
5468 nvme_show_result("Detected an overlapping firmware/boot partition image update command "nvme_show_message(0, "Detected an overlapping firmware/boot partition image update command "
"sequence due to processing a command from an Admin SQ on a controller"
)
5469 "sequence due to processing a command from an Admin SQ on a controller")nvme_show_message(0, "Detected an overlapping firmware/boot partition image update command "
"sequence due to processing a command from an Admin SQ on a controller"
)
;
5470
5471 if (result >> 1 & 0x1)
5472 nvme_show_result("Detected an overlapping firmware/boot partition image update command "nvme_show_message(0, "Detected an overlapping firmware/boot partition image update command "
"sequence due to processing a command from a Management Endpoint"
)
5473 "sequence due to processing a command from a Management Endpoint")nvme_show_message(0, "Detected an overlapping firmware/boot partition image update command "
"sequence due to processing a command from a Management Endpoint"
)
;
5474}
5475
5476static void fw_commit_err(int err, __u8 action, __u8 slot, __u8 bpid)
5477{
5478 __u32 val;
5479
5480 if (err > 0 && nvme_status_get_type(err) == NVME_STATUS_TYPE_NVME) {
5481 val = nvme_status_get_value(err);
5482 switch (val & 0x7ff) {
5483 case NVME_SC_FW_NEEDS_CONV_RESET:
5484 case NVME_SC_FW_NEEDS_SUBSYS_RESET:
5485 case NVME_SC_FW_NEEDS_RESET:
5486 print_info("Success activating firmware action:%d slot:%d",do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("Success activating firmware action:%d slot:%d"
, action, slot); } while (0)
5487 action, slot)do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("Success activating firmware action:%d slot:%d"
, action, slot); } while (0)
;
5488 if (action == 6 || action == 7)
5489 print_info(" bpid:%d", bpid)do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf(" bpid:%d"
, bpid); } while (0)
;
5490 print_info(", but firmware requires %s reset\n",do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf(", but firmware requires %s reset\n"
, nvme_fw_status_reset_type(val)); } while (0)
5491 nvme_fw_status_reset_type(val))do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf(", but firmware requires %s reset\n"
, nvme_fw_status_reset_type(val)); } while (0)
;
5492 return;
5493 default:
5494 break;
5495 }
5496 }
5497
5498 nvme_show_err(err, "fw-commit");
5499}
5500
5501static int fw_commit(int argc, char **argv, struct command *acmd, struct plugin *plugin)
5502{
5503 const char *desc = "Verify downloaded firmware image and "
5504 "commit to specific firmware slot. Device is not automatically "
5505 "reset following firmware activation. A reset may be issued "
5506 "with an 'echo 1 > /sys/class/nvme/nvmeX/reset_controller'. "
5507 "Ensure nvmeX is the device you just activated before reset.";
5508 const char *slot = "[0-7]: firmware slot for commit action";
5509 const char *action = "[0-7]: commit action: 0 = replace, "
5510 "1 = replace and activate, 2 = set active, "
5511 "3 = replace and activate immediate, "
5512 "6 = replace boot partition, "
5513 "7 = activate boot partition";
5514 const char *bpid = "[0,1]: boot partition identifier, if applicable (default: 0)";
5515
5516 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
5517 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
5518 struct libnvme_passthru_cmd cmd;
5519 int err;
5520 nvme_print_flags_t flags;
5521 bool_Bool mud_supported;
5522
5523 struct config {
5524 bool_Bool ish;
5525 __u8 slot;
5526 __u8 action;
5527 __u8 bpid;
5528 };
5529
5530 struct config cfg = {
5531 .ish = false0,
5532 .slot = 0,
5533 .action = 0,
5534 .bpid = 0,
5535 };
5536
5537 OPT_VALS(ca)struct argconfig_opt_val ca[] = {
5538 VAL_BYTE("replace", NVME_FW_COMMIT_CA_REPLACE){"replace", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_REPLACE},
5539 VAL_BYTE("replace-and-activate",{"replace-and-activate", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE
}
5540 NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE){"replace-and-activate", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE
}
,
5541 VAL_BYTE("set-active", NVME_FW_COMMIT_CA_SET_ACTIVE){"set-active", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_SET_ACTIVE
}
,
5542 VAL_BYTE("replace-and-activate-immediate",{"replace-and-activate-immediate", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE_IMMEDIATE
}
5543 NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE_IMMEDIATE){"replace-and-activate-immediate", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE_IMMEDIATE
}
,
5544 VAL_BYTE("replace-boot-partition",{"replace-boot-partition", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_REPLACE_BOOT_PARTITION
}
5545 NVME_FW_COMMIT_CA_REPLACE_BOOT_PARTITION){"replace-boot-partition", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_REPLACE_BOOT_PARTITION
}
,
5546 VAL_BYTE("activate-boot-partition",{"activate-boot-partition", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_ACTIVATE_BOOT_PARTITION
}
5547 NVME_FW_COMMIT_CA_ACTIVATE_BOOT_PARTITION){"activate-boot-partition", CFG_BYTE, .val.byte = NVME_FW_COMMIT_CA_ACTIVATE_BOOT_PARTITION
}
,
5548 VAL_END(){ ((void*)0) }
5549 };
5550
5551 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"slot", 's', "NUM", CFG_BYTE, &cfg.slot, 1, slot
, 0, }, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, ca}, {"bpid", 'b', "NUM", CFG_BYTE, &cfg.bpid, 1, bpid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5552 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"slot", 's', "NUM", CFG_BYTE, &cfg.slot, 1, slot
, 0, }, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, ca}, {"bpid", 'b', "NUM", CFG_BYTE, &cfg.bpid, 1, bpid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5553 OPT_BYTE("slot", 's', &cfg.slot, slot),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"slot", 's', "NUM", CFG_BYTE, &cfg.slot, 1, slot
, 0, }, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, ca}, {"bpid", 'b', "NUM", CFG_BYTE, &cfg.bpid, 1, bpid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5554 OPT_BYTE("action", 'a', &cfg.action, action, ca),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"slot", 's', "NUM", CFG_BYTE, &cfg.slot, 1, slot
, 0, }, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, ca}, {"bpid", 'b', "NUM", CFG_BYTE, &cfg.bpid, 1, bpid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5555 OPT_BYTE("bpid", 'b', &cfg.bpid, bpid))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"slot", 's', "NUM", CFG_BYTE, &cfg.slot, 1, slot
, 0, }, {"action", 'a', "NUM", CFG_BYTE, &cfg.action, 1, action
, 0, ca}, {"bpid", 'b', "NUM", CFG_BYTE, &cfg.bpid, 1, bpid
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
5556
5557 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
5558 if (err)
5559 return err;
5560
5561 err = validate_output_format(nvme_args.output_format, &flags);
5562 if (err < 0) {
5563 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
5564 return err;
5565 }
5566
5567 if (cfg.slot > 7) {
5568 nvme_show_error("invalid slot:%d", cfg.slot)nvme_show_message(1, "invalid slot:%d", cfg.slot);
5569 return -EINVAL22;
5570 }
5571
5572 switch (cfg.action) {
5573 case NVME_FW_COMMIT_CA_REPLACE:
5574 case NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE:
5575 case NVME_FW_COMMIT_CA_SET_ACTIVE:
5576 case NVME_FW_COMMIT_CA_REPLACE_AND_ACTIVATE_IMMEDIATE:
5577 case NVME_FW_COMMIT_CA_REPLACE_BOOT_PARTITION:
5578 case NVME_FW_COMMIT_CA_ACTIVATE_BOOT_PARTITION:
5579 break;
5580 default:
5581 nvme_show_error("invalid action:%d", cfg.action)nvme_show_message(1, "invalid action:%d", cfg.action);
5582 return -EINVAL22;
5583 }
5584
5585 if (cfg.bpid > 1) {
5586 nvme_show_error("invalid boot partition id:%d", cfg.bpid)nvme_show_message(1, "invalid boot partition id:%d", cfg.bpid
)
;
5587 return -EINVAL22;
5588 }
5589
5590 mud_supported = fw_commit_support_mud(hdl);
5591
5592 nvme_init_fw_commit(&cmd, cfg.slot, cfg.action, cfg.bpid);
5593 if (cfg.ish) {
5594 if (libnvme_transport_handle_is_mi(hdl))
5595 nvme_init_mi_cmd_flags(&cmd, ish);
5596 else
5597 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
5598 }
5599 err = libnvme_exec_admin_passthru(hdl, &cmd);
5600 if (err) {
5601 fw_commit_err(err, cfg.action, cfg.slot, cfg.bpid);
5602 return err;
5603 }
5604
5605 if (cfg.action == 6 || cfg.action == 7)
5606 nvme_show_verbose_result("Success committing firmware action:%d slot:%d bpid:%d",nvme_show_verbose_message("Success committing firmware action:%d slot:%d bpid:%d"
, cfg.action, cfg.slot, cfg.bpid)
5607 cfg.action, cfg.slot, cfg.bpid)nvme_show_verbose_message("Success committing firmware action:%d slot:%d bpid:%d"
, cfg.action, cfg.slot, cfg.bpid)
;
5608 else
5609 nvme_show_verbose_result("Success committing firmware action:%d slot:%d",nvme_show_verbose_message("Success committing firmware action:%d slot:%d"
, cfg.action, cfg.slot)
5610 cfg.action, cfg.slot)nvme_show_verbose_message("Success committing firmware action:%d slot:%d"
, cfg.action, cfg.slot)
;
5611 fw_commit_print_mud(mud_supported, cmd.result);
5612
5613 return err;
5614}
5615
5616static int subsystem_reset(int argc, char **argv, struct command *acmd, struct plugin *plugin)
5617{
5618 const char *desc = "Resets the NVMe subsystem";
5619
5620 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
5621 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
5622 int err;
5623
5624 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
5625
5626 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
5627 if (err)
5628 return err;
5629
5630 if (!libnvme_transport_handle_is_ctrl(hdl)) {
5631 nvme_show_error(only_ctrl_dev)nvme_show_message(1, only_ctrl_dev);
5632 return -EINVAL22;
5633 }
5634
5635 err = libnvme_reset_subsystem(hdl);
5636 if (err < 0) {
5637 if (errno(*__errno_location ()) == ENOTTY25)
5638 nvme_show_error("Subsystem-reset: NVM Subsystem Reset not supported.")nvme_show_message(1, "Subsystem-reset: NVM Subsystem Reset not supported."
)
;
5639 else
5640 nvme_show_error("Subsystem-reset: %s", libnvme_strerror(-err))nvme_show_message(1, "Subsystem-reset: %s", libnvme_strerror(
-err))
;
5641 } else {
5642 nvme_show_verbose_info("resetting subsystem through %s",nvme_show_verbose_message("resetting subsystem through %s", libnvme_transport_handle_get_name
(hdl))
5643 libnvme_transport_handle_get_name(hdl))nvme_show_verbose_message("resetting subsystem through %s", libnvme_transport_handle_get_name
(hdl))
;
5644 }
5645
5646 return err;
5647}
5648
5649static int reset(int argc, char **argv, struct command *acmd, struct plugin *plugin)
5650{
5651 const char *desc = "Resets the NVMe controller\n";
5652
5653 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
5654 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
5655 int err;
5656
5657 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
5658
5659 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
5660 if (err)
5661 return err;
5662
5663 if (!libnvme_transport_handle_is_ctrl(hdl)) {
5664 nvme_show_error(only_ctrl_dev)nvme_show_message(1, only_ctrl_dev);
5665 return -EINVAL22;
5666 }
5667
5668 err = libnvme_reset_ctrl(hdl);
5669 if (err < 0)
5670 nvme_show_error("Reset: %s", libnvme_strerror(-err))nvme_show_message(1, "Reset: %s", libnvme_strerror(-err));
5671 else
5672 nvme_show_verbose_info("resetting controller %s",nvme_show_verbose_message("resetting controller %s", libnvme_transport_handle_get_name
(hdl))
5673 libnvme_transport_handle_get_name(hdl))nvme_show_verbose_message("resetting controller %s", libnvme_transport_handle_get_name
(hdl))
;
5674
5675 return err;
5676}
5677
5678static int ns_rescan(int argc, char **argv, struct command *acmd, struct plugin *plugin)
5679{
5680 const char *desc = "Rescans the NVMe namespaces\n";
5681
5682 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
5683 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
5684 int err;
5685 nvme_print_flags_t flags;
5686
5687 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
5688
5689 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
5690 if (err)
5691 return err;
5692
5693 if (!libnvme_transport_handle_is_ctrl(hdl)) {
5694 nvme_show_error(only_ctrl_dev)nvme_show_message(1, only_ctrl_dev);
5695 return -EINVAL22;
5696 }
5697
5698 err = validate_output_format(nvme_args.output_format, &flags);
5699 if (err < 0) {
5700 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
5701 return err;
5702 }
5703
5704 err = libnvme_rescan_ns(hdl);
5705 if (err < 0)
5706 nvme_show_error("Namespace Rescan: %s\n", libnvme_strerror(-err))nvme_show_message(1, "Namespace Rescan: %s\n", libnvme_strerror
(-err))
;
5707 else
5708 nvme_show_verbose_info("rescanning namespaces through %s",nvme_show_verbose_message("rescanning namespaces through %s",
libnvme_transport_handle_get_name(hdl))
5709 libnvme_transport_handle_get_name(hdl))nvme_show_verbose_message("rescanning namespaces through %s",
libnvme_transport_handle_get_name(hdl))
;
5710
5711 return err;
5712}
5713
5714static int wait_sanitize(struct libnvme_transport_handle *hdl)
5715{
5716 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_sanitize_log_page *log = NULL((void*)0);
5717 static const char spin[] = {'-', '\\', '|', '/' };
5718 __u64 i = 0, cnt = 0, wthr = 0;
5719 __u32 p = 0;
5720 int err;
5721
5722 log = libnvme_alloc(sizeof(*log));
5723 if (!log)
5724 return -ENOMEM12;
5725
5726 err = nvme_get_log_sanitize(hdl, false0, log);
5727 if (err) {
5728 nvme_show_err(err, "sanitize status log");
5729 return err;
5730 }
5731
5732 switch (NVME_GET(log->scdw10, SANITIZE_CDW10_SANACT)(((log->scdw10) >> NVME_SANITIZE_CDW10_SANACT_SHIFT)
& NVME_SANITIZE_CDW10_SANACT_MASK)
) {
5733 case NVME_SANITIZE_SANACT_EXIT_FAILURE:
5734 break;
5735 case NVME_SANITIZE_SANACT_START_BLOCK_ERASE:
5736 if (NVME_GET(log->scdw10, SANITIZE_CDW10_NDAS)(((log->scdw10) >> NVME_SANITIZE_CDW10_NDAS_SHIFT) &
NVME_SANITIZE_CDW10_NDAS_MASK)
)
5737 wthr = le32_to_cpu(log->etbend);
5738 else
5739 wthr = le32_to_cpu(log->etbe);
5740 break;
5741 case NVME_SANITIZE_SANACT_START_OVERWRITE:
5742 if (NVME_GET(log->scdw10, SANITIZE_CDW10_NDAS)(((log->scdw10) >> NVME_SANITIZE_CDW10_NDAS_SHIFT) &
NVME_SANITIZE_CDW10_NDAS_MASK)
)
5743 wthr = le32_to_cpu(log->etond);
5744 else
5745 wthr = le32_to_cpu(log->eto);
5746 break;
5747 case NVME_SANITIZE_SANACT_START_CRYPTO_ERASE:
5748 if (NVME_GET(log->scdw10, SANITIZE_CDW10_NDAS)(((log->scdw10) >> NVME_SANITIZE_CDW10_NDAS_SHIFT) &
NVME_SANITIZE_CDW10_NDAS_MASK)
)
5749 wthr = le32_to_cpu(log->etcend);
5750 else
5751 wthr = le32_to_cpu(log->etce);
5752 break;
5753 case NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF:
5754 default:
5755 break;
5756 }
5757 if (wthr != 0xffffffff && NVME_GET(log->scdw10, SANITIZE_CDW10_EMVS)(((log->scdw10) >> NVME_SANITIZE_CDW10_EMVS_SHIFT) &
NVME_SANITIZE_CDW10_EMVS_MASK)
)
5758 wthr += le32_to_cpu(log->etpvds);
5759
5760 nvme_show_result("Waiting for sanitize completion...")nvme_show_message(0, "Waiting for sanitize completion...");
5761 while (true1) {
5762 if (nvme_is_output_format_normal()) {
5763 print_info("\r[%.*s%c%.*s] %3d%%", p * 100 / 0xffff / 2, dash,do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\r[%.*s%c%.*s] %3d%%"
, p * 100 / 0xffff / 2, dash, spin[i % 4], 49 - p * 100 / 0xffff
/ 2, space, p * 100 / 0xffff); } while (0)
5764 spin[i % 4], 49 - p * 100 / 0xffff / 2, space,do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\r[%.*s%c%.*s] %3d%%"
, p * 100 / 0xffff / 2, dash, spin[i % 4], 49 - p * 100 / 0xffff
/ 2, space, p * 100 / 0xffff); } while (0)
5765 p * 100 / 0xffff)do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\r[%.*s%c%.*s] %3d%%"
, p * 100 / 0xffff / 2, dash, spin[i % 4], 49 - p * 100 / 0xffff
/ 2, space, p * 100 / 0xffff); } while (0)
;
5766 fflush(stdoutstdout);
5767 }
5768 err = nvme_sleep(1);
5769 if (err)
5770 return err;
5771
5772 err = nvme_get_log_sanitize(hdl, false0, log);
5773 if (err) {
5774 if (nvme_is_output_format_normal())
5775 print_info("\n")do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\n"
); } while (0)
;
5776 nvme_show_err(err, "sanitize status log");
5777 return err;
5778 }
5779
5780 if (++cnt > wthr) {
5781 nvme_show_error(nvme_show_message(1, "no progress for %""l" "u"" seconds, stop waiting"
, wthr)
5782 "no progress for %"PRIu64" seconds, stop waiting",nvme_show_message(1, "no progress for %""l" "u"" seconds, stop waiting"
, wthr)
5783 wthr)nvme_show_message(1, "no progress for %""l" "u"" seconds, stop waiting"
, wthr)
;
5784 return -EIO5;
5785 }
5786
5787 if (le16_to_cpu(log->sprog) == 0xffff) {
5788 if (nvme_is_output_format_normal())
5789 print_info("\r[%.*s] %3d%%\n", 50, dash, 100)do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\r[%.*s] %3d%%\n"
, 50, dash, 100); } while (0)
;
5790 break;
5791 }
5792
5793 if (le16_to_cpu(log->sprog) < p) {
5794 if (nvme_is_output_format_normal())
5795 print_info("\n")do { if (is_printable_at_level(LIBNVME_LOG_INFO)) printf("\n"
); } while (0)
;
5796 nvme_show_error("progress broken")nvme_show_message(1, "progress broken");
5797 return -EIO5;
5798 } else if (le16_to_cpu(log->sprog) != p) {
5799 p = le16_to_cpu(log->sprog);
5800 cnt = 0;
5801 }
5802
5803 i++;
5804 }
5805
5806 return 0;
5807}
5808
5809static int check_sanitize(struct libnvme_transport_handle *hdl, bool_Bool *sanitized)
5810{
5811 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_sanitize_log_page *log = NULL((void*)0);
5812 int err;
5813
5814 log = libnvme_alloc(sizeof(*log));
5815 if (!log)
5816 return -ENOMEM12;
5817
5818 err = nvme_get_log_sanitize(hdl, false0, log);
5819 if (err) {
5820 nvme_show_err(err, "sanitize status log");
5821 return err;
5822 }
5823
5824 switch (NVME_GET(le16_to_cpu(log->sstat), SANITIZE_SSTAT_STATUS)(((le16_to_cpu(log->sstat)) >> NVME_SANITIZE_SSTAT_STATUS_SHIFT
) & NVME_SANITIZE_SSTAT_STATUS_MASK)
) {
5825 case NVME_SANITIZE_SSTAT_STATUS_NEVER_SANITIZED:
5826 break;
5827 case NVME_SANITIZE_SSTAT_STATUS_COMPLETE_SUCCESS:
5828 *sanitized = true1;
5829 break;
5830 case NVME_SANITIZE_SSTAT_STATUS_IN_PROGRESS:
5831 case NVME_SANITIZE_SSTAT_STATUS_COMPLETED_FAILED:
5832 case NVME_SANITIZE_SSTAT_STATUS_ND_COMPLETE_SUCCESS:
5833 default:
5834 break;
5835 }
5836
5837 return 0;
5838}
5839
5840struct nvme_id_ctrl *identify_ctrl(struct libnvme_transport_handle *hdl)
5841{
5842 struct nvme_id_ctrl *ctrl = libnvme_alloc(sizeof(*ctrl));
5843 int err = 0;
5844
5845 if (!ctrl) {
5846 errno(*__errno_location ()) = ENOMEM12;
5847 return NULL((void*)0);
5848 }
5849
5850 err = nvme_identify_ctrl(hdl, ctrl);
5851 if (err) {
5852 nvme_show_error("identify-ctrl: %s", libnvme_strerror(err))nvme_show_message(1, "identify-ctrl: %s", libnvme_strerror(err
))
;
5853 libnvme_free(ctrl);
5854 return NULL((void*)0);
5855 }
5856
5857 return ctrl;
5858}
5859
5860static int sanitize_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
5861{
5862 const char *desc = "Send a sanitize command.";
5863 const char *emvs_desc = "Enter media verification state.";
5864 const char *no_dealloc_desc = "No deallocate after sanitize.";
5865 const char *oipbp_desc = "Overwrite invert pattern between passes.";
5866 const char *owpass_desc = "Overwrite pass count.";
5867 const char *ause_desc = "Allow unrestricted sanitize exit.";
5868 const char *sanact_desc = "Sanitize action: 1 = Exit failure mode, 2 = Start block erase,"
5869 "3 = Start overwrite, 4 = Start crypto erase, 5 = Exit media verification";
5870 const char *ovrpat_desc = "Overwrite pattern.";
5871 const char *wait = "Wait for the sanitize to finish";
5872 const char *repeat = "Repeat for the multi cycle sanitization";
5873
5874 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
5875 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
5876 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
5877 struct libnvme_passthru_cmd cmd;
5878 nvme_print_flags_t flags;
5879 int err;
5880 bool_Bool sanitized;
5881
5882 struct config {
5883 bool_Bool ish;
5884 bool_Bool no_dealloc;
5885 bool_Bool oipbp;
5886 __u8 owpass;
5887 bool_Bool ause;
5888 __u8 sanact;
5889 __u32 ovrpat;
5890 bool_Bool emvs;
5891 bool_Bool wait;
5892 __u32 repeat;
5893 };
5894
5895 struct config cfg = {
5896 .ish = false0,
5897 .no_dealloc = false0,
5898 .oipbp = false0,
5899 .owpass = 0,
5900 .ause = false0,
5901 .sanact = 0,
5902 .ovrpat = 0,
5903 .emvs = false0,
5904 .repeat = 1,
5905 };
5906
5907 OPT_VALS(sanact)struct argconfig_opt_val sanact[] = {
5908 VAL_BYTE("exit-failure", NVME_SANITIZE_SANACT_EXIT_FAILURE){"exit-failure", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_EXIT_FAILURE
}
,
5909 VAL_BYTE("start-block-erase", NVME_SANITIZE_SANACT_START_BLOCK_ERASE){"start-block-erase", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_START_BLOCK_ERASE
}
,
5910 VAL_BYTE("start-overwrite", NVME_SANITIZE_SANACT_START_OVERWRITE){"start-overwrite", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_START_OVERWRITE
}
,
5911 VAL_BYTE("start-crypto-erase", NVME_SANITIZE_SANACT_START_CRYPTO_ERASE){"start-crypto-erase", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_START_CRYPTO_ERASE
}
,
5912 VAL_BYTE("exit-media-verification", NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF){"exit-media-verification", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF
}
,
5913 VAL_END(){ ((void*)0) }
5914 };
5915
5916 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5917 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5918 OPT_FLAG("no-dealloc", 'd', &cfg.no_dealloc, no_dealloc_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5919 OPT_FLAG("oipbp", 'i', &cfg.oipbp, oipbp_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5920 OPT_BYTE("owpass", 'n', &cfg.owpass, owpass_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5921 OPT_FLAG("ause", 'u', &cfg.ause, ause_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5922 OPT_BYTE("sanact", 'a', &cfg.sanact, sanact_desc, sanact),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5923 OPT_UINT("ovrpat", 'p', &cfg.ovrpat, ovrpat_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5924 OPT_FLAG("emvs", 'e', &cfg.emvs, emvs_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5925 OPT_FLAG("wait", 'w', &cfg.wait, wait),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
5926 OPT_UINT("repeat", 'r', &cfg.repeat, repeat))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"no-dealloc", 'd', ((void*)0), CFG_FLAG, &cfg.no_dealloc
, 0, no_dealloc_desc, 0, }, {"oipbp", 'i', ((void*)0), CFG_FLAG
, &cfg.oipbp, 0, oipbp_desc, 0, }, {"owpass", 'n', "NUM",
CFG_BYTE, &cfg.owpass, 1, owpass_desc, 0, }, {"ause", 'u'
, ((void*)0), CFG_FLAG, &cfg.ause, 0, ause_desc, 0, }, {"sanact"
, 'a', "NUM", CFG_BYTE, &cfg.sanact, 1, sanact_desc, 0, sanact
}, {"ovrpat", 'p', "NUM", CFG_POSITIVE, &cfg.ovrpat, 1, ovrpat_desc
, 0, }, {"emvs", 'e', ((void*)0), CFG_FLAG, &cfg.emvs, 0,
emvs_desc, 0, }, {"wait", 'w', ((void*)0), CFG_FLAG, &cfg
.wait, 0, wait, 0, }, {"repeat", 'r', "NUM", CFG_POSITIVE, &
cfg.repeat, 1, repeat, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
5927
5928 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
5929 if (err)
5930 return err;
5931
5932 err = validate_output_format(nvme_args.output_format, &flags);
5933 if (err < 0) {
5934 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
5935 return err;
5936 }
5937
5938 ctrl = identify_ctrl(hdl);
5939 if (!ctrl)
5940 return -errno(*__errno_location ());
5941
5942 switch (cfg.sanact) {
5943 case NVME_SANITIZE_SANACT_EXIT_FAILURE:
5944 break;
5945 case NVME_SANITIZE_SANACT_START_BLOCK_ERASE:
5946 if (!NVME_CTRL_SANICAP_BES(le32_to_cpu(ctrl->sanicap))(((le32_to_cpu(ctrl->sanicap)) >> NVME_CTRL_SANICAP_BES_SHIFT
) & NVME_CTRL_SANICAP_BES_MASK)
) {
5947 nvme_show_error("block erase action unsupported")nvme_show_message(1, "block erase action unsupported");
5948 return -EINVAL22;
5949 }
5950 break;
5951 case NVME_SANITIZE_SANACT_START_OVERWRITE:
5952 if (!NVME_CTRL_SANICAP_OWS(le32_to_cpu(ctrl->sanicap))(((le32_to_cpu(ctrl->sanicap)) >> NVME_CTRL_SANICAP_OWS_SHIFT
) & NVME_CTRL_SANICAP_OWS_MASK)
) {
5953 nvme_show_error("overwrite action unsupported")nvme_show_message(1, "overwrite action unsupported");
5954 return -EINVAL22;
5955 }
5956 break;
5957 case NVME_SANITIZE_SANACT_START_CRYPTO_ERASE:
5958 if (!NVME_CTRL_SANICAP_CES(le32_to_cpu(ctrl->sanicap))(((le32_to_cpu(ctrl->sanicap)) >> NVME_CTRL_SANICAP_CES_SHIFT
) & NVME_CTRL_SANICAP_CES_MASK)
) {
5959 nvme_show_error("crypto erase action unsupported")nvme_show_message(1, "crypto erase action unsupported");
5960 return -EINVAL22;
5961 }
5962 break;
5963 case NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF:
5964 break;
5965 default:
5966 nvme_show_error("Invalid Sanitize Action")nvme_show_message(1, "Invalid Sanitize Action");
5967 return -EINVAL22;
5968 }
5969
5970 if (cfg.emvs && !NVME_CTRL_SANICAP_VERS(le32_to_cpu(ctrl->sanicap))(((le32_to_cpu(ctrl->sanicap)) >> NVME_CTRL_SANICAP_VERS_SHIFT
) & NVME_CTRL_SANICAP_VERS_MASK)
) {
5971 nvme_show_error("media verification unsupported")nvme_show_message(1, "media verification unsupported");
5972 return -EINVAL22;
5973 }
5974
5975 if (cfg.ause || cfg.no_dealloc) {
5976 if (cfg.sanact == NVME_SANITIZE_SANACT_EXIT_FAILURE) {
5977 nvme_show_error("SANACT is Exit Failure Mode")nvme_show_message(1, "SANACT is Exit Failure Mode");
5978 return -EINVAL22;
5979 } else if (cfg.sanact == NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF) {
5980 nvme_show_error("SANACT is Exit Media Verification State")nvme_show_message(1, "SANACT is Exit Media Verification State"
)
;
5981 return -EINVAL22;
5982 }
5983 }
5984
5985 if (cfg.sanact == NVME_SANITIZE_SANACT_START_OVERWRITE) {
5986 if (cfg.owpass > 15) {
5987 nvme_show_error("OWPASS out of range [0-15]")nvme_show_message(1, "OWPASS out of range [0-15]");
5988 return -EINVAL22;
5989 }
5990 } else {
5991 if (cfg.owpass || cfg.oipbp || cfg.ovrpat) {
5992 nvme_show_error("SANACT is not Overwrite")nvme_show_message(1, "SANACT is not Overwrite");
5993 return -EINVAL22;
5994 }
5995 }
5996
5997 nvme_init_sanitize_nvm(&cmd, cfg.sanact, cfg.ause, cfg.owpass,
5998 cfg.oipbp, cfg.no_dealloc, cfg.emvs, cfg.ovrpat);
5999 if (cfg.ish) {
6000 if (libnvme_transport_handle_is_mi(hdl))
6001 nvme_init_mi_cmd_flags(&cmd, ish);
6002 else
6003 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
6004 }
6005
6006 do {
6007 err = libnvme_exec_admin_passthru(hdl, &cmd);
6008 if (err) {
6009 nvme_show_err(err, "sanitize");
6010 return err;
6011 }
6012
6013 if (cfg.wait)
6014 err = wait_sanitize(hdl);
6015
6016 sanitized = false0;
6017 if (!err && --cfg.repeat)
6018 err = check_sanitize(hdl, &sanitized);
6019 } while (!err && sanitized);
6020
6021 return err;
6022}
6023
6024static int sanitize_ns_cmd(int argc, char **argv, struct command *acmd,
6025 struct plugin *plugin)
6026{
6027 const char *desc = "Send a sanitize namespace command.";
6028 const char *emvs_desc = "Enter media verification state.";
6029 const char *ause_desc = "Allow unrestricted sanitize exit.";
6030 const char *sanact_desc = "Sanitize action: 1 = Exit failure mode,\n"
6031 "4 = Start a crypto erase namespace sanitize operation,\n"
6032 "5 = Exit media verification state";
6033
6034 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl =
6035 NULL((void*)0);
6036
6037 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
6038 struct libnvme_passthru_cmd cmd;
6039 nvme_print_flags_t flags;
6040 int err;
6041
6042 struct config {
6043 bool_Bool ish;
6044 bool_Bool ause;
6045 __u8 sanact;
6046 bool_Bool emvs;
6047 };
6048
6049 struct config cfg = {
6050 .ish = false0,
6051 .ause = false0,
6052 .sanact = 0,
6053 .emvs = false0,
6054 };
6055
6056 OPT_VALS(sanact)struct argconfig_opt_val sanact[] = {
6057 VAL_BYTE("exit-failure", NVME_SANITIZE_SANACT_EXIT_FAILURE){"exit-failure", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_EXIT_FAILURE
}
,
6058 VAL_BYTE("start-crypto-erase",{"start-crypto-erase", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_START_CRYPTO_ERASE
}
6059 NVME_SANITIZE_SANACT_START_CRYPTO_ERASE){"start-crypto-erase", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_START_CRYPTO_ERASE
}
,
6060 VAL_BYTE("exit-media-verification",{"exit-media-verification", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF
}
6061 NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF){"exit-media-verification", CFG_BYTE, .val.byte = NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF
}
,
6062 VAL_END(){ ((void*)0) }
6063 };
6064
6065 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"ause", 'u', ((void*)0), CFG_FLAG, &cfg.ause, 0,
ause_desc, 0, }, {"sanact", 'a', "NUM", CFG_BYTE, &cfg.sanact
, 1, sanact_desc, 0, sanact}, {"emvs", 'e', ((void*)0), CFG_FLAG
, &cfg.emvs, 0, emvs_desc, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6066 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"ause", 'u', ((void*)0), CFG_FLAG, &cfg.ause, 0,
ause_desc, 0, }, {"sanact", 'a', "NUM", CFG_BYTE, &cfg.sanact
, 1, sanact_desc, 0, sanact}, {"emvs", 'e', ((void*)0), CFG_FLAG
, &cfg.emvs, 0, emvs_desc, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6067 OPT_FLAG("ause", 'u', &cfg.ause, ause_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"ause", 'u', ((void*)0), CFG_FLAG, &cfg.ause, 0,
ause_desc, 0, }, {"sanact", 'a', "NUM", CFG_BYTE, &cfg.sanact
, 1, sanact_desc, 0, sanact}, {"emvs", 'e', ((void*)0), CFG_FLAG
, &cfg.emvs, 0, emvs_desc, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6068 OPT_BYTE("sanact", 'a', &cfg.sanact, sanact_desc, sanact),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"ause", 'u', ((void*)0), CFG_FLAG, &cfg.ause, 0,
ause_desc, 0, }, {"sanact", 'a', "NUM", CFG_BYTE, &cfg.sanact
, 1, sanact_desc, 0, sanact}, {"emvs", 'e', ((void*)0), CFG_FLAG
, &cfg.emvs, 0, emvs_desc, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6069 OPT_FLAG("emvs", 'e', &cfg.emvs, emvs_desc))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"ause", 'u', ((void*)0), CFG_FLAG, &cfg.ause, 0,
ause_desc, 0, }, {"sanact", 'a', "NUM", CFG_BYTE, &cfg.sanact
, 1, sanact_desc, 0, sanact}, {"emvs", 'e', ((void*)0), CFG_FLAG
, &cfg.emvs, 0, emvs_desc, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
6070
6071 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
6072 if (err)
6073 return err;
6074
6075 err = validate_output_format(nvme_args.output_format, &flags);
6076 if (err < 0) {
6077 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
6078 return err;
6079 }
6080
6081 switch (cfg.sanact) {
6082 case NVME_SANITIZE_SANACT_EXIT_FAILURE:
6083 case NVME_SANITIZE_SANACT_START_CRYPTO_ERASE:
6084 case NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF:
6085 break;
6086 default:
6087 nvme_show_error("Invalid Sanitize Action")nvme_show_message(1, "Invalid Sanitize Action");
6088 return -EINVAL22;
6089 }
6090
6091 if (cfg.ause) {
6092 if (cfg.sanact == NVME_SANITIZE_SANACT_EXIT_FAILURE) {
6093 nvme_show_error("SANACT is Exit Failure Mode")nvme_show_message(1, "SANACT is Exit Failure Mode");
6094 return -EINVAL22;
6095 } else if (cfg.sanact ==
6096 NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF) {
6097 nvme_show_error(nvme_show_message(1, "SANACT is Exit Media Verification State"
)
6098 "SANACT is Exit Media Verification State")nvme_show_message(1, "SANACT is Exit Media Verification State"
)
;
6099 return -EINVAL22;
6100 }
6101 }
6102
6103 nvme_init_sanitize_ns(&cmd, cfg.sanact, cfg.ause, cfg.emvs);
6104 if (cfg.ish) {
6105 if (libnvme_transport_handle_is_mi(hdl))
6106 nvme_init_mi_cmd_flags(&cmd, ish);
6107 else
6108 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
6109 }
6110 err = libnvme_exec_admin_passthru(hdl, &cmd);
6111 if (err) {
6112 nvme_show_admin_cmd_err("sanitize ns", cmd.opcode, err);
6113 return err;
6114 }
6115
6116 return err;
6117}
6118
6119static int nvme_get_single_property(struct libnvme_transport_handle *hdl,
6120 struct get_reg_config *cfg, __u64 *value)
6121{
6122 struct libnvme_passthru_cmd cmd;
6123 int err;
6124
6125 nvme_init_get_property(&cmd, cfg->offset);
6126 err = libnvme_exec_admin_passthru(hdl, &cmd);
6127 if (!err) {
6128 *value = cmd.result;
6129 return 0;
6130 }
6131
6132 if (cfg->fabrics && nvme_is_fabrics_optional_reg(cfg->offset)) {
6133 *value = -1;
6134 return 0;
6135 }
6136
6137 if (!cfg->fabrics &&
6138 nvme_status_equals(err, NVME_STATUS_TYPE_NVME,
6139 NVME_SC_INVALID_FIELD)) {
6140 *value = -1;
6141 return 0;
6142 }
6143
6144 nvme_show_err(err, "get-property");
6145 return err;
6146}
6147
6148static int nvme_get_properties(struct libnvme_transport_handle *hdl, void **pbar,
6149 struct get_reg_config *cfg)
6150{
6151 int err, size = getpagesize();
6152 bool_Bool is_64bit = false0;
6153 __u64 value;
6154 void *bar;
6155 int offset;
6156
6157 bar = malloc(size);
6158 if (!bar)
6159 return -ENOMEM12;
6160
6161 memset(bar, 0xff, size);
6162 for (offset = NVME_REG_CAP; offset <= NVME_REG_CMBSZ;
6163 offset += is_64bit ? sizeof(uint64_t) : sizeof(uint32_t)) {
6164 if (!nvme_is_fabrics_reg(offset))
6165 continue;
6166
6167 cfg->offset = offset;
6168 err = nvme_get_single_property(hdl, cfg, &value);
6169 if (err)
6170 break;
6171
6172 is_64bit = nvme_is_64bit_reg(cfg->offset);
6173 if (is_64bit)
6174 *(uint64_t *)(bar + cfg->offset) = value;
6175 else
6176 *(uint32_t *)(bar + cfg->offset) = value;
6177 }
6178
6179 if (err)
6180 free(bar);
6181 else
6182 *pbar = bar;
6183
6184 return err;
6185}
6186
6187static void *mmap_registers(struct libnvme_transport_handle *hdl, bool_Bool writable)
6188{
6189 void *membase = NULL((void*)0);
6190#ifdef NVME_HAVE_MMAP
6191 char path[512];
6192 int fd;
6193 int prot = PROT_READ0x1;
6194
6195 if (writable)
6196 prot |= PROT_WRITE0x2;
6197
6198 sprintf(path, "/sys/class/nvme/%s/device/resource0", libnvme_transport_handle_get_name(hdl));
6199 fd = open(path, writable ? O_RDWR02 : O_RDONLY00);
6200 if (fd < 0) {
6201 if (log_level >= LIBNVME_LOG_INFO)
6202 nvme_show_error("%s did not find a pci resource, open failed %s",nvme_show_message(1, "%s did not find a pci resource, open failed %s"
, libnvme_transport_handle_get_name(hdl), libnvme_strerror((*
__errno_location ())))
6203 libnvme_transport_handle_get_name(hdl), libnvme_strerror(errno))nvme_show_message(1, "%s did not find a pci resource, open failed %s"
, libnvme_transport_handle_get_name(hdl), libnvme_strerror((*
__errno_location ())))
;
6204 return NULL((void*)0);
6205 }
6206
6207 membase = mmap(NULL((void*)0), getpagesize(), prot, MAP_SHARED0x01, fd, 0);
6208 if (membase == MAP_FAILED((void *) -1)) {
6209 if (log_level >= LIBNVME_LOG_INFO) {
6210 nvme_show_error("Failed to map registers to userspace.\n\n"nvme_show_message(1, "Failed to map registers to userspace.\n\n"
"Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n" "You can disable this feature with command line argument\n\n"
"\tio_memory=relaxed\n\n" "Also ensure secure boot is disabled."
)
6211 "Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n"nvme_show_message(1, "Failed to map registers to userspace.\n\n"
"Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n" "You can disable this feature with command line argument\n\n"
"\tio_memory=relaxed\n\n" "Also ensure secure boot is disabled."
)
6212 "You can disable this feature with command line argument\n\n"nvme_show_message(1, "Failed to map registers to userspace.\n\n"
"Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n" "You can disable this feature with command line argument\n\n"
"\tio_memory=relaxed\n\n" "Also ensure secure boot is disabled."
)
6213 "\tio_memory=relaxed\n\n"nvme_show_message(1, "Failed to map registers to userspace.\n\n"
"Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n" "You can disable this feature with command line argument\n\n"
"\tio_memory=relaxed\n\n" "Also ensure secure boot is disabled."
)
6214 "Also ensure secure boot is disabled.")nvme_show_message(1, "Failed to map registers to userspace.\n\n"
"Did your kernel enable CONFIG_IO_STRICT_DEVMEM?\n" "You can disable this feature with command line argument\n\n"
"\tio_memory=relaxed\n\n" "Also ensure secure boot is disabled."
)
;
6215 }
6216 membase = NULL((void*)0);
6217 }
6218
6219 close(fd);
6220#endif
6221 return membase;
6222}
6223
6224static int munmap_registers(void *addr)
6225{
6226#ifdef NVME_HAVE_MMAP
6227 return munmap(addr, getpagesize());
6228#else
6229 return 0;
6230#endif
6231}
6232
6233static int show_registers(int argc, char **argv, struct command *acmd, struct plugin *plugin)
6234{
6235 const char *desc = "Reads and shows the defined NVMe controller registers\n"
6236 "in binary or human-readable format";
6237
6238 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
6239 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
6240 nvme_print_flags_t flags;
6241 void *bar;
6242 int err;
6243
6244 struct get_reg_config cfg = {
6245 .fabrics = false0,
6246 };
6247
6248 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
6249
6250 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
6251 if (err)
6252 return err;
6253
6254 if (libnvme_transport_handle_is_ns(hdl)) {
6255 nvme_show_error(only_ctrl_dev)nvme_show_message(1, only_ctrl_dev);
6256 return -EINVAL22;
6257 }
6258
6259 err = validate_output_format(nvme_args.output_format, &flags);
6260 if (err < 0) {
6261 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
6262 return err;
6263 }
6264
6265 if (nvme_args.verbose)
6266 flags |= VERBOSE;
6267
6268 bar = mmap_registers(hdl, false0);
6269 if (!bar) {
6270 cfg.fabrics = true1;
6271 err = nvme_get_properties(hdl, &bar, &cfg);
6272 if (err)
6273 return err;
6274 }
6275
6276 nvme_show_ctrl_registers(bar, cfg.fabrics, flags);
6277 if (cfg.fabrics)
6278 free(bar);
6279 else
6280 munmap_registers(bar);
6281
6282 return 0;
6283}
6284
6285int get_reg_size(int offset)
6286{
6287 return nvme_is_64bit_reg(offset) ? sizeof(uint64_t) : sizeof(uint32_t);
6288}
6289
6290static bool_Bool is_reg_selected(struct get_reg_config *cfg, int offset)
6291{
6292 switch (offset) {
6293 case NVME_REG_CAP:
6294 return cfg->cap;
6295 case NVME_REG_VS:
6296 return cfg->vs;
6297 case NVME_REG_INTMS:
6298 return cfg->intms;
6299 case NVME_REG_INTMC:
6300 return cfg->intmc;
6301 case NVME_REG_CC:
6302 return cfg->cc;
6303 case NVME_REG_CSTS:
6304 return cfg->csts;
6305 case NVME_REG_NSSR:
6306 return cfg->nssr;
6307 case NVME_REG_AQA:
6308 return cfg->aqa;
6309 case NVME_REG_ASQ:
6310 return cfg->asq;
6311 case NVME_REG_ACQ:
6312 return cfg->acq;
6313 case NVME_REG_CMBLOC:
6314 return cfg->cmbloc;
6315 case NVME_REG_CMBSZ:
6316 return cfg->cmbsz;
6317 case NVME_REG_BPINFO:
6318 return cfg->bpinfo;
6319 case NVME_REG_BPRSEL:
6320 return cfg->bprsel;
6321 case NVME_REG_BPMBL:
6322 return cfg->bpmbl;
6323 case NVME_REG_CMBMSC:
6324 return cfg->cmbmsc;
6325 case NVME_REG_CMBSTS:
6326 return cfg->cmbsts;
6327 case NVME_REG_CMBEBS:
6328 return cfg->cmbebs;
6329 case NVME_REG_CMBSWTP:
6330 return cfg->cmbswtp;
6331 case NVME_REG_NSSD:
6332 return cfg->nssd;
6333 case NVME_REG_CRTO:
6334 return cfg->crto;
6335 case NVME_REG_PMRCAP:
6336 return cfg->pmrcap;
6337 case NVME_REG_PMRCTL:
6338 return cfg->pmrctl;
6339 case NVME_REG_PMRSTS:
6340 return cfg->pmrsts;
6341 case NVME_REG_PMREBS:
6342 return cfg->pmrebs;
6343 case NVME_REG_PMRSWTP:
6344 return cfg->pmrswtp;
6345 case NVME_REG_PMRMSCL:
6346 return cfg->pmrmscl;
6347 case NVME_REG_PMRMSCU:
6348 return cfg->pmrmscu;
6349 default:
6350 break;
6351 }
6352
6353 return false0;
6354}
6355
6356static int get_register_properties(struct libnvme_transport_handle *hdl, void **pbar, struct get_reg_config *cfg)
6357{
6358 struct libnvme_passthru_cmd cmd;
6359 int offset = NVME_REG_CRTO;
6360 __u64 value;
6361 int size;
6362 int err;
6363 void *bar;
6364
6365 size = offset + get_reg_size(offset);
6366 bar = malloc(size);
6367 if (!bar)
6368 return -ENOMEM12;
6369
6370 for (offset = NVME_REG_CAP; offset <= NVME_REG_CRTO; offset += get_reg_size(offset)) {
6371 if ((cfg->offset != offset && !is_reg_selected(cfg, offset)) ||
6372 !nvme_is_fabrics_reg(offset))
6373 continue;
6374
6375 nvme_init_get_property(&cmd, offset);
6376 err = libnvme_exec_admin_passthru(hdl, &cmd);
6377 if (nvme_status_equals(err, NVME_STATUS_TYPE_NVME, NVME_SC_INVALID_FIELD)) {
6378 value = -1;
6379 } else if (err) {
6380 nvme_show_error("get-property: %s", libnvme_strerror(-err))nvme_show_message(1, "get-property: %s", libnvme_strerror(-err
))
;
6381 free(bar);
6382 return err;
6383 } else {
6384 value = cmd.result;
6385 }
6386
6387 if (nvme_is_64bit_reg(offset))
6388 *(uint64_t *)(bar + offset) = value;
6389 else
6390 *(uint32_t *)(bar + offset) = value;
6391 }
6392
6393 *pbar = bar;
6394
6395 return 0;
6396}
6397
6398bool_Bool nvme_is_ctrl_reg(int offset)
6399{
6400 switch (offset) {
6401 case NVME_REG_CAP:
6402 case NVME_REG_VS:
6403 case NVME_REG_INTMS:
6404 case NVME_REG_INTMC:
6405 case NVME_REG_CC:
6406 case NVME_REG_CSTS:
6407 case NVME_REG_NSSR:
6408 case NVME_REG_AQA:
6409 case NVME_REG_ASQ:
6410 case NVME_REG_ACQ:
6411 case NVME_REG_CMBLOC:
6412 case NVME_REG_CMBSZ:
6413 case NVME_REG_BPINFO:
6414 case NVME_REG_BPRSEL:
6415 case NVME_REG_BPMBL:
6416 case NVME_REG_CMBMSC:
6417 case NVME_REG_CMBSTS:
6418 case NVME_REG_CMBEBS:
6419 case NVME_REG_CMBSWTP:
6420 case NVME_REG_NSSD:
6421 case NVME_REG_CRTO:
6422 case NVME_REG_PMRCAP:
6423 case NVME_REG_PMRCTL:
6424 case NVME_REG_PMRSTS:
6425 case NVME_REG_PMREBS:
6426 case NVME_REG_PMRSWTP:
6427 case NVME_REG_PMRMSCL:
6428 case NVME_REG_PMRMSCU:
6429 return true1;
6430 default:
6431 break;
6432 }
6433
6434 return false0;
6435}
6436
6437static bool_Bool get_register_offset(void *bar, bool_Bool fabrics, struct get_reg_config *cfg,
6438 nvme_print_flags_t flags)
6439{
6440 bool_Bool offset_matched = cfg->offset >= 0;
6441 int offset;
6442
6443 if (offset_matched)
6444 nvme_show_ctrl_register(bar, fabrics, cfg->offset, flags);
6445
6446 for (offset = NVME_REG_CAP; offset <= NVME_REG_PMRMSCU; offset += get_reg_size(offset)) {
6447 if (!nvme_is_ctrl_reg(offset) || offset == cfg->offset || !is_reg_selected(cfg, offset))
6448 continue;
6449 nvme_show_ctrl_register(bar, fabrics, offset, flags);
6450 if (!offset_matched)
6451 offset_matched = true1;
6452 }
6453
6454 return offset_matched;
6455}
6456
6457static int get_register(int argc, char **argv, struct command *acmd, struct plugin *plugin)
6458{
6459 const char *desc = "Reads and shows the defined NVMe controller register.\n"
6460 "Register offset must be one of:\n"
6461 "CAP=0x0, VS=0x8, INTMS=0xc, INTMC=0x10, CC=0x14, CSTS=0x1c,\n"
6462 "NSSR=0x20, AQA=0x24, ASQ=0x28, ACQ=0x30, CMBLOC=0x38,\n"
6463 "CMBSZ=0x3c, BPINFO=0x40, BPRSEL=0x44, BPMBL=0x48, CMBMSC=0x50,\n"
6464 "CMBSTS=0x58, CRTO=0x68, PMRCAP=0xe00, PMRCTL=0xe04,\n"
6465 "PMRSTS=0xe08, PMREBS=0xe0c, PMRSWTP=0xe10, PMRMSCL=0xe14, PMRMSCU=0xe18";
6466 const char *cap = "CAP=0x0 register offset";
6467 const char *vs = "VS=0x8 register offset";
6468 const char *cmbloc = "CMBLOC=0x38 register offset";
6469 const char *cmbsz = "CMBSZ=0x3c register offset";
6470 const char *bpinfo = "BPINFO=0x40 register offset";
6471 const char *cmbsts = "CMBSTS=0x58 register offset";
6472 const char *cmbebs = "CMBEBS=0x5c register offset";
6473 const char *cmbswtp = "CMBSWTP=0x60 register offset";
6474 const char *crto = "CRTO=0x68 register offset";
6475 const char *pmrcap = "PMRCAP=0xe00 register offset";
6476 const char *pmrsts = "PMRSTS=0xe08 register offset";
6477 const char *pmrebs = "PMREBS=0xe0c register offset";
6478 const char *pmrswtp = "PMRSWTP=0xe10 register offset";
6479 const char *pmrmscl = "PMRMSCL=0xe14 register offset";
6480 const char *pmrmscu = "PMRMSCU=0xe18 register offset";
6481
6482 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
6483 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
6484 int err;
6485 nvme_print_flags_t flags;
6486 bool_Bool fabrics = false0;
6487
6488 void *bar;
6489
6490 struct get_reg_config cfg = {
6491 .offset = -1,
6492 };
6493
6494 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6495 OPT_UINT("offset", 'O', &cfg.offset, offset),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6496 OPT_FLAG("cap", 0, &cfg.cap, cap),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6497 OPT_FLAG("vs", 0, &cfg.vs, vs),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6498 OPT_FLAG("cmbloc", 0, &cfg.cmbloc, cmbloc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6499 OPT_FLAG("cmbsz", 0, &cfg.cmbsz, cmbsz),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6500 OPT_FLAG("bpinfo", 0, &cfg.bpinfo, bpinfo),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6501 OPT_FLAG("cmbsts", 0, &cfg.cmbsts, cmbsts),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6502 OPT_FLAG("cmbebs", 0, &cfg.cmbebs, cmbebs),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6503 OPT_FLAG("cmbswtp", 0, &cfg.cmbswtp, cmbswtp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6504 OPT_FLAG("crto", 0, &cfg.crto, crto),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6505 OPT_FLAG("pmrcap", 0, &cfg.pmrcap, pmrcap),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6506 OPT_FLAG("pmrsts", 0, &cfg.pmrsts, pmrsts),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6507 OPT_FLAG("pmrebs", 0, &cfg.pmrebs, pmrebs),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6508 OPT_FLAG("pmrswtp", 0, &cfg.pmrswtp, pmrswtp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6509 OPT_FLAG("intms", 0, &cfg.intms, intms),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6510 OPT_FLAG("intmc", 0, &cfg.intmc, intmc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6511 OPT_FLAG("cc", 0, &cfg.cc, cc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6512 OPT_FLAG("csts", 0, &cfg.csts, csts),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6513 OPT_FLAG("nssr", 0, &cfg.nssr, nssr),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6514 OPT_FLAG("aqa", 0, &cfg.aqa, aqa),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6515 OPT_FLAG("asq", 0, &cfg.asq, asq),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6516 OPT_FLAG("acq", 0, &cfg.acq, acq),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6517 OPT_FLAG("bprsel", 0, &cfg.bprsel, bprsel),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6518 OPT_FLAG("bpmbl", 0, &cfg.bpmbl, bpmbl),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6519 OPT_FLAG("cmbmsc", 0, &cfg.cmbmsc, cmbmsc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6520 OPT_FLAG("nssd", 0, &cfg.nssd, nssd),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6521 OPT_FLAG("pmrctl", 0, &cfg.pmrctl, pmrctl),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6522 OPT_FLAG("pmrmscl", 0, &cfg.pmrmscl, pmrmscl),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6523 OPT_FLAG("pmrmscu", 0, &cfg.pmrmscu, pmrmscu))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"cap", 0, ((void*)0), CFG_FLAG, &cfg.cap
, 0, cap, 0, }, {"vs", 0, ((void*)0), CFG_FLAG, &cfg.vs, 0
, vs, 0, }, {"cmbloc", 0, ((void*)0), CFG_FLAG, &cfg.cmbloc
, 0, cmbloc, 0, }, {"cmbsz", 0, ((void*)0), CFG_FLAG, &cfg
.cmbsz, 0, cmbsz, 0, }, {"bpinfo", 0, ((void*)0), CFG_FLAG, &
cfg.bpinfo, 0, bpinfo, 0, }, {"cmbsts", 0, ((void*)0), CFG_FLAG
, &cfg.cmbsts, 0, cmbsts, 0, }, {"cmbebs", 0, ((void*)0),
CFG_FLAG, &cfg.cmbebs, 0, cmbebs, 0, }, {"cmbswtp", 0, (
(void*)0), CFG_FLAG, &cfg.cmbswtp, 0, cmbswtp, 0, }, {"crto"
, 0, ((void*)0), CFG_FLAG, &cfg.crto, 0, crto, 0, }, {"pmrcap"
, 0, ((void*)0), CFG_FLAG, &cfg.pmrcap, 0, pmrcap, 0, }, {
"pmrsts", 0, ((void*)0), CFG_FLAG, &cfg.pmrsts, 0, pmrsts
, 0, }, {"pmrebs", 0, ((void*)0), CFG_FLAG, &cfg.pmrebs, 0
, pmrebs, 0, }, {"pmrswtp", 0, ((void*)0), CFG_FLAG, &cfg
.pmrswtp, 0, pmrswtp, 0, }, {"intms", 0, ((void*)0), CFG_FLAG
, &cfg.intms, 0, intms, 0, }, {"intmc", 0, ((void*)0), CFG_FLAG
, &cfg.intmc, 0, intmc, 0, }, {"cc", 0, ((void*)0), CFG_FLAG
, &cfg.cc, 0, cc, 0, }, {"csts", 0, ((void*)0), CFG_FLAG,
&cfg.csts, 0, csts, 0, }, {"nssr", 0, ((void*)0), CFG_FLAG
, &cfg.nssr, 0, nssr, 0, }, {"aqa", 0, ((void*)0), CFG_FLAG
, &cfg.aqa, 0, aqa, 0, }, {"asq", 0, ((void*)0), CFG_FLAG
, &cfg.asq, 0, asq, 0, }, {"acq", 0, ((void*)0), CFG_FLAG
, &cfg.acq, 0, acq, 0, }, {"bprsel", 0, ((void*)0), CFG_FLAG
, &cfg.bprsel, 0, bprsel, 0, }, {"bpmbl", 0, ((void*)0), CFG_FLAG
, &cfg.bpmbl, 0, bpmbl, 0, }, {"cmbmsc", 0, ((void*)0), CFG_FLAG
, &cfg.cmbmsc, 0, cmbmsc, 0, }, {"nssd", 0, ((void*)0), CFG_FLAG
, &cfg.nssd, 0, nssd, 0, }, {"pmrctl", 0, ((void*)0), CFG_FLAG
, &cfg.pmrctl, 0, pmrctl, 0, }, {"pmrmscl", 0, ((void*)0)
, CFG_FLAG, &cfg.pmrmscl, 0, pmrmscl, 0, }, {"pmrmscu", 0
, ((void*)0), CFG_FLAG, &cfg.pmrmscu, 0, pmrmscu, 0, }, {
"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
6524
6525 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
6526 if (err)
6527 return err;
6528
6529 if (libnvme_transport_handle_is_ns(hdl)) {
6530 nvme_show_error(only_ctrl_dev)nvme_show_message(1, only_ctrl_dev);
6531 return -EINVAL22;
6532 }
6533
6534 err = validate_output_format(nvme_args.output_format, &flags);
6535 if (err < 0) {
6536 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
6537 return err;
6538 }
6539
6540 if (nvme_args.verbose)
6541 flags |= VERBOSE;
6542
6543 bar = mmap_registers(hdl, false0);
6544 if (!bar) {
6545 err = get_register_properties(hdl, &bar, &cfg);
6546 if (err)
6547 return err;
6548 fabrics = true1;
6549 }
6550
6551 if (!get_register_offset(bar, fabrics, &cfg, flags)) {
6552 nvme_show_error("offset required param")nvme_show_message(1, "offset required param");
6553 err = -EINVAL22;
6554 }
6555
6556 if (fabrics)
6557 free(bar);
6558 else
6559 munmap_registers(bar);
6560
6561 return err;
6562}
6563
6564static int nvme_set_single_property(struct libnvme_transport_handle *hdl, int offset, uint64_t value)
6565{
6566 struct libnvme_passthru_cmd cmd;
6567 int err;
6568
6569 nvme_init_set_property(&cmd, offset, value);
6570 err = libnvme_exec_admin_passthru(hdl, &cmd);
6571 if (err) {
6572 nvme_show_err(err, "set-property");
6573 return err;
6574 }
6575
6576 nvme_show_result("set-property: %#02x (%s), value: %#"PRIx64, offset,nvme_show_message(0, "set-property: %#02x (%s), value: %#""l"
"x", offset, nvme_register_to_string(offset), value)
6577 nvme_register_to_string(offset), value)nvme_show_message(0, "set-property: %#02x (%s), value: %#""l"
"x", offset, nvme_register_to_string(offset), value)
;
6578
6579 return err;
6580}
6581
6582static int set_register_property(struct libnvme_transport_handle *hdl, int offset, uint64_t value)
6583{
6584 if (!nvme_is_fabrics_reg(offset)) {
6585 nvme_show_error("register: %#04x (%s) not fabrics", offset,nvme_show_message(1, "register: %#04x (%s) not fabrics", offset
, nvme_register_to_string(offset))
6586 nvme_register_to_string(offset))nvme_show_message(1, "register: %#04x (%s) not fabrics", offset
, nvme_register_to_string(offset))
;
6587 return -EINVAL22;
6588 }
6589
6590 return nvme_set_single_property(hdl, offset, value);
6591}
6592
6593static int nvme_set_register(struct libnvme_transport_handle *hdl, void *bar, int offset, uint64_t value, bool_Bool mmio32)
6594{
6595 if (!bar)
6596 return set_register_property(hdl, offset, value);
6597
6598 if (nvme_is_64bit_reg(offset))
6599 mmio_write64(bar + offset, value, mmio32);
6600 else
6601 mmio_write32(bar + offset, value);
6602
6603 nvme_show_result("set-register: %#02x (%s), value: %#"PRIx64, offset,nvme_show_message(0, "set-register: %#02x (%s), value: %#""l"
"x", offset, nvme_register_to_string(offset), value)
6604 nvme_register_to_string(offset), value)nvme_show_message(0, "set-register: %#02x (%s), value: %#""l"
"x", offset, nvme_register_to_string(offset), value)
;
6605
6606 return 0;
6607}
6608
6609static inline int set_register_names_check(struct argconfig_commandline_options *opts, int offset)
6610{
6611 switch (offset) {
6612 case NVME_REG_INTMS:
6613 if (argconfig_parse_seen(opts, "intms"))
6614 return -EINVAL22;
6615 break;
6616 case NVME_REG_INTMC:
6617 if (argconfig_parse_seen(opts, "intmc"))
6618 return -EINVAL22;
6619 break;
6620 case NVME_REG_CC:
6621 if (argconfig_parse_seen(opts, "cc"))
6622 return -EINVAL22;
6623 break;
6624 case NVME_REG_CSTS:
6625 if (argconfig_parse_seen(opts, "csts"))
6626 return -EINVAL22;
6627 break;
6628 case NVME_REG_NSSR:
6629 if (argconfig_parse_seen(opts, "nssr"))
6630 return -EINVAL22;
6631 break;
6632 case NVME_REG_AQA:
6633 if (argconfig_parse_seen(opts, "aqa"))
6634 return -EINVAL22;
6635 break;
6636 case NVME_REG_ASQ:
6637 if (argconfig_parse_seen(opts, "asq"))
6638 return -EINVAL22;
6639 break;
6640 case NVME_REG_ACQ:
6641 if (argconfig_parse_seen(opts, "acq"))
6642 return -EINVAL22;
6643 break;
6644 case NVME_REG_BPRSEL:
6645 if (argconfig_parse_seen(opts, "bprsel"))
6646 return -EINVAL22;
6647 break;
6648 case NVME_REG_CMBMSC:
6649 if (argconfig_parse_seen(opts, "cmbmsc"))
6650 return -EINVAL22;
6651 break;
6652 case NVME_REG_NSSD:
6653 if (argconfig_parse_seen(opts, "nssd"))
6654 return -EINVAL22;
6655 break;
6656 case NVME_REG_PMRCTL:
6657 if (argconfig_parse_seen(opts, "pmrctl"))
6658 return -EINVAL22;
6659 break;
6660 case NVME_REG_PMRMSCL:
6661 if (argconfig_parse_seen(opts, "pmrmscl"))
6662 return -EINVAL22;
6663 break;
6664 case NVME_REG_PMRMSCU:
6665 if (argconfig_parse_seen(opts, "pmrmscu"))
6666 return -EINVAL22;
6667 break;
6668 default:
6669 break;
6670 }
6671
6672 return 0;
6673}
6674
6675static int set_register_offset(struct libnvme_transport_handle *hdl, void *bar, struct argconfig_commandline_options *opts,
6676 struct set_reg_config *cfg)
6677{
6678 int err;
6679
6680 if (!argconfig_parse_seen(opts, "value")) {
6681 nvme_show_error("value required param")nvme_show_message(1, "value required param");
6682 return -EINVAL22;
6683 }
6684
6685 err = set_register_names_check(opts, cfg->offset);
6686 if (err) {
6687 nvme_show_error("offset duplicated param")nvme_show_message(1, "offset duplicated param");
6688 return err;
6689 }
6690
6691 err = nvme_set_register(hdl, bar, cfg->offset, cfg->value, cfg->mmio32);
6692 if (err)
6693 return err;
6694
6695 return 0;
6696}
6697
6698static int set_register_names(struct libnvme_transport_handle *hdl, void *bar, struct argconfig_commandline_options *opts,
6699 struct set_reg_config *cfg)
6700{
6701 int err;
6702
6703 if (argconfig_parse_seen(opts, "intms")) {
6704 err = nvme_set_register(hdl, bar, NVME_REG_INTMS, cfg->intms, cfg->mmio32);
6705 if (err)
6706 return err;
6707 }
6708
6709 if (argconfig_parse_seen(opts, "intmc")) {
6710 err = nvme_set_register(hdl, bar, NVME_REG_INTMC, cfg->intmc, cfg->mmio32);
6711 if (err)
6712 return err;
6713 }
6714
6715 if (argconfig_parse_seen(opts, "cc")) {
6716 err = nvme_set_register(hdl, bar, NVME_REG_CC, cfg->cc, cfg->mmio32);
6717 if (err)
6718 return err;
6719 }
6720
6721 if (argconfig_parse_seen(opts, "csts")) {
6722 err = nvme_set_register(hdl, bar, NVME_REG_CSTS, cfg->csts, cfg->mmio32);
6723 if (err)
6724 return err;
6725 }
6726
6727 if (argconfig_parse_seen(opts, "nssr")) {
6728 err = nvme_set_register(hdl, bar, NVME_REG_NSSR, cfg->nssr, cfg->mmio32);
6729 if (err)
6730 return err;
6731 }
6732
6733 if (argconfig_parse_seen(opts, "aqa")) {
6734 err = nvme_set_register(hdl, bar, NVME_REG_AQA, cfg->aqa, cfg->mmio32);
6735 if (err)
6736 return err;
6737 }
6738
6739 if (argconfig_parse_seen(opts, "asq")) {
6740 err = nvme_set_register(hdl, bar, NVME_REG_ASQ, cfg->asq, cfg->mmio32);
6741 if (err)
6742 return err;
6743 }
6744
6745 if (argconfig_parse_seen(opts, "acq")) {
6746 err = nvme_set_register(hdl, bar, NVME_REG_ACQ, cfg->acq, cfg->mmio32);
6747 if (err)
6748 return err;
6749 }
6750
6751 if (argconfig_parse_seen(opts, "bprsel")) {
6752 err = nvme_set_register(hdl, bar, NVME_REG_BPRSEL, cfg->bprsel, cfg->mmio32);
6753 if (err)
6754 return err;
6755 }
6756
6757 if (argconfig_parse_seen(opts, "cmbmsc")) {
6758 err = nvme_set_register(hdl, bar, NVME_REG_CMBMSC, cfg->cmbmsc, cfg->mmio32);
6759 if (err)
6760 return err;
6761 }
6762
6763 if (argconfig_parse_seen(opts, "nssd")) {
6764 err = nvme_set_register(hdl, bar, NVME_REG_NSSD, cfg->nssd, cfg->mmio32);
6765 if (err)
6766 return err;
6767 }
6768
6769 if (argconfig_parse_seen(opts, "pmrctl")) {
6770 err = nvme_set_register(hdl, bar, NVME_REG_PMRCTL, cfg->pmrctl, cfg->mmio32);
6771 if (err)
6772 return err;
6773 }
6774
6775 if (argconfig_parse_seen(opts, "pmrmscl")) {
6776 err = nvme_set_register(hdl, bar, NVME_REG_PMRMSCL, cfg->pmrmscl, cfg->mmio32);
6777 if (err)
6778 return err;
6779 }
6780
6781 if (argconfig_parse_seen(opts, "pmrmscu")) {
6782 err = nvme_set_register(hdl, bar, NVME_REG_PMRMSCU, cfg->pmrmscu, cfg->mmio32);
6783 if (err)
6784 return err;
6785 }
6786
6787 return 0;
6788}
6789
6790static int set_register(int argc, char **argv, struct command *acmd, struct plugin *plugin)
6791{
6792 const char *desc = "Writes and shows the defined NVMe controller register";
6793 const char *value = "the value of the register to be set";
6794 const char *mmio32 = "Access 64-bit registers as 2 32-bit";
6795
6796 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
6797 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
6798 int err;
6799 void *bar;
6800
6801 struct set_reg_config cfg = {
6802 .offset = -1,
6803 };
6804
6805 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6806 OPT_UINT("offset", 'O', &cfg.offset, offset),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6807 OPT_SUFFIX("value", 'V', &cfg.value, value),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6808 OPT_FLAG("mmio32", 'm', &cfg.mmio32, mmio32),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6809 OPT_UINT("intms", 0, &cfg.intms, intms),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6810 OPT_UINT("intmc", 0, &cfg.intmc, intmc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6811 OPT_UINT("cc", 0, &cfg.cc, cc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6812 OPT_UINT("csts", 0, &cfg.csts, csts),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6813 OPT_UINT("nssr", 0, &cfg.nssr, nssr),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6814 OPT_UINT("aqa", 0, &cfg.aqa, aqa),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6815 OPT_SUFFIX("asq", 0, &cfg.asq, asq),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6816 OPT_SUFFIX("acq", 0, &cfg.acq, acq),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6817 OPT_UINT("bprsel", 0, &cfg.bprsel, bprsel),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6818 OPT_SUFFIX("bpmbl", 0, &cfg.bpmbl, bpmbl),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6819 OPT_SUFFIX("cmbmsc", 0, &cfg.cmbmsc, cmbmsc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6820 OPT_UINT("nssd", 0, &cfg.nssd, nssd),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6821 OPT_UINT("pmrctl", 0, &cfg.pmrctl, pmrctl),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6822 OPT_UINT("pmrmscl", 0, &cfg.pmrmscl, pmrmscl),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6823 OPT_UINT("pmrmscu", 0, &cfg.pmrmscu, pmrmscu))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "IONUM", CFG_LONG_SUFFIX, &
cfg.value, 1, value, 0, }, {"mmio32", 'm', ((void*)0), CFG_FLAG
, &cfg.mmio32, 0, mmio32, 0, }, {"intms", 0, "NUM", CFG_POSITIVE
, &cfg.intms, 1, intms, 0, }, {"intmc", 0, "NUM", CFG_POSITIVE
, &cfg.intmc, 1, intmc, 0, }, {"cc", 0, "NUM", CFG_POSITIVE
, &cfg.cc, 1, cc, 0, }, {"csts", 0, "NUM", CFG_POSITIVE, &
cfg.csts, 1, csts, 0, }, {"nssr", 0, "NUM", CFG_POSITIVE, &
cfg.nssr, 1, nssr, 0, }, {"aqa", 0, "NUM", CFG_POSITIVE, &
cfg.aqa, 1, aqa, 0, }, {"asq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.asq, 1, asq, 0, }, {"acq", 0, "IONUM", CFG_LONG_SUFFIX, &
cfg.acq, 1, acq, 0, }, {"bprsel", 0, "NUM", CFG_POSITIVE, &
cfg.bprsel, 1, bprsel, 0, }, {"bpmbl", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.bpmbl, 1, bpmbl, 0, }, {"cmbmsc", 0, "IONUM", CFG_LONG_SUFFIX
, &cfg.cmbmsc, 1, cmbmsc, 0, }, {"nssd", 0, "NUM", CFG_POSITIVE
, &cfg.nssd, 1, nssd, 0, }, {"pmrctl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrctl, 1, pmrctl, 0, }, {"pmrmscl", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscl, 1, pmrmscl, 0, }, {"pmrmscu", 0, "NUM", CFG_POSITIVE
, &cfg.pmrmscu, 1, pmrmscu, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
6824
6825 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
6826 if (err)
6827 return err;
6828
6829 if (libnvme_transport_handle_is_ns(hdl)) {
6830 nvme_show_error(only_ctrl_dev)nvme_show_message(1, only_ctrl_dev);
6831 return -EINVAL22;
6832 }
6833
6834 bar = mmap_registers(hdl, true1);
6835
6836 if (argconfig_parse_seen(opts, "offset"))
6837 err = set_register_offset(hdl, bar, opts, &cfg);
6838
6839 if (!err)
6840 err = set_register_names(hdl, bar, opts, &cfg);
6841
6842 if (bar)
6843 munmap_registers(bar);
6844
6845 return err;
6846}
6847
6848static int get_property(int argc, char **argv, struct command *acmd, struct plugin *plugin)
6849{
6850 const char *desc = "Reads and shows the defined NVMe controller property\n"
6851 "for NVMe over Fabric. Property offset must be one of:\n"
6852 "CAP=0x0, VS=0x8, CC=0x14, CSTS=0x1c, NSSR=0x20, NSSD=0x64, CRTO=0x68";
6853 const char *offset = "offset of the requested property";
6854
6855 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
6856 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
6857 __u64 value;
6858 int err;
6859 nvme_print_flags_t flags = NORMAL;
6860
6861 struct get_reg_config cfg = {
6862 .offset = -1,
6863 .fabrics = true1,
6864 };
6865
6866 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6867 OPT_UINT("offset", 'O', &cfg.offset, offset))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
6868
6869 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
6870 if (err)
6871 return err;
6872
6873 err = validate_output_format(nvme_args.output_format, &flags);
6874 if (err < 0) {
6875 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
6876 return err;
6877 }
6878
6879 if (cfg.offset == -1) {
6880 nvme_show_error("offset required param")nvme_show_message(1, "offset required param");
6881 return -EINVAL22;
6882 }
6883
6884 if (nvme_args.verbose)
6885 flags |= VERBOSE;
6886
6887 err = nvme_get_single_property(hdl, &cfg, &value);
6888 if (!err)
6889 nvme_show_single_property(cfg.offset, value, flags);
6890
6891 return err;
6892}
6893
6894static int set_property(int argc, char **argv, struct command *acmd, struct plugin *plugin)
6895{
6896 const char *desc =
6897 "Writes and shows the defined NVMe controller property for NVMe over Fabric";
6898 const char *offset = "the offset of the property";
6899 const char *value = "the value of the property to be set";
6900
6901 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
6902 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
6903 int err;
6904 nvme_print_flags_t flags;
6905
6906 struct set_reg_config cfg = {
6907 .offset = -1,
6908 .value = -1,
6909 };
6910
6911 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "NUM", CFG_POSITIVE, &cfg.
value, 1, value, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6912 OPT_UINT("offset", 'O', &cfg.offset, offset),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "NUM", CFG_POSITIVE, &cfg.
value, 1, value, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
6913 OPT_UINT("value", 'V', &cfg.value, value))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"offset", 'O', "NUM", CFG_POSITIVE, &cfg.offset, 1
, offset, 0, }, {"value", 'V', "NUM", CFG_POSITIVE, &cfg.
value, 1, value, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
6914
6915 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
6916 if (err)
6917 return err;
6918
6919 err = validate_output_format(nvme_args.output_format, &flags);
6920 if (err < 0) {
6921 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
6922 return err;
6923 }
6924
6925 if (cfg.offset == -1) {
6926 nvme_show_error("offset required param")nvme_show_message(1, "offset required param");
6927 return -EINVAL22;
6928 }
6929 if (cfg.value == -1) {
6930 nvme_show_error("value required param")nvme_show_message(1, "value required param");
6931 return -EINVAL22;
6932 }
6933
6934 return nvme_set_single_property(hdl, cfg.offset, cfg.value);
6935}
6936
6937static void show_relatives(const char *name, nvme_print_flags_t flags)
6938{
6939 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
6940 int err;
6941
6942 err = nvme_create_global_ctx(&ctx);
6943 if (err)
6944 return;
6945
6946 err = libnvme_scan_topology(ctx, NULL((void*)0), NULL((void*)0));
6947 if (err < 0) {
6948 handle_scan_topology_error(err);
6949 return;
6950 }
6951
6952 nvme_show_relatives(ctx, name, flags);
6953}
6954
6955static int format_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
6956{
6957 const char *desc = "Re-format a specified namespace on the\n"
6958 "given device. Can erase all data in namespace (user\n"
6959 "data erase) or delete data encryption key if specified.\n"
6960 "Can also be used to change LBAF to change the namespaces reported physical block format.";
6961 const char *lbaf = "LBA format to apply (required)";
6962 const char *ses = "[0-2]: secure erase";
6963 const char *pil = "[0-1]: protection info location last/first bytes of metadata";
6964 const char *pi = "[0-3]: protection info off/Type 1/Type 2/Type 3";
6965 const char *mset = "[0-1]: extended format off/on";
6966 const char *reset = "Automatically reset the controller after successful format";
6967 const char *bs = "target block size";
6968 const char *force = "The \"I know what I'm doing\" flag, skip confirmation before sending command";
6969
6970 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
6971 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
6972 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
6973 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
6974 nvme_print_flags_t flags = NORMAL;
6975 struct libnvme_passthru_cmd cmd;
6976 __u8 prev_lbaf = 0;
6977 int block_size;
6978 int err, i;
6979
6980 struct config {
6981 bool_Bool ish;
6982 __u32 namespace_id;
6983 __u8 lbaf;
6984 __u8 ses;
6985 __u8 pi;
6986 __u8 pil;
6987 __u8 mset;
6988 bool_Bool reset;
6989 bool_Bool force;
6990 __u64 bs;
6991 };
6992
6993 struct config cfg = {
6994 .ish = false0,
6995 .namespace_id = 0,
6996 .lbaf = 0xff,
6997 .ses = 0,
6998 .pi = 0,
6999 .pil = 0,
7000 .mset = 0,
7001 .reset = false0,
7002 .force = false0,
7003 .bs = 0,
7004 };
7005
7006 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7007 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7008 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7009 OPT_BYTE("lbaf", 'l', &cfg.lbaf, lbaf),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7010 OPT_BYTE("ses", 's', &cfg.ses, ses),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7011 OPT_BYTE("pi", 'i', &cfg.pi, pi),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7012 OPT_BYTE("pil", 'p', &cfg.pil, pil),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7013 OPT_BYTE("ms", 'm', &cfg.mset, mset),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7014 OPT_FLAG("reset", 'r', &cfg.reset, reset),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7015 OPT_FLAG("force", 0, &cfg.force, force),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7016 OPT_SUFFIX("block-size", 'b', &cfg.bs, bs))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"lbaf", 'l', "NUM", CFG_BYTE
, &cfg.lbaf, 1, lbaf, 0, }, {"ses", 's', "NUM", CFG_BYTE,
&cfg.ses, 1, ses, 0, }, {"pi", 'i', "NUM", CFG_BYTE, &
cfg.pi, 1, pi, 0, }, {"pil", 'p', "NUM", CFG_BYTE, &cfg.pil
, 1, pil, 0, }, {"ms", 'm', "NUM", CFG_BYTE, &cfg.mset, 1
, mset, 0, }, {"reset", 'r', ((void*)0), CFG_FLAG, &cfg.reset
, 0, reset, 0, }, {"force", 0, ((void*)0), CFG_FLAG, &cfg
.force, 0, force, 0, }, {"block-size", 'b', "IONUM", CFG_LONG_SUFFIX
, &cfg.bs, 1, bs, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
7017
7018 /* set default timeout for format to 60 seconds */
7019 nvme_args.timeout = 600000;
7020
7021 err = parse_args(argc, argv, desc, opts);
7022 if (err)
7023 return err;
7024
7025 err = open_exclusive(&ctx, &hdl, argc, argv, cfg.force, opts);
7026 if (err) {
7027 if (-err == EBUSY16) {
7028 nvme_show_error("Failed to open %s.", basename(argv[optind]))nvme_show_message(1, "Failed to open %s.", __xpg_basename(argv
[optind]))
;
7029 nvme_show_error("Namespace is currently busy.")nvme_show_message(1, "Namespace is currently busy.");
7030 if (!cfg.force)
7031 nvme_show_error("Use the force [--force] option to ignore that.")nvme_show_message(1, "Use the force [--force] option to ignore that."
)
;
7032 } else {
7033 argconfig_print_help(desc, opts);
7034 }
7035 return err;
7036 }
7037
7038 err = validate_output_format(nvme_args.output_format, &flags);
7039 if (err < 0) {
7040 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
7041 return err;
7042 }
7043
7044 if (cfg.lbaf != 0xff && cfg.bs != 0) {
7045 nvme_show_error(nvme_show_message(1, "Invalid specification of both LBAF and Block Size, please specify only one"
)
7046 "Invalid specification of both LBAF and Block Size, please specify only one")nvme_show_message(1, "Invalid specification of both LBAF and Block Size, please specify only one"
)
;
7047 return -EINVAL22;
7048 }
7049 if (cfg.bs) {
7050 if ((cfg.bs & (~cfg.bs + 1)) != cfg.bs) {
7051 nvme_show_error(nvme_show_message(1, "Invalid value for block size (%""l" "u"
"), must be a power of two", (uint64_t) cfg.bs)
7052 "Invalid value for block size (%"PRIu64"), must be a power of two",nvme_show_message(1, "Invalid value for block size (%""l" "u"
"), must be a power of two", (uint64_t) cfg.bs)
7053 (uint64_t) cfg.bs)nvme_show_message(1, "Invalid value for block size (%""l" "u"
"), must be a power of two", (uint64_t) cfg.bs)
;
7054 return -EINVAL22;
7055 }
7056 }
7057
7058 ctrl = libnvme_alloc(sizeof(*ctrl));
7059 if (!ctrl)
7060 return -ENOMEM12;
7061
7062 err = nvme_identify_ctrl(hdl, ctrl);
7063 if (err) {
7064 nvme_show_error("identify-ctrl: %s", libnvme_strerror(err))nvme_show_message(1, "identify-ctrl: %s", libnvme_strerror(err
))
;
7065 return -errno(*__errno_location ());
7066 }
7067
7068 if (ctrl->fna & NVME_CTRL_FNA_FMT_ALL_NAMESPACES) {
7069 /*
7070 * FNA bit 0 set to 1: all namespaces ... shall be configured with the same
7071 * attributes and a format (excluding secure erase) of any namespace results in a
7072 * format of all namespaces.
7073 */
7074 cfg.namespace_id = NVME_NSID_ALL;
7075 } else if (!cfg.namespace_id) {
7076 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
7077 if (err < 0) {
7078 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
7079 return -errno(*__errno_location ());
7080 }
7081 }
7082
7083 if (cfg.namespace_id == 0) {
7084 nvme_show_error(nvme_show_message(1, "Invalid namespace ID, specify a namespace to format or use\n"
"'-n 0xffffffff' to format all namespaces on this controller."
)
7085 "Invalid namespace ID, specify a namespace to format or use\n"nvme_show_message(1, "Invalid namespace ID, specify a namespace to format or use\n"
"'-n 0xffffffff' to format all namespaces on this controller."
)
7086 "'-n 0xffffffff' to format all namespaces on this controller.")nvme_show_message(1, "Invalid namespace ID, specify a namespace to format or use\n"
"'-n 0xffffffff' to format all namespaces on this controller."
)
;
7087 return -EINVAL22;
7088 }
7089
7090 if (cfg.namespace_id != NVME_NSID_ALL) {
7091 ns = libnvme_alloc(sizeof(*ns));
7092 if (!ns)
7093 return -ENOMEM12;
7094
7095 err = nvme_identify_ns(hdl, cfg.namespace_id, ns);
7096 if (err) {
7097 if (err > 0)
7098 nvme_show_error("identify failed")nvme_show_message(1, "identify failed");
7099 nvme_show_err(err, "identify-namespace");
7100 return err;
7101 }
7102
7103 nvme_id_ns_flbas_to_lbaf_inuse(ns->flbas, &prev_lbaf);
7104
7105 if (cfg.bs) {
7106 for (i = 0; i <= ns->nlbaf; ++i) {
7107 if ((1ULL << ns->lbaf[i].ds) == cfg.bs && ns->lbaf[i].ms == 0) {
7108 cfg.lbaf = i;
7109 break;
7110 }
7111 }
7112 if (cfg.lbaf == 0xff) {
7113 nvme_show_error(nvme_show_message(1, "LBAF corresponding to given block size %"
"l" "u"" not found", (uint64_t)cfg.bs)
7114 "LBAF corresponding to given block size %"PRIu64" not found",nvme_show_message(1, "LBAF corresponding to given block size %"
"l" "u"" not found", (uint64_t)cfg.bs)
7115 (uint64_t)cfg.bs)nvme_show_message(1, "LBAF corresponding to given block size %"
"l" "u"" not found", (uint64_t)cfg.bs)
;
7116 nvme_show_error(nvme_show_message(1, "Please correct block size, or specify LBAF directly"
)
7117 "Please correct block size, or specify LBAF directly")nvme_show_message(1, "Please correct block size, or specify LBAF directly"
)
;
7118 return -EINVAL22;
7119 }
7120 } else if (cfg.lbaf == 0xff) {
7121 cfg.lbaf = prev_lbaf;
7122 }
7123 } else {
7124 if (cfg.lbaf == 0xff)
7125 cfg.lbaf = 0;
7126 }
7127
7128 /* ses & pi checks set to 7 for forward-compatibility */
7129 if (cfg.ses > 7) {
7130 nvme_show_error("invalid secure erase settings:%d", cfg.ses)nvme_show_message(1, "invalid secure erase settings:%d", cfg.
ses)
;
7131 return -EINVAL22;
7132 }
7133 if (cfg.lbaf > 63) {
7134 nvme_show_error("invalid lbaf:%d", cfg.lbaf)nvme_show_message(1, "invalid lbaf:%d", cfg.lbaf);
7135 return -EINVAL22;
7136 }
7137 if (cfg.pi > 7) {
7138 nvme_show_error("invalid pi:%d", cfg.pi)nvme_show_message(1, "invalid pi:%d", cfg.pi);
7139 return -EINVAL22;
7140 }
7141 if (cfg.pil > 1) {
7142 nvme_show_error("invalid pil:%d", cfg.pil)nvme_show_message(1, "invalid pil:%d", cfg.pil);
7143 return -EINVAL22;
7144 }
7145 if (cfg.mset > 1) {
7146 nvme_show_error("invalid mset:%d", cfg.mset)nvme_show_message(1, "invalid mset:%d", cfg.mset);
7147 return -EINVAL22;
7148 }
7149
7150 if (!cfg.force) {
7151 nvme_show_error("You are about to format %s, namespace %#x%s.",nvme_show_message(1, "You are about to format %s, namespace %#x%s."
, libnvme_transport_handle_get_name(hdl), cfg.namespace_id, cfg
.namespace_id == NVME_NSID_ALL ? "(ALL namespaces)" : "")
7152 libnvme_transport_handle_get_name(hdl), cfg.namespace_id,nvme_show_message(1, "You are about to format %s, namespace %#x%s."
, libnvme_transport_handle_get_name(hdl), cfg.namespace_id, cfg
.namespace_id == NVME_NSID_ALL ? "(ALL namespaces)" : "")
7153 cfg.namespace_id == NVME_NSID_ALL ? "(ALL namespaces)" : "")nvme_show_message(1, "You are about to format %s, namespace %#x%s."
, libnvme_transport_handle_get_name(hdl), cfg.namespace_id, cfg
.namespace_id == NVME_NSID_ALL ? "(ALL namespaces)" : "")
;
7154 show_relatives(libnvme_transport_handle_get_name(hdl), flags);
7155 nvme_show_error(nvme_show_message(1, "WARNING: Format may irrevocably delete this device's data.\n"
"You have 10 seconds to press Ctrl-C to cancel this operation.\n\n"
"Use the force [--force] option to suppress this warning.")
7156 "WARNING: Format may irrevocably delete this device's data.\n"nvme_show_message(1, "WARNING: Format may irrevocably delete this device's data.\n"
"You have 10 seconds to press Ctrl-C to cancel this operation.\n\n"
"Use the force [--force] option to suppress this warning.")
7157 "You have 10 seconds to press Ctrl-C to cancel this operation.\n\n"nvme_show_message(1, "WARNING: Format may irrevocably delete this device's data.\n"
"You have 10 seconds to press Ctrl-C to cancel this operation.\n\n"
"Use the force [--force] option to suppress this warning.")
7158 "Use the force [--force] option to suppress this warning.")nvme_show_message(1, "WARNING: Format may irrevocably delete this device's data.\n"
"You have 10 seconds to press Ctrl-C to cancel this operation.\n\n"
"Use the force [--force] option to suppress this warning.")
;
7159 shr_sigint_received = false0;
7160 sleep(10);
7161 if (shr_sigint_received)
7162 return -EINTR4;
7163 nvme_show_verbose_info("Sending format operation ...")nvme_show_verbose_message("Sending format operation ...");
7164 }
7165
7166 nvme_init_format_nvm(&cmd, cfg.namespace_id, cfg.lbaf, cfg.mset,
7167 cfg.pi, cfg.pil, cfg.ses);
7168 if (cfg.ish) {
7169 if (libnvme_transport_handle_is_mi(hdl))
7170 nvme_init_mi_cmd_flags(&cmd, ish);
7171 else
7172 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
7173 }
7174 err = libnvme_exec_admin_passthru(hdl, &cmd);
7175 if (err) {
7176 nvme_show_err(err, "format");
7177 return err;
7178 }
7179
7180 nvme_show_verbose_result("Success formatting namespace:%x", cfg.namespace_id)nvme_show_verbose_message("Success formatting namespace:%x", cfg
.namespace_id)
;
7181 if (libnvme_transport_handle_is_direct(hdl) && cfg.lbaf != prev_lbaf) {
7182 if (libnvme_transport_handle_is_ctrl(hdl)) {
7183 if (libnvme_rescan_ns(hdl) < 0) {
7184 nvme_show_error("failed to rescan namespaces")nvme_show_message(1, "failed to rescan namespaces");
7185 return -errno(*__errno_location ());
7186 }
7187 } else if (cfg.namespace_id != NVME_NSID_ALL) {
7188 block_size = 1 << ns->lbaf[cfg.lbaf].ds;
7189
7190 /*
7191 * If block size has been changed by the format
7192 * command up there, we should notify it to
7193 * kernel blkdev to update its own block size
7194 * to the given one because blkdev will not
7195 * update by itself without re-opening fd.
7196 */
7197 err = libnvme_update_block_size(hdl, block_size);
7198 if (err < 0) {
7199 nvme_show_error(nvme_show_message(1, "failed to set block size to %d", block_size
)
7200 "failed to set block size to %d",nvme_show_message(1, "failed to set block size to %d", block_size
)
7201 block_size)nvme_show_message(1, "failed to set block size to %d", block_size
)
;
7202 return err;
7203 }
7204 }
7205 }
7206 if (libnvme_transport_handle_is_direct(hdl) && cfg.reset &&
7207 libnvme_transport_handle_is_ctrl(hdl))
7208 libnvme_reset_ctrl(hdl);
7209
7210 return err;
7211}
7212
7213#define STRTOUL_AUTO_BASE(0) (0)
7214#define NVME_FEAT_TIMESTAMP_DATA_SIZE(6) (6)
7215
7216static int set_feature(int argc, char **argv, struct command *acmd, struct plugin *plugin)
7217{
7218 const char *desc = "Modify the saveable or changeable "
7219 "current operating parameters of the controller. "
7220 "Operating parameters are grouped and identified by Feature"
7221 "Identifiers. Feature settings can be applied to the entire"
7222 "controller and all associated namespaces, or to only a few"
7223 "namespace(s) associated with the controller. Default values"
7224 "for each Feature are vendor-specific and may not be modified."
7225 "Use get-feature to determine which Features are supported by"
7226 "the controller and are saveable/changeable.";
7227 const char *fid = "feature identifier (required)";
7228 const char *data = "optional file for feature data (default stdin)";
7229 const char *value = "new value of feature (required)";
7230 const char *cdw12 = "feature cdw12, if used";
7231 const char *sv = "specifies that the controller shall save the attribute";
7232
7233 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
7234 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
7235 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *buf = NULL((void*)0);
7236 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int ffd = STDIN_FILENO0;
7237 int err;
7238 __u64 result;
7239 nvme_print_flags_t flags;
7240
7241 struct config {
7242 __u32 nsid;
7243 __u8 fid;
7244 __u64 value;
7245 __u32 cdw12;
7246 __u8 uidx;
7247 __u32 data_len;
7248 char *file;
7249 bool_Bool sv;
7250 };
7251
7252 struct config cfg = {
7253 .nsid = 0,
7254 .fid = 0,
7255 .value = 0,
7256 .uidx = 0,
7257 .data_len = 0,
7258 .file = "",
7259 .sv = false0,
7260 };
7261
7262 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7263 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7264 OPT_BYTE("feature-id", 'f', &cfg.fid, fid, feature_name),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7265 OPT_SUFFIX("value", 'V', &cfg.value, value),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7266 OPT_UINT("cdw12", 'c', &cfg.cdw12, cdw12),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7267 OPT_BYTE("uuid-index", 'U', &cfg.uidx, uuid_index_specify),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7268 OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7269 OPT_FILE("data", 'd', &cfg.file, data),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7270 OPT_FLAG("save", 's', &cfg.sv, sv))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"feature-id", 'f', "NUM", CFG_BYTE
, &cfg.fid, 1, fid, 0, feature_name}, {"value", 'V', "IONUM"
, CFG_LONG_SUFFIX, &cfg.value, 1, value, 0, }, {"cdw12", 'c'
, "NUM", CFG_POSITIVE, &cfg.cdw12, 1, cdw12, 0, }, {"uuid-index"
, 'U', "NUM", CFG_BYTE, &cfg.uidx, 1, uuid_index_specify,
0, }, {"data-len", 'l', "NUM", CFG_POSITIVE, &cfg.data_len
, 1, buf_len, 0, }, {"data", 'd', "FILE", CFG_STRING, &cfg
.file, 1, data, 0, }, {"save", 's', ((void*)0), CFG_FLAG, &
cfg.sv, 0, sv, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR,
((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose",
'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
7271
7272 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
7273 if (err)
7274 return err;
7275
7276 err = validate_output_format(nvme_args.output_format, &flags);
7277 if (err < 0) {
7278 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
7279 return err;
7280 }
7281
7282 if (!argconfig_parse_seen(opts, "namespace-id")) {
7283 err = libnvme_get_nsid(hdl, &cfg.nsid);
7284 if (err < 0) {
7285 if (errno(*__errno_location ()) != ENOTTY25) {
7286 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
7287 return -errno(*__errno_location ());
7288 }
7289 cfg.nsid = NVME_NSID_ALL;
7290 }
7291 }
7292
7293 if (!cfg.fid) {
7294 nvme_show_error("feature-id required param")nvme_show_message(1, "feature-id required param");
7295 return -EINVAL22;
7296 }
7297
7298 if (cfg.uidx > 127) {
7299 nvme_show_error("invalid uuid index param: %u", cfg.uidx)nvme_show_message(1, "invalid uuid index param: %u", cfg.uidx
)
;
7300 return -1;
7301 }
7302
7303 if (!cfg.data_len)
7304 libnvme_get_feature_length(cfg.fid, cfg.value,
7305 NVME_DATA_TFR_HOST_TO_CTRL,
7306 &cfg.data_len);
7307
7308 if (cfg.data_len) {
7309 buf = libnvme_alloc(cfg.data_len);
7310 if (!buf)
7311 return -ENOMEM12;
7312 }
7313
7314 if (buf) {
7315 /*
7316 * Use the '-v' value for the timestamp feature if provided as
7317 * a convenience since it can often fit in 4-bytes. The user
7318 * should use the buffer method if the value exceeds this
7319 * length.
7320 */
7321 if (cfg.fid == NVME_FEAT_FID_TIMESTAMP &&
7322 argconfig_parse_seen(opts, "value")) {
7323 memcpy(buf, &cfg.value, NVME_FEAT_TIMESTAMP_DATA_SIZE(6));
7324 } else {
7325 if (strlen(cfg.file))
7326 ffd = nvme_open_rawdata(cfg.file, O_RDONLY)open((cfg.file), (00));
7327
7328 if (ffd < 0) {
7329 nvme_show_error("Failed to open file %s: %s",nvme_show_message(1, "Failed to open file %s: %s", cfg.file, libnvme_strerror
((*__errno_location ())))
7330 cfg.file, libnvme_strerror(errno))nvme_show_message(1, "Failed to open file %s: %s", cfg.file, libnvme_strerror
((*__errno_location ())))
;
7331 return -EINVAL22;
7332 }
7333
7334 err = read(ffd, buf, cfg.data_len);
7335 if (err < 0) {
7336 nvme_show_error("failed to read data buffer from input file: %s",nvme_show_message(1, "failed to read data buffer from input file: %s"
, libnvme_strerror((*__errno_location ())))
7337 libnvme_strerror(errno))nvme_show_message(1, "failed to read data buffer from input file: %s"
, libnvme_strerror((*__errno_location ())))
;
7338 return -errno(*__errno_location ());
7339 }
7340 }
7341 }
7342
7343 err = nvme_set_features(hdl, cfg.nsid, cfg.fid, cfg.sv, cfg.value, cfg.cdw12,
7344 0, cfg.uidx, 0, buf, cfg.data_len, &result);
7345 if (err) {
7346 nvme_show_admin_cmd_err("set-feature", nvme_admin_set_features,
7347 err);
7348 return err;
7349 }
7350
7351 nvme_show_result("set-feature:%#0*x (%s), value:%#0*" PRIx64nvme_show_message(0, "set-feature:%#0*x (%s), value:%#0*" "l"
"x" ", cdw12:%#0*x, save:%#x", cfg.fid ? 4 : 2, cfg.fid, nvme_feature_to_string
(cfg.fid), cfg.value ? 10 : 8, (uint64_t)cfg.value, cfg.cdw12
? 10 : 8, cfg.cdw12, cfg.sv)
7352 ", cdw12:%#0*x, save:%#x", cfg.fid ? 4 : 2, cfg.fid,nvme_show_message(0, "set-feature:%#0*x (%s), value:%#0*" "l"
"x" ", cdw12:%#0*x, save:%#x", cfg.fid ? 4 : 2, cfg.fid, nvme_feature_to_string
(cfg.fid), cfg.value ? 10 : 8, (uint64_t)cfg.value, cfg.cdw12
? 10 : 8, cfg.cdw12, cfg.sv)
7353 nvme_feature_to_string(cfg.fid), cfg.value ? 10 : 8,nvme_show_message(0, "set-feature:%#0*x (%s), value:%#0*" "l"
"x" ", cdw12:%#0*x, save:%#x", cfg.fid ? 4 : 2, cfg.fid, nvme_feature_to_string
(cfg.fid), cfg.value ? 10 : 8, (uint64_t)cfg.value, cfg.cdw12
? 10 : 8, cfg.cdw12, cfg.sv)
7354 (uint64_t)cfg.value, cfg.cdw12 ? 10 : 8, cfg.cdw12, cfg.sv)nvme_show_message(0, "set-feature:%#0*x (%s), value:%#0*" "l"
"x" ", cdw12:%#0*x, save:%#x", cfg.fid ? 4 : 2, cfg.fid, nvme_feature_to_string
(cfg.fid), cfg.value ? 10 : 8, (uint64_t)cfg.value, cfg.cdw12
? 10 : 8, cfg.cdw12, cfg.sv)
;
7355 if (cfg.fid == NVME_FEAT_FID_LBA_STS_INTERVAL)
7356 nvme_show_lba_status_info(result);
7357 if (buf) {
7358 if (cfg.fid == NVME_FEAT_FID_LBA_RANGE)
7359 nvme_show_lba_range((struct nvme_lba_range_type *)buf,
7360 result, 0);
7361 else
7362 d(buf, cfg.data_len, 16, 1);
7363 }
7364
7365 return err;
7366}
7367
7368static int sec_send(int argc, char **argv, struct command *acmd, struct plugin *plugin)
7369{
7370 struct stat sb;
7371 const char *desc = "Transfer security protocol data to\n"
7372 "a controller. Security Receives for the same protocol should be\n"
7373 "performed after Security Sends. The security protocol field\n"
7374 "associates Security Sends (security-send) and Security Receives (security-recv).";
7375 const char *file = "transfer payload";
7376 const char *tl = "transfer length (cf. SPC-4)";
7377
7378 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
7379 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
7380 struct libnvme_passthru_cmd cmd;
7381 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *sec_buf = NULL((void*)0);
7382 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int sec_fd = -1;
7383 unsigned int sec_size;
7384 int err;
7385 nvme_print_flags_t flags;
7386
7387 struct config {
7388 bool_Bool ish;
7389 __u32 namespace_id;
7390 char *file;
7391 __u8 nssf;
7392 __u8 secp;
7393 __u16 spsp;
7394 __u32 tl;
7395 };
7396
7397 struct config cfg = {
7398 .ish = false0,
7399 .namespace_id = 0,
7400 .file = "",
7401 .nssf = 0,
7402 .secp = 0,
7403 .spsp = 0,
7404 .tl = 0,
7405 };
7406
7407 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"file", 'f', "FILE", CFG_STRING
, &cfg.file, 1, file, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"tl", 't', "NUM", CFG_POSITIVE
, &cfg.tl, 1, tl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7408 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"file", 'f', "FILE", CFG_STRING
, &cfg.file, 1, file, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"tl", 't', "NUM", CFG_POSITIVE
, &cfg.tl, 1, tl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7409 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"file", 'f', "FILE", CFG_STRING
, &cfg.file, 1, file, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"tl", 't', "NUM", CFG_POSITIVE
, &cfg.tl, 1, tl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7410 OPT_FILE("file", 'f', &cfg.file, file),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"file", 'f', "FILE", CFG_STRING
, &cfg.file, 1, file, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"tl", 't', "NUM", CFG_POSITIVE
, &cfg.tl, 1, tl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7411 OPT_BYTE("nssf", 'N', &cfg.nssf, nssf),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"file", 'f', "FILE", CFG_STRING
, &cfg.file, 1, file, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"tl", 't', "NUM", CFG_POSITIVE
, &cfg.tl, 1, tl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7412 OPT_BYTE("secp", 'p', &cfg.secp, secp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"file", 'f', "FILE", CFG_STRING
, &cfg.file, 1, file, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"tl", 't', "NUM", CFG_POSITIVE
, &cfg.tl, 1, tl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7413 OPT_SHRT("spsp", 's', &cfg.spsp, spsp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"file", 'f', "FILE", CFG_STRING
, &cfg.file, 1, file, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"tl", 't', "NUM", CFG_POSITIVE
, &cfg.tl, 1, tl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7414 OPT_UINT("tl", 't', &cfg.tl, tl))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"file", 'f', "FILE", CFG_STRING
, &cfg.file, 1, file, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"tl", 't', "NUM", CFG_POSITIVE
, &cfg.tl, 1, tl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
7415
7416 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
7417 if (err)
7418 return err;
7419
7420 err = validate_output_format(nvme_args.output_format, &flags);
7421 if (err < 0) {
7422 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
7423 return err;
7424 }
7425
7426 if (cfg.tl == 0) {
7427 nvme_show_error("--tl unspecified or zero")nvme_show_message(1, "--tl unspecified or zero");
7428 return -EINVAL22;
7429 }
7430 if ((cfg.tl & 3) != 0)
7431 nvme_show_error(nvme_show_message(1, "WARNING: --tl not dword aligned; unaligned bytes may be truncated"
)
7432 "WARNING: --tl not dword aligned; unaligned bytes may be truncated")nvme_show_message(1, "WARNING: --tl not dword aligned; unaligned bytes may be truncated"
)
;
7433
7434 if (strlen(cfg.file) == 0) {
7435 sec_fd = STDIN_FILENO0;
7436 sec_size = cfg.tl;
7437 } else {
7438 sec_fd = nvme_open_rawdata(cfg.file, O_RDONLY)open((cfg.file), (00));
7439 if (sec_fd < 0) {
7440 nvme_show_error("Failed to open %s: %s", cfg.file, libnvme_strerror(errno))nvme_show_message(1, "Failed to open %s: %s", cfg.file, libnvme_strerror
((*__errno_location ())))
;
7441 return -EINVAL22;
7442 }
7443
7444 err = fstat(sec_fd, &sb);
7445 if (err < 0) {
7446 nvme_show_perror("fstat");
7447 return err;
7448 }
7449
7450 sec_size = cfg.tl > sb.st_size ? cfg.tl : sb.st_size;
7451 }
7452
7453 sec_buf = libnvme_alloc(cfg.tl);
7454 if (!sec_buf)
7455 return -ENOMEM12;
7456
7457 err = read(sec_fd, sec_buf, sec_size);
7458 if (err < 0) {
7459 nvme_show_error("Failed to read data from security file %s with %s", cfg.file,nvme_show_message(1, "Failed to read data from security file %s with %s"
, cfg.file, libnvme_strerror((*__errno_location ())))
7460 libnvme_strerror(errno))nvme_show_message(1, "Failed to read data from security file %s with %s"
, cfg.file, libnvme_strerror((*__errno_location ())))
;
7461 return -errno(*__errno_location ());
7462 }
7463
7464 nvme_init_security_send(&cmd, cfg.namespace_id, cfg.nssf, cfg.spsp,
7465 cfg.secp, cfg.tl, sec_buf, cfg.tl);
7466 if (cfg.ish) {
7467 if (libnvme_transport_handle_is_mi(hdl))
7468 nvme_init_mi_cmd_flags(&cmd, ish);
7469 else
7470 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
7471 }
7472 err = libnvme_exec_admin_passthru(hdl, &cmd);
7473 if (err) {
7474 nvme_show_err(err, "security-send");
7475 return err;
7476 }
7477
7478 nvme_show_verbose_result("NVME Security Send Command Success")nvme_show_verbose_message("NVME Security Send Command Success"
)
;
7479
7480 return err;
7481}
7482
7483static int dir_send(int argc, char **argv, struct command *acmd, struct plugin *plugin)
7484{
7485 const char *desc = "Set directive parameters of the specified directive type.";
7486 const char *endir = "directive enable";
7487 const char *ttype = "target directive type to be enabled/disabled";
7488 const char *input = "write/send file (default stdin)";
7489
7490 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
7491 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
7492 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *buf = NULL((void*)0);
7493 struct libnvme_passthru_cmd cmd;
7494 __u32 dw12 = 0;
7495 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int ffd = STDIN_FILENO0;
7496 int err;
7497
7498 struct config {
7499 __u32 namespace_id;
7500 __u32 data_len;
7501 __u8 dtype;
7502 __u8 ttype;
7503 __u16 dspec;
7504 __u8 doper;
7505 __u16 endir;
7506 bool_Bool raw_binary;
7507 char *file;
7508 };
7509
7510 struct config cfg = {
7511 .namespace_id = 1,
7512 .data_len = 0,
7513 .dtype = 0,
7514 .ttype = 0,
7515 .dspec = 0,
7516 .doper = 0,
7517 .endir = 1,
7518 .raw_binary = false0,
7519 .file = "",
7520 };
7521
7522 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7523 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7524 OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7525 OPT_BYTE("dir-type", 'D', &cfg.dtype, dtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7526 OPT_BYTE("target-dir", 'T', &cfg.ttype, ttype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7527 OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec_w_dtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7528 OPT_BYTE("dir-oper", 'O', &cfg.doper, doper),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7529 OPT_SHRT("endir", 'e', &cfg.endir, endir),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7530 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_directive),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7531 OPT_FILE("input-file", 'i', &cfg.file, input))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"dir-type", 'D', "NUM"
, CFG_BYTE, &cfg.dtype, 1, dtype, 0, }, {"target-dir", 'T'
, "NUM", CFG_BYTE, &cfg.ttype, 1, ttype, 0, }, {"dir-spec"
, 'S', "NUM", CFG_SHORT, &cfg.dspec, 1, dspec_w_dtype, 0,
}, {"dir-oper", 'O', "NUM", CFG_BYTE, &cfg.doper, 1, doper
, 0, }, {"endir", 'e', "NUM", CFG_SHORT, &cfg.endir, 1, endir
, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_directive, 0, }, {"input-file", 'i', "FILE", CFG_STRING
, &cfg.file, 1, input, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
7532
7533 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
7534 if (err)
7535 return err;
7536
7537 switch (cfg.dtype) {
7538 case NVME_DIRECTIVE_DTYPE_IDENTIFY:
7539 switch (cfg.doper) {
7540 case NVME_DIRECTIVE_SEND_IDENTIFY_DOPER_ENDIR:
7541 if (!cfg.ttype) {
7542 nvme_show_error("target-dir required param\n")nvme_show_message(1, "target-dir required param\n");
7543 return -EINVAL22;
7544 }
7545 dw12 = cfg.ttype << 8 | cfg.endir;
7546 break;
7547 default:
7548 nvme_show_error("invalid directive operations for Identify Directives")nvme_show_message(1, "invalid directive operations for Identify Directives"
)
;
7549 return -EINVAL22;
7550 }
7551 break;
7552 case NVME_DIRECTIVE_DTYPE_STREAMS:
7553 switch (cfg.doper) {
7554 case NVME_DIRECTIVE_SEND_STREAMS_DOPER_RELEASE_IDENTIFIER:
7555 case NVME_DIRECTIVE_SEND_STREAMS_DOPER_RELEASE_RESOURCE:
7556 break;
7557 default:
7558 nvme_show_error("invalid directive operations for Streams Directives")nvme_show_message(1, "invalid directive operations for Streams Directives"
)
;
7559 return -EINVAL22;
7560 }
7561 break;
7562 default:
7563 nvme_show_error("invalid directive type")nvme_show_message(1, "invalid directive type");
7564 return -EINVAL22;
7565 }
7566
7567 if (cfg.data_len) {
7568 buf = libnvme_alloc(cfg.data_len);
7569 if (!buf)
7570 return -ENOMEM12;
7571 }
7572
7573 if (buf) {
7574 if (strlen(cfg.file)) {
7575 ffd = nvme_open_rawdata(cfg.file, O_RDONLY)open((cfg.file), (00));
7576 if (ffd <= 0) {
7577 nvme_show_error("Failed to open file %s: %s",nvme_show_message(1, "Failed to open file %s: %s", cfg.file, libnvme_strerror
((*__errno_location ())))
7578 cfg.file, libnvme_strerror(errno))nvme_show_message(1, "Failed to open file %s: %s", cfg.file, libnvme_strerror
((*__errno_location ())))
;
7579 return -EINVAL22;
7580 }
7581 }
7582 err = read(ffd, (void *)buf, cfg.data_len);
7583 if (err < 0) {
7584 nvme_show_error(nvme_show_message(1, "failed to read data buffer from input file %s"
, libnvme_strerror((*__errno_location ())))
7585 "failed to read data buffer from input file %s",nvme_show_message(1, "failed to read data buffer from input file %s"
, libnvme_strerror((*__errno_location ())))
7586 libnvme_strerror(errno))nvme_show_message(1, "failed to read data buffer from input file %s"
, libnvme_strerror((*__errno_location ())))
;
7587 return -errno(*__errno_location ());
7588 }
7589 }
7590
7591 nvme_init_directive_send(&cmd, cfg.namespace_id, cfg.doper, cfg.dtype,
7592 cfg.dspec, buf, cfg.data_len);
7593 cmd.cdw12 = dw12;
7594 err = libnvme_exec_admin_passthru(hdl, &cmd);
7595 if (err) {
7596 nvme_show_err(err, "dir-send");
7597 return err;
7598 }
7599
7600 nvme_show_result(nvme_show_message(0, "%s: type %#x, operation %#x, spec_val %#x, nsid %#x, result %#"
"l" "x", __func__, cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id
, (uint64_t)cmd.result)
7601 "%s: type %#x, operation %#x, spec_val %#x, nsid %#x, result %#"nvme_show_message(0, "%s: type %#x, operation %#x, spec_val %#x, nsid %#x, result %#"
"l" "x", __func__, cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id
, (uint64_t)cmd.result)
7602 PRIx64, __func__, cfg.dtype, cfg.doper, cfg.dspec,nvme_show_message(0, "%s: type %#x, operation %#x, spec_val %#x, nsid %#x, result %#"
"l" "x", __func__, cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id
, (uint64_t)cmd.result)
7603 cfg.namespace_id, (uint64_t)cmd.result)nvme_show_message(0, "%s: type %#x, operation %#x, spec_val %#x, nsid %#x, result %#"
"l" "x", __func__, cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id
, (uint64_t)cmd.result)
;
7604
7605 if (buf) {
7606 if (!cfg.raw_binary)
7607 d(buf, cfg.data_len, 16, 1);
7608 else
7609 d_raw(buf, cfg.data_len);
7610 }
7611
7612 return err;
7613}
7614
7615static int write_uncor(int argc, char **argv, struct command *acmd, struct plugin *plugin)
7616{
7617 const char *desc =
7618 "The Write Uncorrectable command is used to set a range of logical blocks to invalid.";
7619
7620 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
7621 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
7622 struct libnvme_passthru_cmd cmd;
7623 int err;
7624
7625 struct config {
7626 __u32 namespace_id;
7627 __u64 start_block;
7628 __u16 block_count;
7629 __u8 dtype;
7630 __u16 dspec;
7631 };
7632
7633 struct config cfg = {
7634 .namespace_id = 0,
7635 .start_block = 0,
7636 .block_count = 0,
7637 .dtype = 0,
7638 .dspec = 0,
7639 };
7640
7641 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7642 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7643 OPT_SUFFIX("start-block", 's', &cfg.start_block, start_block),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7644 OPT_SHRT("block-count", 'c', &cfg.block_count, block_count),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7645 OPT_BYTE("dir-type", 'T', &cfg.dtype, dtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7646 OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec_w_dtype))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
7647
7648 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
7649 if (err)
7650 return err;
7651
7652 if (!cfg.namespace_id) {
7653 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
7654 if (err < 0) {
7655 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
7656 return err;
7657 }
7658 }
7659
7660 if (cfg.dtype > 0xf) {
7661 nvme_show_error("Invalid directive type, %x", cfg.dtype)nvme_show_message(1, "Invalid directive type, %x", cfg.dtype);
7662 return -EINVAL22;
7663 }
7664
7665 nvme_init_write_uncorrectable(&cmd, cfg.namespace_id, cfg.start_block,
7666 cfg.block_count, cfg.dtype << 4, cfg.dspec);
7667 err = libnvme_exec_io_passthru(hdl, &cmd);
7668 if (err) {
7669 nvme_show_err(err, "write uncorrectable");
7670 return err;
7671 }
7672
7673 nvme_show_verbose_result("NVME Write Uncorrectable Success")nvme_show_verbose_message("NVME Write Uncorrectable Success");
7674
7675 return err;
7676}
7677
7678static int invalid_tags(__u64 storage_tag, __u64 ref_tag, __u8 sts, __u8 pif)
7679{
7680 int result = 0;
7681
7682 if (sts < 64 && storage_tag >= (1LL << sts)) {
7683 nvme_show_error("Storage tag larger than storage tag size")nvme_show_message(1, "Storage tag larger than storage tag size"
)
;
7684 return 1;
7685 }
7686
7687 switch (pif) {
7688 case NVME_NVM_PIF_16B_GUARD:
7689 if (ref_tag >= (1LL << (32 - sts)))
7690 result = 1;
7691 break;
7692 case NVME_NVM_PIF_32B_GUARD:
7693 if (sts > 16 && ref_tag >= (1LL << (80 - sts)))
7694 result = 1;
7695 break;
7696 case NVME_NVM_PIF_64B_GUARD:
7697 if (sts > 0 && ref_tag >= (1LL << (48 - sts)))
7698 result = 1;
7699 break;
7700 default:
7701 nvme_show_error("Invalid PIF")nvme_show_message(1, "Invalid PIF");
7702 result = 1;
7703 break;
7704 }
7705
7706 if (result)
7707 nvme_show_error("Reference tag larger than allowed by PIF")nvme_show_message(1, "Reference tag larger than allowed by PIF"
)
;
7708
7709 return result;
7710}
7711
7712static int check_lbstm_byte_granularity(__u64 lbstm, __u8 sts)
7713{
7714 __u8 nr_full_bytes = sts / 8;
7715 __u8 nr_rem_bits = sts % 8;
7716 __u8 rem_mask, byte;
7717 __u8 i;
7718
7719 if (sts > 64)
7720 return -EINVAL22;
7721
7722 if (sts < 64)
7723 lbstm &= (1ULL << sts) - 1;
7724
7725 for (i = 0; i < nr_full_bytes; i++) {
7726 byte = (lbstm >> (i * 8)) & 0xff;
7727 if (byte != 0x00 && byte != 0xff)
7728 return -EINVAL22;
7729 }
7730
7731 if (nr_rem_bits) {
7732 rem_mask = (1u << nr_rem_bits) - 1;
7733 byte = (lbstm >> (nr_full_bytes * 8)) & rem_mask;
7734 if (byte != 0x00 && byte != rem_mask)
7735 return -EINVAL22;
7736 }
7737
7738 return 0;
7739}
7740
7741static int check_lbstm_masking_not_supported(__u64 lbstm, __u8 sts)
7742{
7743 __u64 stm_mask;
7744
7745 if (sts > 64)
7746 return -EINVAL22;
7747
7748 stm_mask = (sts < 64) ? ((1ULL << sts) - 1) : ~0ULL;
7749 if ((lbstm & stm_mask) != stm_mask)
7750 return -EINVAL22;
7751
7752 return 0;
7753}
7754
7755static int get_pif_sts_via_qpif(struct nvme_nvm_id_ns *nvm_ns, __u32 elbaf,
7756 __u8 sts, __u8 *pif)
7757{
7758 __u64 lbstm;
7759 int err = 0;
7760
7761 *pif = NVME_NVM_ELBAF_QPIF(elbaf)(((elbaf) >> NVME_NVM_ELBAF_QPIF_SHIFT) & NVME_NVM_ELBAF_QPIF_MASK
)
;
7762
7763 lbstm = le64_to_cpu(nvm_ns->lbstm);
7764 switch (NVME_NVM_PIFA_STMLA(nvm_ns->pifa)(((nvm_ns->pifa) >> NVME_NVM_PIFA_STMLA_SHIFT) &
NVME_NVM_PIFA_STMLA_MASK)
) {
7765 case NVME_NVM_PIFA_BIT_GRANULARITY_MASKING:
7766 break;
7767 case NVME_NVM_PIFA_BYTE_GRANULARITY_MASKING:
7768 err = check_lbstm_byte_granularity(lbstm, sts);
7769 break;
7770 case NVME_NVM_PIFA_MASKING_NOT_SUPPORTED:
7771 err = check_lbstm_masking_not_supported(lbstm, sts);
7772 break;
7773 default:
7774 err = -EINVAL22;
7775 break;
7776 }
7777
7778 if (err)
7779 nvme_show_error("Logical Block Storage Tag Mask is inconsistent with the Storage Tag Masking Level Attribute")nvme_show_message(1, "Logical Block Storage Tag Mask is inconsistent with the Storage Tag Masking Level Attribute"
)
;
7780
7781 return err;
7782}
7783
7784static int get_pif_sts(struct nvme_id_ns *ns, struct nvme_nvm_id_ns *nvm_ns,
7785 __u8 *pif, __u8 *sts)
7786{
7787 __u8 lba_index;
7788 __u32 elbaf;
7789
7790 nvme_id_ns_flbas_to_lbaf_inuse(ns->flbas, &lba_index);
7791 elbaf = le32_to_cpu(nvm_ns->elbaf[lba_index]);
7792 *sts = NVME_NVM_ELBAF_STS(elbaf)(((elbaf) >> NVME_NVM_ELBAF_STS_SHIFT) & NVME_NVM_ELBAF_STS_MASK
)
;
7793 *pif = NVME_NVM_ELBAF_PIF(elbaf)(((elbaf) >> NVME_NVM_ELBAF_PIF_SHIFT) & NVME_NVM_ELBAF_PIF_MASK
)
;
7794
7795 if (*pif == NVME_NVM_PIF_QTYPE && NVME_NVM_PIC_QPIFS(nvm_ns->pic)(((nvm_ns->pic) >> NVME_NVM_PIC_QPIFS_SHIFT) & NVME_NVM_PIC_QPIFS_MASK
)
)
7796 return get_pif_sts_via_qpif(nvm_ns, elbaf, *sts, pif);
7797
7798 return 0;
7799}
7800
7801static int get_pi_info(struct libnvme_transport_handle *hdl,
7802 __u32 nsid, __u8 prinfo, __u64 ilbrt, __u64 lbst,
7803 unsigned int *logical_block_size, __u16 *metadata_size)
7804{
7805 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_nvm_id_ns *nvm_ns = NULL((void*)0);
7806 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
7807 __u8 sts = 0, pif = 0;
7808 unsigned int lbs = 0;
7809 __u8 lba_index;
7810 int pi_size;
7811 __u16 ms;
7812 int err;
7813
7814 ns = libnvme_alloc(sizeof(*ns));
7815 if (!ns)
7816 return -ENOMEM12;
7817
7818 err = nvme_identify_ns(hdl, nsid, ns);
7819 if (err) {
7820 nvme_show_err(err, "identify namespace");
7821 return err;
7822 }
7823
7824 nvme_id_ns_flbas_to_lbaf_inuse(ns->flbas, &lba_index);
7825 lbs = 1 << ns->lbaf[lba_index].ds;
7826 ms = le16_to_cpu(ns->lbaf[lba_index].ms);
7827
7828 nvm_ns = libnvme_alloc(sizeof(*nvm_ns));
7829 if (!nvm_ns)
7830 return -ENOMEM12;
7831
7832 err = nvme_identify_csi_ns(hdl, nsid, NVME_CSI_NVM, 0, nvm_ns);
7833 if (!err) {
7834 err = get_pif_sts(ns, nvm_ns, &pif, &sts);
7835 if (err)
7836 return err;
7837 } else if (!nvme_status_equals(err, NVME_STATUS_TYPE_NVME,
7838 NVME_SC_INVALID_FIELD)) {
7839 /*
7840 * Ignore the invalid field error and skip get_pif_sts().
7841 * Keep the I/O commands behavior same as before.
7842 * Since the error returned by drives unsupported.
7843 */
7844 return NVME_SC_INVALID_FIELD;
7845 }
7846
7847 pi_size = (pif == NVME_NVM_PIF_16B_GUARD) ? 8 : 16;
7848 if (NVME_FLBAS_META_EXT(ns->flbas)(((ns->flbas) >> NVME_FLBAS_META_EXT_SHIFT) & NVME_FLBAS_META_EXT_MASK
)
) {
7849 /*
7850 * No meta data is transferred for PRACT=1 and MD=PI size:
7851 * 5.2.2.1 Protection Information and Write Commands
7852 * 5.2.2.2 Protection Information and Read Commands
7853 */
7854 if (!((prinfo & 0x8) != 0 && ms == pi_size))
7855 lbs += ms;
7856 }
7857
7858 if (invalid_tags(lbst, ilbrt, sts, pif))
7859 return -EINVAL22;
7860
7861 *logical_block_size = lbs;
7862 *metadata_size = ms;
7863
7864 return 0;
7865}
7866
7867static int init_pi_tags(struct libnvme_transport_handle *hdl,
7868 struct libnvme_passthru_cmd *cmd, __u32 nsid, __u64 ilbrt, __u64 lbst,
7869 __u16 lbat, __u16 lbatm)
7870{
7871 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_nvm_id_ns *nvm_ns = NULL((void*)0);
7872 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ns *ns = NULL((void*)0);
7873 __u8 sts = 0, pif = 0;
7874 int err = 0;
7875
7876 ns = libnvme_alloc(sizeof(*ns));
7877 if (!ns)
7878 return -ENOMEM12;
7879
7880 err = nvme_identify_ns(hdl, nsid, ns);
7881 if (err) {
7882 nvme_show_err(err, "identify namespace");
7883 return err;
7884 }
7885
7886 nvm_ns = libnvme_alloc(sizeof(*nvm_ns));
7887 if (!nvm_ns)
7888 return -ENOMEM12;
7889
7890 err = nvme_identify_csi_ns(hdl, nsid, NVME_CSI_NVM, 0, nvm_ns);
7891 if (!err) {
7892 err = get_pif_sts(ns, nvm_ns, &pif, &sts);
7893 if (err)
7894 return err;
7895 } else if (!nvme_status_equals(err, NVME_STATUS_TYPE_NVME,
7896 NVME_SC_INVALID_FIELD)) {
7897 /*
7898 * Ignore the invalid field error and skip get_pif_sts().
7899 * Keep the I/O commands behavior same as before.
7900 * Since the error returned by drives unsupported.
7901 */
7902 return NVME_SC_INVALID_FIELD;
7903 }
7904
7905 if (invalid_tags(lbst, ilbrt, sts, pif))
7906 return -EINVAL22;
7907
7908 nvme_init_var_size_tags(cmd, pif, sts, ilbrt, lbst);
7909 nvme_init_app_tag(cmd, lbat, lbatm);
7910
7911 return 0;
7912}
7913
7914static int write_zeroes(int argc, char **argv,
7915 struct command *acmd, struct plugin *plugin)
7916{
7917 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
7918 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
7919 struct libnvme_passthru_cmd cmd;
7920 __u16 control = 0;
7921 int err;
7922
7923 const char *desc =
7924 "The Write Zeroes command is used to set a range of logical blocks to zero.";
7925 const char *deac =
7926 "Set DEAC bit, requesting controller to deallocate specified logical blocks";
7927 const char *nsz = "Clear all logical blocks to zero in the entire namespace";
7928
7929 struct config {
7930 __u32 nsid;
7931 __u64 start_block;
7932 __u16 block_count;
7933 __u8 dtype;
7934 bool_Bool deac;
7935 bool_Bool limited_retry;
7936 bool_Bool force_unit_access;
7937 __u8 prinfo;
7938 __u64 ilbrt;
7939 __u16 lbatm;
7940 __u16 lbat;
7941 __u64 lbst;
7942 bool_Bool stc;
7943 __u16 dspec;
7944 bool_Bool nsz;
7945 };
7946
7947 struct config cfg = {
7948 .nsid = 0,
7949 .start_block = 0,
7950 .block_count = 0,
7951 .dtype = 0,
7952 .deac = false0,
7953 .limited_retry = false0,
7954 .force_unit_access = false0,
7955 .prinfo = 0,
7956 .ilbrt = 0,
7957 .lbatm = 0,
7958 .lbat = 0,
7959 .lbst = 0,
7960 .stc = false0,
7961 .dspec = 0,
7962 .nsz = false0,
7963 };
7964
7965 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7966 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7967 OPT_SUFFIX("start-block", 's', &cfg.start_block, start_block),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7968 OPT_SHRT("block-count", 'c', &cfg.block_count, block_count),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7969 OPT_BYTE("dir-type", 'T', &cfg.dtype, dtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7970 OPT_FLAG("deac", 'd', &cfg.deac, deac),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7971 OPT_FLAG("limited-retry", 'l', &cfg.limited_retry, limited_retry),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7972 OPT_FLAG("force-unit-access", 'f', &cfg.force_unit_access, force_unit_access),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7973 OPT_BYTE("prinfo", 'p', &cfg.prinfo, prinfo),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7974 OPT_SUFFIX("ref-tag", 'r', &cfg.ilbrt, ref_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7975 OPT_SHRT("app-tag-mask", 'm', &cfg.lbatm, app_tag_mask),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7976 OPT_SHRT("app-tag", 'a', &cfg.lbat, app_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7977 OPT_SUFFIX("storage-tag", 'S', &cfg.lbst, storage_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7978 OPT_FLAG("storage-tag-check", 'C', &cfg.stc, storage_tag_check),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7979 OPT_SHRT("dir-spec", 'D', &cfg.dspec, dspec_w_dtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
7980 OPT_FLAG("namespace-zeroes", 'Z', &cfg.nsz, nsz))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"deac", 'd', ((void*)0), CFG_FLAG, &cfg.deac, 0,
deac, 0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &
cfg.limited_retry, 0, limited_retry, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &
cfg.lbatm, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT
, &cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'S', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-spec", 'D', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"namespace-zeroes", 'Z', ((void*)0), CFG_FLAG
, &cfg.nsz, 0, nsz, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
7981
7982 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
7983 if (err)
7984 return err;
7985
7986 if (cfg.prinfo > 0xf)
7987 return -EINVAL22;
7988
7989 if (cfg.dtype > 0x7) {
7990 nvme_show_error("Invalid directive type, %x", cfg.dtype)nvme_show_message(1, "Invalid directive type, %x", cfg.dtype);
7991 return -EINVAL22;
7992 }
7993
7994 control |= (cfg.prinfo << 10);
7995 if (cfg.limited_retry)
7996 control |= NVME_IO_LR;
7997 if (cfg.force_unit_access)
7998 control |= NVME_IO_FUA;
7999 if (cfg.deac)
8000 control |= NVME_IO_DEAC;
8001 if (cfg.stc)
8002 control |= NVME_IO_STC;
8003 if (cfg.nsz)
8004 control |= NVME_IO_NSZ;
8005 control |= (cfg.dtype << 4);
8006 if (!cfg.nsid) {
8007 err = libnvme_get_nsid(hdl, &cfg.nsid);
8008 if (err < 0) {
8009 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8010 return err;
8011 }
8012 }
8013
8014 nvme_init_write_zeros(&cmd, cfg.nsid, cfg.start_block, cfg.block_count,
8015 control, cfg.dspec, 0, 0);
8016
8017 err = init_pi_tags(hdl, &cmd, cfg.nsid, cfg.ilbrt, cfg.lbst, cfg.lbat,
8018 cfg.lbatm);
8019 if (err && err != NVME_SC_INVALID_FIELD)
8020 return err;
8021
8022 err = libnvme_exec_io_passthru(hdl, &cmd);
8023 if (err) {
8024 nvme_show_err(err, "write-zeroes");
8025 return err;
8026 }
8027
8028 nvme_show_verbose_result("NVME Write Zeroes Success")nvme_show_verbose_message("NVME Write Zeroes Success");
8029
8030 if (!cfg.nsz || !nvme_args.verbose)
8031 return err;
8032
8033 if (cmd.result & 0x1)
8034 nvme_show_result(nvme_show_message(0, "All logical blocks in the entire namespace cleared to zero"
)
8035 "All logical blocks in the entire namespace cleared to zero")nvme_show_message(0, "All logical blocks in the entire namespace cleared to zero"
)
;
8036 else
8037 nvme_show_result("%d logical blocks cleared to zero", cfg.block_count)nvme_show_message(0, "%d logical blocks cleared to zero", cfg
.block_count)
;
8038
8039 return err;
8040}
8041
8042static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugin)
8043{
8044 const char *desc = "The Dataset Management command is used by the host to\n"
8045 "indicate attributes for ranges of logical blocks. This includes attributes\n"
8046 "for discarding unused blocks, data read and write frequency, access size, and other\n"
8047 "information that may be used to optimize performance and reliability.";
8048 const char *blocks = "Comma separated list of the number of blocks in each range";
8049 const char *starting_blocks = "Comma separated list of the starting block in each range";
8050 const char *context_attrs = "Comma separated list of the context attributes in each range";
8051 const char *ad = "Attribute Deallocate";
8052 const char *idw = "Attribute Integral Dataset for Write";
8053 const char *idr = "Attribute Integral Dataset for Read";
8054 const char *cdw11 = "All the command DWORD 11 attributes. Use instead of specifying individual attributes";
8055
8056 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
8057 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
8058 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_dsm_range *dsm = NULL((void*)0);
8059 struct libnvme_passthru_cmd cmd;
8060 __u32 ctx_attrs[NVME_DSM_MAX_RANGES] = {0,};
8061 __u32 nlbs[NVME_DSM_MAX_RANGES] = {0,};
8062 __u64 slbas[NVME_DSM_MAX_RANGES] = {0,};
8063 nvme_print_flags_t flags;
8064 uint16_t nc, nb, ns;
8065 int err;
8066
8067 struct config {
8068 __u32 namespace_id;
8069 char *ctx_attrs;
8070 char *blocks;
8071 char *slbas;
8072 bool_Bool ad;
8073 bool_Bool idw;
8074 bool_Bool idr;
8075 __u32 cdw11;
8076 };
8077
8078 struct config cfg = {
8079 .namespace_id = 0,
8080 .ctx_attrs = "",
8081 .blocks = "",
8082 .slbas = "",
8083 .ad = false0,
8084 .idw = false0,
8085 .idr = false0,
8086 .cdw11 = 0,
8087 };
8088
8089 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8090 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8091 OPT_LIST("ctx-attrs", 'a', &cfg.ctx_attrs, context_attrs),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8092 OPT_LIST("blocks", 'b', &cfg.blocks, blocks),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8093 OPT_LIST("slbs", 's', &cfg.slbas, starting_blocks),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8094 OPT_FLAG("ad", 'd', &cfg.ad, ad),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8095 OPT_FLAG("idw", 'w', &cfg.idw, idw),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8096 OPT_FLAG("idr", 'r', &cfg.idr, idr),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8097 OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"ctx-attrs", 'a', "LIST", CFG_STRING
, &cfg.ctx_attrs, 1, context_attrs, 0, }, {"blocks", 'b',
"LIST", CFG_STRING, &cfg.blocks, 1, blocks, 0, }, {"slbs"
, 's', "LIST", CFG_STRING, &cfg.slbas, 1, starting_blocks
, 0, }, {"ad", 'd', ((void*)0), CFG_FLAG, &cfg.ad, 0, ad,
0, }, {"idw", 'w', ((void*)0), CFG_FLAG, &cfg.idw, 0, idw
, 0, }, {"idr", 'r', ((void*)0), CFG_FLAG, &cfg.idr, 0, idr
, 0, }, {"cdw11", 'c', "NUM", CFG_POSITIVE, &cfg.cdw11, 1
, cdw11, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
8098
8099 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
8100 if (err)
8101 return err;
8102
8103 err = open_fallback_chardev(ctx, cfg.namespace_id, &hdl);
8104 if (err)
8105 return err;
8106
8107 err = validate_output_format(nvme_args.output_format, &flags);
8108 if (err < 0) {
8109 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
8110 return err;
8111 }
8112
8113 nc = shr_parse_csv_u32(cfg.ctx_attrs, ctx_attrs, ARRAY_SIZE(ctx_attrs))shr_parse_csv_uint(cfg.ctx_attrs, (unsigned int *)(ctx_attrs)
+ (sizeof(char [1 - 2*!(sizeof(*(ctx_attrs)) == sizeof(unsigned
int))]) - 1), (sizeof(ctx_attrs) / sizeof((ctx_attrs)[0])))
;
8114 nb = shr_parse_csv_u32(cfg.blocks, nlbs, ARRAY_SIZE(nlbs))shr_parse_csv_uint(cfg.blocks, (unsigned int *)(nlbs) + (sizeof
(char [1 - 2*!(sizeof(*(nlbs)) == sizeof(unsigned int))]) - 1
), (sizeof(nlbs) / sizeof((nlbs)[0])))
;
8115 ns = shr_parse_csv_u64(cfg.slbas, slbas, ARRAY_SIZE(slbas))shr_parse_csv_ulonglong(cfg.slbas, (unsigned long long *)(slbas
) + (sizeof(char [1 - 2*!(sizeof(*(slbas)) == sizeof(unsigned
long long))]) - 1), (sizeof(slbas) / sizeof((slbas)[0])))
;
8116 if ((nb != ns) ||
8117 (argconfig_parse_seen(opts, "ctx-attrs") && nb != nc)) {
8118 nvme_show_error("No valid range definition provided")nvme_show_message(1, "No valid range definition provided");
8119 return -EINVAL22;
8120 }
8121 if (!nb || nb > NVME_DSM_MAX_RANGES) {
8122 nvme_show_error("No range definition provided")nvme_show_message(1, "No range definition provided");
8123 return -EINVAL22;
8124 }
8125
8126 if (!cfg.namespace_id) {
8127 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
8128 if (err < 0) {
8129 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8130 return err;
8131 }
8132 }
8133 if (cfg.cdw11) {
8134 cfg.ad = NVME_GET(cfg.cdw11, DSM_CDW11_AD)(((cfg.cdw11) >> NVME_DSM_CDW11_AD_SHIFT) & NVME_DSM_CDW11_AD_MASK
)
;
8135 cfg.idw = NVME_GET(cfg.cdw11, DSM_CDW11_IDW)(((cfg.cdw11) >> NVME_DSM_CDW11_IDW_SHIFT) & NVME_DSM_CDW11_IDW_MASK
)
;
8136 cfg.idr = NVME_GET(cfg.cdw11, DSM_CDW11_IDR)(((cfg.cdw11) >> NVME_DSM_CDW11_IDR_SHIFT) & NVME_DSM_CDW11_IDR_MASK
)
;
8137 }
8138
8139 dsm = libnvme_alloc(sizeof(*dsm) * nb);
8140 if (!dsm)
8141 return -ENOMEM12;
8142
8143 nvme_init_dsm_range(dsm, ctx_attrs, nlbs, slbas, nb);
8144 nvme_init_dsm(&cmd, cfg.namespace_id, nb, cfg.idr, cfg.idw, cfg.ad, dsm,
8145 sizeof(*dsm) * nb);
8146 err = libnvme_exec_io_passthru(hdl, &cmd);
8147 if (err) {
8148 nvme_show_err(err, "data-set management");
8149 return err;
8150 }
8151
8152 nvme_show_verbose_result("NVMe DSM: success")nvme_show_verbose_message("NVMe DSM: success");
8153
8154 return err;
8155}
8156
8157static int copy_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
8158{
8159 const char *desc = "The Copy command is used by the host to copy data\n"
8160 "from one or more source logical block ranges to a\n"
8161 "single consecutive destination logical block range.";
8162 const char *d_sdlba = "64-bit addr of first destination logical block";
8163 const char *d_slbas = "64-bit addr of first block per range (comma-separated list)";
8164 const char *d_nlbs = "number of blocks per range (comma-separated list, zeroes-based values)";
8165 const char *d_snsids = "source namespace identifier per range (comma-separated list)";
8166 const char *d_sopts = "source options per range (comma-separated list)";
8167 const char *d_lr = "limited retry";
8168 const char *d_fua = "force unit access";
8169 const char *d_prinfor = "protection information and check field (read part)";
8170 const char *d_prinfow = "protection information and check field (write part)";
8171 const char *d_ilbrt = "initial lba reference tag (write part)";
8172 const char *d_eilbrts = "expected lba reference tags (read part, comma-separated list)";
8173 const char *d_lbat = "lba application tag (write part)";
8174 const char *d_elbats = "expected lba application tags (read part, comma-separated list)";
8175 const char *d_lbatm = "lba application tag mask (write part)";
8176 const char *d_elbatms = "expected lba application tag masks (read part, comma-separated list)";
8177 const char *d_dtype = "directive type (write part)";
8178 const char *d_dspec = "directive specific (write part)";
8179 const char *d_format = "source range entry format";
8180
8181 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
8182 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
8183 __u16 nr, nb, ns, nrts, natms, nats, nids;
8184 struct libnvme_passthru_cmd cmd;
8185 __u16 nlbs[256] = { 0 };
8186 __u64 slbas[256] = { 0 };
8187 __u32 snsids[256] = { 0 };
8188 __u16 sopts[256] = { 0 };
8189 int err;
8190
8191 union {
8192 __u32 short_pi[256];
8193 __u64 long_pi[256];
8194 } eilbrts;
8195
8196 __u16 elbatms[256] = { 0 };
8197 __u16 elbats[256] = { 0 };
8198
8199 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) union {
8200 struct nvme_copy_range_f0 f0[256];
8201 struct nvme_copy_range_f1 f1[256];
8202 struct nvme_copy_range_f2 f2[256];
8203 struct nvme_copy_range_f3 f3[256];
8204 } *copy = NULL((void*)0);
8205
8206 struct config {
8207 __u32 nsid;
8208 __u64 sdlba;
8209 char *slbas;
8210 char *nlbs;
8211 char *snsids;
8212 char *sopts;
8213 bool_Bool lr;
8214 bool_Bool fua;
8215 __u8 prinfow;
8216 __u8 prinfor;
8217 __u64 ilbrt;
8218 char *eilbrts;
8219 __u16 lbat;
8220 char *elbats;
8221 __u16 lbatm;
8222 char *elbatms;
8223 __u8 dtype;
8224 __u16 dspec;
8225 __u8 format;
8226 __u64 lbst;
8227 bool_Bool stc;
8228 };
8229
8230 struct config cfg = {
8231 .nsid = 0,
8232 .sdlba = 0,
8233 .slbas = "",
8234 .nlbs = "",
8235 .snsids = "",
8236 .sopts = "",
8237 .lr = false0,
8238 .fua = false0,
8239 .prinfow = 0,
8240 .prinfor = 0,
8241 .ilbrt = 0,
8242 .eilbrts = "",
8243 .lbat = 0,
8244 .elbats = "",
8245 .lbatm = 0,
8246 .elbatms = "",
8247 .dtype = 0,
8248 .dspec = 0,
8249 .format = 0,
8250 .lbst = 0,
8251 .stc = false0,
8252 };
8253
8254 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8255 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8256 OPT_SUFFIX("sdlba", 'd', &cfg.sdlba, d_sdlba),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8257 OPT_LIST("slbs", 's', &cfg.slbas, d_slbas),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8258 OPT_LIST("blocks", 'b', &cfg.nlbs, d_nlbs),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8259 OPT_LIST("snsids", 'N', &cfg.snsids, d_snsids),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8260 OPT_LIST("sopts", 'O', &cfg.sopts, d_sopts),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8261 OPT_FLAG("limited-retry", 'l', &cfg.lr, d_lr),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8262 OPT_FLAG("force-unit-access", 'f', &cfg.fua, d_fua),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8263 OPT_BYTE("prinfow", 'p', &cfg.prinfow, d_prinfow),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8264 OPT_BYTE("prinfor", 'P', &cfg.prinfor, d_prinfor),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8265 OPT_SUFFIX("ref-tag", 'r', &cfg.ilbrt, d_ilbrt),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8266 OPT_LIST("expected-ref-tags", 'R', &cfg.eilbrts, d_eilbrts),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8267 OPT_SHRT("app-tag", 'a', &cfg.lbat, d_lbat),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8268 OPT_LIST("expected-app-tags", 'A', &cfg.elbats, d_elbats),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8269 OPT_SHRT("app-tag-mask", 'm', &cfg.lbatm, d_lbatm),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8270 OPT_LIST("expected-app-tag-masks", 'M', &cfg.elbatms, d_elbatms),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8271 OPT_BYTE("dir-type", 'T', &cfg.dtype, d_dtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8272 OPT_SHRT("dir-spec", 'S', &cfg.dspec, d_dspec),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8273 OPT_BYTE("format", 'F', &cfg.format, d_format),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8274 OPT_SUFFIX("storage-tag", 't', &cfg.lbst, storage_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8275 OPT_FLAG("storage-tag-check", 'c', &cfg.stc, storage_tag_check))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"sdlba", 'd', "IONUM", CFG_LONG_SUFFIX
, &cfg.sdlba, 1, d_sdlba, 0, }, {"slbs", 's', "LIST", CFG_STRING
, &cfg.slbas, 1, d_slbas, 0, }, {"blocks", 'b', "LIST", CFG_STRING
, &cfg.nlbs, 1, d_nlbs, 0, }, {"snsids", 'N', "LIST", CFG_STRING
, &cfg.snsids, 1, d_snsids, 0, }, {"sopts", 'O', "LIST", CFG_STRING
, &cfg.sopts, 1, d_sopts, 0, }, {"limited-retry", 'l', ((
void*)0), CFG_FLAG, &cfg.lr, 0, d_lr, 0, }, {"force-unit-access"
, 'f', ((void*)0), CFG_FLAG, &cfg.fua, 0, d_fua, 0, }, {"prinfow"
, 'p', "NUM", CFG_BYTE, &cfg.prinfow, 1, d_prinfow, 0, },
{"prinfor", 'P', "NUM", CFG_BYTE, &cfg.prinfor, 1, d_prinfor
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, d_ilbrt, 0, }, {"expected-ref-tags", 'R', "LIST", CFG_STRING
, &cfg.eilbrts, 1, d_eilbrts, 0, }, {"app-tag", 'a', "NUM"
, CFG_SHORT, &cfg.lbat, 1, d_lbat, 0, }, {"expected-app-tags"
, 'A', "LIST", CFG_STRING, &cfg.elbats, 1, d_elbats, 0, }
, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm, 1, d_lbatm
, 0, }, {"expected-app-tag-masks", 'M', "LIST", CFG_STRING, &
cfg.elbatms, 1, d_elbatms, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE
, &cfg.dtype, 1, d_dtype, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT
, &cfg.dspec, 1, d_dspec, 0, }, {"format", 'F', "NUM", CFG_BYTE
, &cfg.format, 1, d_format, 0, }, {"storage-tag", 't', "IONUM"
, CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }, {"storage-tag-check"
, 'c', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
8276
8277 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
8278 if (err)
8279 return err;
8280
8281 nb = shr_parse_csv_u16(cfg.nlbs, nlbs, ARRAY_SIZE(nlbs))shr_parse_csv_ushort(cfg.nlbs, (unsigned short *)(nlbs) + (sizeof
(char [1 - 2*!(sizeof(*(nlbs)) == sizeof(unsigned short))]) -
1), (sizeof(nlbs) / sizeof((nlbs)[0])))
;
8282 ns = shr_parse_csv_u64(cfg.slbas, slbas, ARRAY_SIZE(slbas))shr_parse_csv_ulonglong(cfg.slbas, (unsigned long long *)(slbas
) + (sizeof(char [1 - 2*!(sizeof(*(slbas)) == sizeof(unsigned
long long))]) - 1), (sizeof(slbas) / sizeof((slbas)[0])))
;
8283 nids = shr_parse_csv_u32(cfg.snsids, snsids, ARRAY_SIZE(snsids))shr_parse_csv_uint(cfg.snsids, (unsigned int *)(snsids) + (sizeof
(char [1 - 2*!(sizeof(*(snsids)) == sizeof(unsigned int))]) -
1), (sizeof(snsids) / sizeof((snsids)[0])))
;
8284 shr_parse_csv_u16(cfg.sopts, sopts, ARRAY_SIZE(sopts))shr_parse_csv_ushort(cfg.sopts, (unsigned short *)(sopts) + (
sizeof(char [1 - 2*!(sizeof(*(sopts)) == sizeof(unsigned short
))]) - 1), (sizeof(sopts) / sizeof((sopts)[0])))
;
8285
8286 switch (cfg.format) {
8287 case 0:
8288 case 2:
8289 nrts = shr_parse_csv_u32(cfg.eilbrts,shr_parse_csv_uint(cfg.eilbrts, (unsigned int *)(eilbrts.short_pi
) + (sizeof(char [1 - 2*!(sizeof(*(eilbrts.short_pi)) == sizeof
(unsigned int))]) - 1), (sizeof(eilbrts.short_pi) / sizeof((eilbrts
.short_pi)[0])))
8290 eilbrts.short_pi, ARRAY_SIZE(eilbrts.short_pi))shr_parse_csv_uint(cfg.eilbrts, (unsigned int *)(eilbrts.short_pi
) + (sizeof(char [1 - 2*!(sizeof(*(eilbrts.short_pi)) == sizeof
(unsigned int))]) - 1), (sizeof(eilbrts.short_pi) / sizeof((eilbrts
.short_pi)[0])))
;
8291 break;
8292 case 1:
8293 case 3:
8294 nrts = shr_parse_csv_u64(cfg.eilbrts,shr_parse_csv_ulonglong(cfg.eilbrts, (unsigned long long *)(eilbrts
.long_pi) + (sizeof(char [1 - 2*!(sizeof(*(eilbrts.long_pi)) ==
sizeof(unsigned long long))]) - 1), (sizeof(eilbrts.long_pi)
/ sizeof((eilbrts.long_pi)[0])))
8295 eilbrts.long_pi, ARRAY_SIZE(eilbrts.long_pi))shr_parse_csv_ulonglong(cfg.eilbrts, (unsigned long long *)(eilbrts
.long_pi) + (sizeof(char [1 - 2*!(sizeof(*(eilbrts.long_pi)) ==
sizeof(unsigned long long))]) - 1), (sizeof(eilbrts.long_pi)
/ sizeof((eilbrts.long_pi)[0])))
;
8296 break;
8297 default:
8298 nvme_show_error("invalid format")nvme_show_message(1, "invalid format");
8299 return -EINVAL22;
8300 }
8301
8302 natms = shr_parse_csv_u16(cfg.elbatms, elbatms,shr_parse_csv_ushort(cfg.elbatms, (unsigned short *)(elbatms)
+ (sizeof(char [1 - 2*!(sizeof(*(elbatms)) == sizeof(unsigned
short))]) - 1), (sizeof(elbatms) / sizeof((elbatms)[0])))
8303 ARRAY_SIZE(elbatms))shr_parse_csv_ushort(cfg.elbatms, (unsigned short *)(elbatms)
+ (sizeof(char [1 - 2*!(sizeof(*(elbatms)) == sizeof(unsigned
short))]) - 1), (sizeof(elbatms) / sizeof((elbatms)[0])))
;
8304 nats = shr_parse_csv_u16(cfg.elbats, elbats,shr_parse_csv_ushort(cfg.elbats, (unsigned short *)(elbats) +
(sizeof(char [1 - 2*!(sizeof(*(elbats)) == sizeof(unsigned short
))]) - 1), (sizeof(elbats) / sizeof((elbats)[0])))
8305 ARRAY_SIZE(elbats))shr_parse_csv_ushort(cfg.elbats, (unsigned short *)(elbats) +
(sizeof(char [1 - 2*!(sizeof(*(elbats)) == sizeof(unsigned short
))]) - 1), (sizeof(elbats) / sizeof((elbats)[0])))
;
8306
8307 nr = max(nb, max(ns, max(nrts, max(natms, nats))))((nb) > (((ns) > (((nrts) > (((natms) > (nats) ? (
natms) : (nats))) ? (nrts) : (((natms) > (nats) ? (natms) :
(nats))))) ? (ns) : (((nrts) > (((natms) > (nats) ? (natms
) : (nats))) ? (nrts) : (((natms) > (nats) ? (natms) : (nats
))))))) ? (nb) : (((ns) > (((nrts) > (((natms) > (nats
) ? (natms) : (nats))) ? (nrts) : (((natms) > (nats) ? (natms
) : (nats))))) ? (ns) : (((nrts) > (((natms) > (nats) ?
(natms) : (nats))) ? (nrts) : (((natms) > (nats) ? (natms
) : (nats))))))))
;
8308 if (cfg.format == 2 || cfg.format == 3) {
8309 if (nr != nids) {
8310 nvme_show_error("formats 2 and 3 require source namespace ids for each source range")nvme_show_message(1, "formats 2 and 3 require source namespace ids for each source range"
)
;
8311 return -EINVAL22;
8312 }
8313 } else if (nids) {
8314 nvme_show_error("formats 0 and 1 do not support cross-namespace copy")nvme_show_message(1, "formats 0 and 1 do not support cross-namespace copy"
)
;
8315 return -EINVAL22;
8316 }
8317 if (!nr || nr > 256) {
8318 nvme_show_error("invalid range")nvme_show_message(1, "invalid range");
8319 return -EINVAL22;
8320 }
8321
8322 if (!cfg.nsid) {
8323 err = libnvme_get_nsid(hdl, &cfg.nsid);
8324 if (err < 0) {
8325 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8326 return err;
8327 }
8328 }
8329
8330 copy = libnvme_alloc(sizeof(*copy));
8331 if (!copy)
8332 return -ENOMEM12;
8333
8334 switch (cfg.format) {
8335 case 1:
8336 nvme_init_copy_range_f1(copy->f1, nlbs, slbas, eilbrts.long_pi,
8337 elbatms, elbats, nr);
8338 break;
8339 case 2:
8340 nvme_init_copy_range_f2(copy->f2, snsids, nlbs, slbas, sopts,
8341 eilbrts.short_pi, elbatms, elbats, nr);
8342 break;
8343 case 3:
8344 nvme_init_copy_range_f3(copy->f3, snsids, nlbs, slbas, sopts,
8345 eilbrts.long_pi, elbatms, elbats, nr);
8346 break;
8347 default:
8348 nvme_init_copy_range_f0(copy->f0, nlbs, slbas, eilbrts.short_pi,
8349 elbatms, elbats, nr);
8350 break;
8351 }
8352
8353 nvme_init_copy(&cmd, cfg.nsid, cfg.sdlba, nr, cfg.format,
8354 cfg.prinfor, cfg.prinfow, 0, cfg.dtype, cfg.stc, cfg.stc,
8355 cfg.fua, cfg.lr, 0, cfg.dspec, copy->f0);
8356 err = init_pi_tags(hdl, &cmd, cfg.nsid, cfg.ilbrt, cfg.lbst, cfg.lbat,
8357 cfg.lbatm);
8358 if (err != 0 && err != NVME_SC_INVALID_FIELD)
8359 return err;
8360 err = libnvme_exec_io_passthru(hdl, &cmd);
8361 if (err) {
8362 nvme_show_err(err, "NVMe Copy");
8363 return err;
8364 }
8365
8366 nvme_show_verbose_result("NVMe Copy: success")nvme_show_verbose_message("NVMe Copy: success");
8367
8368 return err;
8369}
8370
8371static int flush_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
8372{
8373 const char *desc = "Commit data and metadata associated with\n"
8374 "given namespaces to nonvolatile media. Applies to all commands\n"
8375 "finished before the flush was submitted. Additional data may also be\n"
8376 "flushed by the controller, from any namespace, depending on controller and\n"
8377 "associated namespace status.";
8378
8379 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
8380 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
8381 int err;
8382
8383 struct config {
8384 __u32 namespace_id;
8385 };
8386
8387 struct config cfg = {
8388 .namespace_id = 0,
8389 };
8390
8391 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8392 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
8393
8394 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
8395 if (err)
8396 return err;
8397
8398 err = open_fallback_chardev(ctx, cfg.namespace_id, &hdl);
8399 if (err)
8400 return err;
8401
8402 if (!cfg.namespace_id) {
8403 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
8404 if (err < 0) {
8405 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8406 return err;
8407 }
8408 }
8409
8410 err = nvme_flush(hdl, cfg.namespace_id);
8411 if (err) {
8412 nvme_show_err(err, "flush");
8413 return err;
8414 }
8415
8416 nvme_show_verbose_result("NVMe Flush: success")nvme_show_verbose_message("NVMe Flush: success");
8417
8418 return err;
8419}
8420
8421static int resv_acquire(int argc, char **argv, struct command *acmd, struct plugin *plugin)
8422{
8423 const char *desc = "Obtain a reservation on a given\n"
8424 "namespace. Only one reservation is allowed at a time on a\n"
8425 "given namespace, though multiple controllers may register\n"
8426 "with that namespace. Namespace reservation will abort with\n"
8427 "status Reservation Conflict if the given namespace is already reserved.";
8428 const char *prkey = "pre-empt reservation key";
8429 const char *racqa = "reservation acquire action";
8430
8431 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
8432 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
8433 struct libnvme_passthru_cmd cmd;
8434 nvme_print_flags_t flags;
8435 __le64 payload[2];
8436 int err;
8437
8438 struct config {
8439 __u32 namespace_id;
8440 __u64 crkey;
8441 __u64 prkey;
8442 __u8 rtype;
8443 __u8 racqa;
8444 bool_Bool iekey;
8445 };
8446
8447 struct config cfg = {
8448 .namespace_id = 0,
8449 .crkey = 0,
8450 .prkey = 0,
8451 .rtype = 0,
8452 .racqa = 0,
8453 .iekey = false0,
8454 };
8455
8456 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"prkey", 'p', "IONUM", CFG_LONG_SUFFIX
, &cfg.prkey, 1, prkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"racqa", 'a', "NUM", CFG_BYTE
, &cfg.racqa, 1, racqa, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8457 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"prkey", 'p', "IONUM", CFG_LONG_SUFFIX
, &cfg.prkey, 1, prkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"racqa", 'a', "NUM", CFG_BYTE
, &cfg.racqa, 1, racqa, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8458 OPT_SUFFIX("crkey", 'c', &cfg.crkey, crkey),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"prkey", 'p', "IONUM", CFG_LONG_SUFFIX
, &cfg.prkey, 1, prkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"racqa", 'a', "NUM", CFG_BYTE
, &cfg.racqa, 1, racqa, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8459 OPT_SUFFIX("prkey", 'p', &cfg.prkey, prkey),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"prkey", 'p', "IONUM", CFG_LONG_SUFFIX
, &cfg.prkey, 1, prkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"racqa", 'a', "NUM", CFG_BYTE
, &cfg.racqa, 1, racqa, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8460 OPT_BYTE("rtype", 't', &cfg.rtype, rtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"prkey", 'p', "IONUM", CFG_LONG_SUFFIX
, &cfg.prkey, 1, prkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"racqa", 'a', "NUM", CFG_BYTE
, &cfg.racqa, 1, racqa, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8461 OPT_BYTE("racqa", 'a', &cfg.racqa, racqa),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"prkey", 'p', "IONUM", CFG_LONG_SUFFIX
, &cfg.prkey, 1, prkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"racqa", 'a', "NUM", CFG_BYTE
, &cfg.racqa, 1, racqa, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8462 OPT_FLAG("iekey", 'i', &cfg.iekey, iekey))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"prkey", 'p', "IONUM", CFG_LONG_SUFFIX
, &cfg.prkey, 1, prkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"racqa", 'a', "NUM", CFG_BYTE
, &cfg.racqa, 1, racqa, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
8463
8464 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
8465 if (err)
8466 return err;
8467
8468 err = validate_output_format(nvme_args.output_format, &flags);
8469 if (err < 0) {
8470 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
8471 return err;
8472 }
8473
8474 if (!cfg.namespace_id) {
8475 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
8476 if (err < 0) {
8477 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8478 return err;
8479 }
8480 }
8481 if (cfg.racqa > 7) {
8482 nvme_show_error("invalid racqa:%d", cfg.racqa)nvme_show_message(1, "invalid racqa:%d", cfg.racqa);
8483 return -EINVAL22;
8484 }
8485
8486 nvme_init_resv_acquire(&cmd, cfg.namespace_id, cfg.racqa, cfg.iekey,
8487 false0, cfg.rtype, cfg.crkey, cfg.prkey, payload);
8488 err = libnvme_exec_io_passthru(hdl, &cmd);
8489 if (err) {
8490 nvme_show_err(err, "reservation acquire");
8491 return err;
8492 }
8493
8494 nvme_show_verbose_result("NVME Reservation Acquire success")nvme_show_verbose_message("NVME Reservation Acquire success");
8495
8496 return err;
8497}
8498
8499static int resv_register(int argc, char **argv, struct command *acmd, struct plugin *plugin)
8500{
8501 const char *desc = "Register, de-register, or\n"
8502 "replace a controller's reservation on a given namespace.\n"
8503 "Only one reservation at a time is allowed on any namespace.";
8504 const char *nrkey = "new reservation key";
8505 const char *rrega = "reservation registration action";
8506 const char *cptpl = "change persistence through power loss setting";
8507
8508 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
8509 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
8510 struct libnvme_passthru_cmd cmd;
8511 nvme_print_flags_t flags;
8512 __le64 payload[2];
8513 int err;
8514
8515 struct config {
8516 __u32 namespace_id;
8517 __u64 crkey;
8518 __u64 nrkey;
8519 __u8 rrega;
8520 __u8 cptpl;
8521 bool_Bool iekey;
8522 };
8523
8524 struct config cfg = {
8525 .namespace_id = 0,
8526 .crkey = 0,
8527 .nrkey = 0,
8528 .rrega = 0,
8529 .cptpl = false0,
8530 };
8531
8532 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"nrkey", 'k', "IONUM", CFG_LONG_SUFFIX
, &cfg.nrkey, 1, nrkey, 0, }, {"rrega", 'r', "NUM", CFG_BYTE
, &cfg.rrega, 1, rrega, 0, }, {"cptpl", 'p', "NUM", CFG_BYTE
, &cfg.cptpl, 1, cptpl, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8533 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"nrkey", 'k', "IONUM", CFG_LONG_SUFFIX
, &cfg.nrkey, 1, nrkey, 0, }, {"rrega", 'r', "NUM", CFG_BYTE
, &cfg.rrega, 1, rrega, 0, }, {"cptpl", 'p', "NUM", CFG_BYTE
, &cfg.cptpl, 1, cptpl, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8534 OPT_SUFFIX("crkey", 'c', &cfg.crkey, crkey),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"nrkey", 'k', "IONUM", CFG_LONG_SUFFIX
, &cfg.nrkey, 1, nrkey, 0, }, {"rrega", 'r', "NUM", CFG_BYTE
, &cfg.rrega, 1, rrega, 0, }, {"cptpl", 'p', "NUM", CFG_BYTE
, &cfg.cptpl, 1, cptpl, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8535 OPT_SUFFIX("nrkey", 'k', &cfg.nrkey, nrkey),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"nrkey", 'k', "IONUM", CFG_LONG_SUFFIX
, &cfg.nrkey, 1, nrkey, 0, }, {"rrega", 'r', "NUM", CFG_BYTE
, &cfg.rrega, 1, rrega, 0, }, {"cptpl", 'p', "NUM", CFG_BYTE
, &cfg.cptpl, 1, cptpl, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8536 OPT_BYTE("rrega", 'r', &cfg.rrega, rrega),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"nrkey", 'k', "IONUM", CFG_LONG_SUFFIX
, &cfg.nrkey, 1, nrkey, 0, }, {"rrega", 'r', "NUM", CFG_BYTE
, &cfg.rrega, 1, rrega, 0, }, {"cptpl", 'p', "NUM", CFG_BYTE
, &cfg.cptpl, 1, cptpl, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8537 OPT_BYTE("cptpl", 'p', &cfg.cptpl, cptpl),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"nrkey", 'k', "IONUM", CFG_LONG_SUFFIX
, &cfg.nrkey, 1, nrkey, 0, }, {"rrega", 'r', "NUM", CFG_BYTE
, &cfg.rrega, 1, rrega, 0, }, {"cptpl", 'p', "NUM", CFG_BYTE
, &cfg.cptpl, 1, cptpl, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8538 OPT_FLAG("iekey", 'i', &cfg.iekey, iekey))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"nrkey", 'k', "IONUM", CFG_LONG_SUFFIX
, &cfg.nrkey, 1, nrkey, 0, }, {"rrega", 'r', "NUM", CFG_BYTE
, &cfg.rrega, 1, rrega, 0, }, {"cptpl", 'p', "NUM", CFG_BYTE
, &cfg.cptpl, 1, cptpl, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
8539
8540 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
8541 if (err)
8542 return err;
8543
8544 err = validate_output_format(nvme_args.output_format, &flags);
8545 if (err < 0) {
8546 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
8547 return err;
8548 }
8549
8550 if (!cfg.namespace_id) {
8551 err = libnvme_get_nsid(hdl, &cfg.namespace_id);
8552 if (err < 0) {
8553 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8554 return err;
8555 }
8556 }
8557 if (cfg.cptpl > 3) {
8558 nvme_show_error("invalid cptpl:%d", cfg.cptpl)nvme_show_message(1, "invalid cptpl:%d", cfg.cptpl);
8559 return -EINVAL22;
8560 }
8561
8562 if (cfg.rrega > 7) {
8563 nvme_show_error("invalid rrega:%d", cfg.rrega)nvme_show_message(1, "invalid rrega:%d", cfg.rrega);
8564 return -EINVAL22;
8565 }
8566
8567 nvme_init_resv_register(&cmd, cfg.namespace_id, cfg.rrega, cfg.iekey,
8568 false0, cfg.cptpl, cfg.crkey, cfg.nrkey,
8569 payload);
8570 err = libnvme_exec_io_passthru(hdl, &cmd);
8571 if (err) {
8572 nvme_show_err(err, "reservation register");
8573 return err;
8574 }
8575
8576 nvme_show_verbose_result("NVME Reservation success")nvme_show_verbose_message("NVME Reservation success");
8577
8578 return err;
8579}
8580
8581static int resv_release(int argc, char **argv, struct command *acmd, struct plugin *plugin)
8582{
8583 const char *desc = "Releases reservation held on a\n"
8584 "namespace by the given controller. If rtype != current reservation\n"
8585 "type, release will fails. If the given controller holds no\n"
8586 "reservation on the namespace or is not the namespace's current\n"
8587 "reservation holder, the release command completes with no\n"
8588 "effect. If the reservation type is not Write Exclusive or\n"
8589 "Exclusive Access, all registrants on the namespace except\n"
8590 "the issuing controller are notified.";
8591 const char *rrela = "reservation release action";
8592
8593 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
8594 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
8595 struct libnvme_passthru_cmd cmd;
8596 nvme_print_flags_t flags;
8597 __le64 payload[1];
8598 int err;
8599
8600 struct config {
8601 __u32 nsid;
8602 __u64 crkey;
8603 __u8 rtype;
8604 __u8 rrela;
8605 __u8 iekey;
8606 };
8607
8608 struct config cfg = {
8609 .nsid = 0,
8610 .crkey = 0,
8611 .rtype = 0,
8612 .rrela = 0,
8613 .iekey = 0,
8614 };
8615
8616 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"rrela", 'a', "NUM", CFG_BYTE
, &cfg.rrela, 1, rrela, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8617 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"rrela", 'a', "NUM", CFG_BYTE
, &cfg.rrela, 1, rrela, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8618 OPT_SUFFIX("crkey", 'c', &cfg.crkey, crkey),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"rrela", 'a', "NUM", CFG_BYTE
, &cfg.rrela, 1, rrela, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8619 OPT_BYTE("rtype", 't', &cfg.rtype, rtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"rrela", 'a', "NUM", CFG_BYTE
, &cfg.rrela, 1, rrela, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8620 OPT_BYTE("rrela", 'a', &cfg.rrela, rrela),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"rrela", 'a', "NUM", CFG_BYTE
, &cfg.rrela, 1, rrela, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8621 OPT_FLAG("iekey", 'i', &cfg.iekey, iekey))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"crkey", 'c', "IONUM", CFG_LONG_SUFFIX
, &cfg.crkey, 1, crkey, 0, }, {"rtype", 't', "NUM", CFG_BYTE
, &cfg.rtype, 1, rtype, 0, }, {"rrela", 'a', "NUM", CFG_BYTE
, &cfg.rrela, 1, rrela, 0, }, {"iekey", 'i', ((void*)0), CFG_FLAG
, &cfg.iekey, 0, iekey, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
8622
8623 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
8624 if (err)
8625 return err;
8626
8627 err = validate_output_format(nvme_args.output_format, &flags);
8628 if (err < 0) {
8629 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
8630 return err;
8631 }
8632
8633 if (!cfg.nsid) {
8634 err = libnvme_get_nsid(hdl, &cfg.nsid);
8635 if (err < 0) {
8636 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8637 return err;
8638 }
8639 }
8640 if (cfg.rrela > 7) {
8641 nvme_show_error("invalid rrela:%d", cfg.rrela)nvme_show_message(1, "invalid rrela:%d", cfg.rrela);
8642 return -EINVAL22;
8643 }
8644
8645 nvme_init_resv_release(&cmd, cfg.nsid, cfg.rrela, cfg.iekey, false0,
8646 cfg.rtype, cfg.crkey, payload);
8647 err = libnvme_exec_io_passthru(hdl, &cmd);
8648 if (err) {
8649 nvme_show_err(err, "reservation release");
8650 return err;
8651 }
8652
8653 nvme_show_verbose_result("NVME Reservation Release success")nvme_show_verbose_message("NVME Reservation Release success");
8654
8655 return err;
8656}
8657
8658static int resv_report(int argc, char **argv, struct command *acmd, struct plugin *plugin)
8659{
8660 const char *desc = "Returns Reservation Status data\n"
8661 "structure describing any existing reservations on and the\n"
8662 "status of a given namespace. Namespace Reservation Status\n"
8663 "depends on the number of controllers registered for that namespace.";
8664 const char *numd = "number of dwords to transfer";
8665 const char *eds = "request extended data structure";
8666
8667 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
8668 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
8669 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_resv_status *status = NULL((void*)0);
8670 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_id_ctrl *ctrl = NULL((void*)0);
8671 struct libnvme_passthru_cmd cmd;
8672 nvme_print_flags_t flags;
8673 int err, size;
8674
8675 struct config {
8676 __u32 nsid;
8677 __u32 numd;
8678 __u8 eds;
8679 bool_Bool raw_binary;
8680 };
8681
8682 struct config cfg = {
8683 .nsid = 0,
8684 .numd = 0,
8685 .eds = false0,
8686 .raw_binary = false0,
8687 };
8688
8689 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"numd", 'd', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"eds", 'e', ((void*)0), CFG_FLAG
, &cfg.eds, 0, eds, 0, }, {"raw-binary", 'b', ((void*)0),
CFG_FLAG, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((
void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8690 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"numd", 'd', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"eds", 'e', ((void*)0), CFG_FLAG
, &cfg.eds, 0, eds, 0, }, {"raw-binary", 'b', ((void*)0),
CFG_FLAG, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((
void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8691 OPT_UINT("numd", 'd', &cfg.numd, numd),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"numd", 'd', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"eds", 'e', ((void*)0), CFG_FLAG
, &cfg.eds, 0, eds, 0, }, {"raw-binary", 'b', ((void*)0),
CFG_FLAG, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((
void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8692 OPT_FLAG("eds", 'e', &cfg.eds, eds),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"numd", 'd', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"eds", 'e', ((void*)0), CFG_FLAG
, &cfg.eds, 0, eds, 0, }, {"raw-binary", 'b', ((void*)0),
CFG_FLAG, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((
void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8693 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_dump))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"numd", 'd', "NUM", CFG_POSITIVE
, &cfg.numd, 1, numd, 0, }, {"eds", 'e', ((void*)0), CFG_FLAG
, &cfg.eds, 0, eds, 0, }, {"raw-binary", 'b', ((void*)0),
CFG_FLAG, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((
void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
8694
8695 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
8696 if (err)
8697 return err;
8698
8699 err = validate_output_format(nvme_args.output_format, &flags);
8700 if (err < 0) {
8701 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
8702 return err;
8703 }
8704
8705 if (cfg.raw_binary)
8706 flags = BINARY;
8707
8708 if (!cfg.nsid) {
8709 err = libnvme_get_nsid(hdl, &cfg.nsid);
8710 if (err < 0) {
8711 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8712 return err;
8713 }
8714 }
8715
8716 if (!cfg.numd || cfg.numd >= (0x1000 >> 2))
8717 cfg.numd = (0x1000 >> 2) - 1;
8718 if (cfg.numd < 3)
8719 cfg.numd = 3;
8720
8721 size = (cfg.numd + 1) << 2;
8722
8723 ctrl = libnvme_alloc(sizeof(*ctrl));
8724 if (!ctrl)
8725 return -ENOMEM12;
8726
8727 err = nvme_identify_ctrl(hdl, ctrl);
8728 if (err) {
8729 nvme_show_error("identify-ctrl: %s", libnvme_strerror(err))nvme_show_message(1, "identify-ctrl: %s", libnvme_strerror(err
))
;
8730 return -errno(*__errno_location ());
8731 }
8732
8733 if (ctrl->ctratt & NVME_CTRL_CTRATT_128_ID)
8734 cfg.eds = true1;
8735
8736 status = libnvme_alloc(size);
8737 if (!status)
8738 return -ENOMEM12;
8739
8740 nvme_init_resv_report(&cmd, cfg.nsid, cfg.eds, false0, status, size);
8741 err = libnvme_exec_io_passthru(hdl, &cmd);
8742 if (err) {
8743 nvme_show_err(err, "reservation report");
8744 return err;
8745 }
8746
8747 nvme_show_resv_report(status, size, cfg.eds, flags);
8748
8749 return err;
8750}
8751
8752unsigned long long elapsed_utime(struct timeval start_time,
8753 struct timeval end_time)
8754{
8755 unsigned long long err = (end_time.tv_sec - start_time.tv_sec) * 1000000 +
8756 (end_time.tv_usec - start_time.tv_usec);
8757 return err;
8758}
8759
8760static int submit_io(int opcode, char *command, const char *desc, int argc, char **argv)
8761{
8762 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
8763 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
8764 unsigned long long buffer_size = 0, mbuffer_size = 0;
8765 __cleanup_free__attribute__((cleanup(shr_freep))) struct nvme_nvm_id_ns *nvm_ns = NULL((void*)0);
8766 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
8767 __cleanup_free__attribute__((cleanup(shr_freep))) struct nvme_id_ns *ns = NULL((void*)0);
8768 unsigned int logical_block_size = 0;
8769 struct timeval start_time, end_time;
8770 __cleanup_free__attribute__((cleanup(shr_freep))) void *mbuffer = NULL((void*)0);
8771 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int dfd = -1, mfd = -1;
8772 __u16 control = 0, nblocks = 0;
8773 struct libnvme_passthru_cmd cmd;
8774 __u8 sts = 0, pif = 0;
8775 bool_Bool pi_available;
8776 __u32 dsmgmt = 0;
8777 int mode = 0644;
8778 void *buffer;
8779 __u16 ms = 0;
8780 int err = 0;
8781 int flags;
8782
8783 const char *start_block_addr = "64-bit addr of first block to access";
8784 const char *block_size = "if specified, logical block size in bytes;\n"
8785 "discovered by identify namespace otherwise";
8786 const char *data_size = "size of data in bytes";
8787 const char *metadata_size = "size of metadata in bytes";
8788 const char *data = "data file";
8789 const char *metadata = "metadata file";
8790 const char *limited_retry_num = "limit num. media access attempts";
8791 const char *show = "show command before sending";
8792 const char *dtype_for_write = "directive type (for write-only)";
8793 const char *dspec = "directive specific (for write-only)";
8794 const char *dsm = "dataset management attributes (lower 8 bits)";
8795 const char *force = "The \"I know what I'm doing\" flag, do not enforce exclusive access for write";
8796
8797 struct config {
8798 __u32 nsid;
8799 __u64 start_block;
8800 __u16 block_count;
8801 __u16 block_size;
8802 __u64 data_size;
8803 __u64 metadata_size;
8804 __u64 ilbrt;
8805 char *data;
8806 char *metadata;
8807 __u8 prinfo;
8808 __u16 lbatm;
8809 __u16 lbat;
8810 __u64 lbst;
8811 bool_Bool limited_retry;
8812 bool_Bool force_unit_access;
8813 bool_Bool stc;
8814 __u8 dtype;
8815 __u16 dspec;
8816 __u8 dsmgmt;
8817 bool_Bool show;
8818 bool_Bool latency;
8819 bool_Bool force;
8820 };
8821
8822 struct config cfg = {
8823 .nsid = 0,
8824 .start_block = 0,
8825 .block_count = 0,
8826 .block_size = 0,
8827 .data_size = 0,
8828 .metadata_size = 0,
8829 .ilbrt = 0,
8830 .data = "",
8831 .metadata = "",
8832 .prinfo = 0,
8833 .lbatm = 0,
8834 .lbat = 0,
8835 .lbst = 0,
8836 .limited_retry = false0,
8837 .force_unit_access = false0,
8838 .stc = false0,
8839 .dtype = 0,
8840 .dspec = 0,
8841 .dsmgmt = 0,
8842 .show = false0,
8843 .latency = false0,
8844 .force = false0,
8845 };
8846
8847 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8848 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8849 OPT_SUFFIX("start-block", 's', &cfg.start_block, start_block_addr),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8850 OPT_SHRT("block-count", 'c', &cfg.block_count, block_count),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8851 OPT_SHRT("block-size", 'b', &cfg.block_size, block_size),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8852 OPT_SUFFIX("data-size", 'z', &cfg.data_size, data_size),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8853 OPT_SUFFIX("metadata-size", 'y', &cfg.metadata_size, metadata_size),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8854 OPT_SUFFIX("ref-tag", 'r', &cfg.ilbrt, ref_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8855 OPT_FILE("data", 'd', &cfg.data, data),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8856 OPT_FILE("metadata", 'M', &cfg.metadata, metadata),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8857 OPT_BYTE("prinfo", 'p', &cfg.prinfo, prinfo),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8858 OPT_SHRT("app-tag-mask", 'm', &cfg.lbatm, app_tag_mask),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8859 OPT_SHRT("app-tag", 'a', &cfg.lbat, app_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8860 OPT_SUFFIX("storage-tag", 'g', &cfg.lbst, storage_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8861 OPT_FLAG("limited-retry", 'l', &cfg.limited_retry, limited_retry_num),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8862 OPT_FLAG("force-unit-access", 'f', &cfg.force_unit_access, force_unit_access),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8863 OPT_FLAG("storage-tag-check", 'C', &cfg.stc, storage_tag_check),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8864 OPT_BYTE("dir-type", 'T', &cfg.dtype, dtype_for_write),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8865 OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8866 OPT_BYTE("dsm", 'D', &cfg.dsmgmt, dsm),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8867 OPT_FLAG("show-command", 'V', &cfg.show, show),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8868 OPT_FLAG("latency", 't', &cfg.latency, latency),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
8869 OPT_FLAG("force", 0, &cfg.force, force))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_id_desired, 0, }, {"start-block", 's', "IONUM"
, CFG_LONG_SUFFIX, &cfg.start_block, 1, start_block_addr,
0, }, {"block-count", 'c', "NUM", CFG_SHORT, &cfg.block_count
, 1, block_count, 0, }, {"block-size", 'b', "NUM", CFG_SHORT,
&cfg.block_size, 1, block_size, 0, }, {"data-size", 'z',
"IONUM", CFG_LONG_SUFFIX, &cfg.data_size, 1, data_size, 0
, }, {"metadata-size", 'y', "IONUM", CFG_LONG_SUFFIX, &cfg
.metadata_size, 1, metadata_size, 0, }, {"ref-tag", 'r', "IONUM"
, CFG_LONG_SUFFIX, &cfg.ilbrt, 1, ref_tag, 0, }, {"data",
'd', "FILE", CFG_STRING, &cfg.data, 1, data, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT, &cfg.lbatm
, 1, app_tag_mask, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &
cfg.lbat, 1, app_tag, 0, }, {"storage-tag", 'g', "IONUM", CFG_LONG_SUFFIX
, &cfg.lbst, 1, storage_tag, 0, }, {"limited-retry", 'l',
((void*)0), CFG_FLAG, &cfg.limited_retry, 0, limited_retry_num
, 0, }, {"force-unit-access", 'f', ((void*)0), CFG_FLAG, &
cfg.force_unit_access, 0, force_unit_access, 0, }, {"storage-tag-check"
, 'C', ((void*)0), CFG_FLAG, &cfg.stc, 0, storage_tag_check
, 0, }, {"dir-type", 'T', "NUM", CFG_BYTE, &cfg.dtype, 1,
dtype_for_write, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &
cfg.dspec, 1, dspec, 0, }, {"dsm", 'D', "NUM", CFG_BYTE, &
cfg.dsmgmt, 1, dsm, 0, }, {"show-command", 'V', ((void*)0), CFG_FLAG
, &cfg.show, 0, show, 0, }, {"latency", 't', ((void*)0), CFG_FLAG
, &cfg.latency, 0, latency, 0, }, {"force", 0, ((void*)0)
, CFG_FLAG, &cfg.force, 0, force, 0, }, {"", 0, ((void*)0
), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, (
(void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args
.verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
8870
8871 if (opcode != nvme_cmd_write) {
8872 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
8873 if (err)
8874 return err;
8875 } else {
8876 err = parse_args(argc, argv, desc, opts);
8877 if (err)
8878 return err;
8879 err = open_exclusive(&ctx, &hdl, argc, argv, cfg.force, opts);
8880 if (err) {
8881 if (err == -EBUSY16) {
8882 nvme_show_error("Failed to open %s.", basename(argv[optind]))nvme_show_message(1, "Failed to open %s.", __xpg_basename(argv
[optind]))
;
8883 nvme_show_error("Namespace is currently busy.")nvme_show_message(1, "Namespace is currently busy.");
8884 if (!cfg.force)
8885 nvme_show_error(nvme_show_message(1, "Use the force [--force] option to ignore that."
)
8886 "Use the force [--force] option to ignore that.")nvme_show_message(1, "Use the force [--force] option to ignore that."
)
;
8887 } else {
8888 argconfig_print_help(desc, opts);
8889 }
8890 return err;
8891 }
8892 }
8893
8894 if (!cfg.nsid) {
8895 err = libnvme_get_nsid(hdl, &cfg.nsid);
8896 if (err < 0) {
8897 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
8898 return err;
8899 }
8900 }
8901
8902 if (cfg.prinfo > 0xf)
8903 return err;
8904
8905 dsmgmt = cfg.dsmgmt;
8906 control |= (cfg.prinfo << 10);
8907 if (cfg.limited_retry)
8908 control |= NVME_IO_LR;
8909 if (cfg.force_unit_access)
8910 control |= NVME_IO_FUA;
8911 if (cfg.stc)
8912 control |= NVME_IO_STC;
8913 if (cfg.dtype) {
8914 if (cfg.dtype > 0xf) {
8915 nvme_show_error("Invalid directive type, %x", cfg.dtype)nvme_show_message(1, "Invalid directive type, %x", cfg.dtype);
8916 return -EINVAL22;
8917 }
8918 control |= cfg.dtype << 4;
8919 dsmgmt |= ((__u32)cfg.dspec) << 16;
8920 }
8921
8922 if (opcode & 1) {
8923 dfd = mfd = STDIN_FILENO0;
8924 flags = O_RDONLY00;
8925 } else {
8926 dfd = mfd = STDOUT_FILENO1;
8927 flags = O_WRONLY01 | O_CREAT0100 | O_TRUNC01000;
8928 }
8929
8930 if (strlen(cfg.data)) {
8931 dfd = nvme_open_rawdata(cfg.data, flags, mode)open((cfg.data), (flags), mode);
8932 if (dfd < 0) {
8933 nvme_show_perror(cfg.data);
8934 return -EINVAL22;
8935 }
8936 }
8937
8938 if (strlen(cfg.metadata)) {
8939 mfd = nvme_open_rawdata(cfg.metadata, flags, mode)open((cfg.metadata), (flags), mode);
8940 if (mfd < 0) {
8941 nvme_show_perror(cfg.metadata);
8942 return -EINVAL22;
8943 }
8944 }
8945
8946 if (!cfg.data_size) {
8947 nvme_show_error("data size not provided")nvme_show_message(1, "data size not provided");
8948 return -EINVAL22;
8949 }
8950
8951 if (cfg.block_size) {
8952 logical_block_size = cfg.block_size;
8953 ms = cfg.metadata_size;
8954 pi_available = true1;
8955 } else {
8956 err = get_pi_info(hdl, cfg.nsid, cfg.prinfo,
8957 cfg.ilbrt, cfg.lbst, &logical_block_size, &ms);
8958 pi_available = err == 0;
8959 }
8960
8961 buffer_size = ((long long)cfg.block_count + 1) * logical_block_size;
8962 if (cfg.data_size < buffer_size)
8963 nvme_show_error("Rounding data size to fit block count (%lld bytes)", buffer_size)nvme_show_message(1, "Rounding data size to fit block count (%lld bytes)"
, buffer_size)
;
8964 else
8965 buffer_size = cfg.data_size;
8966
8967 if (argconfig_parse_seen(opts, "block-count")) {
8968 /* Use the value provided */
8969 nblocks = cfg.block_count;
8970 } else {
8971 /* Get the required block count. Note this is a zeroes based value. */
8972 nblocks = ((buffer_size + (logical_block_size - 1)) / logical_block_size) - 1;
8973
8974 /* Update the data size based on the required block count */
8975 buffer_size = ((unsigned long long)nblocks + 1) * logical_block_size;
8976 }
8977
8978 buffer = libnvme_alloc_huge(buffer_size, &mh);
8979 if (!buffer) {
8980 nvme_show_error("failed to allocate huge memory")nvme_show_message(1, "failed to allocate huge memory");
8981 return -ENOMEM12;
8982 }
8983
8984 if (cfg.metadata_size) {
8985 mbuffer_size = ((unsigned long long)cfg.block_count + 1) * ms;
8986 if (ms && cfg.metadata_size < mbuffer_size)
8987 nvme_show_error("Rounding metadata size to fit block count (%lld bytes)",nvme_show_message(1, "Rounding metadata size to fit block count (%lld bytes)"
, mbuffer_size)
8988 mbuffer_size)nvme_show_message(1, "Rounding metadata size to fit block count (%lld bytes)"
, mbuffer_size)
;
8989 else
8990 mbuffer_size = cfg.metadata_size;
8991
8992 mbuffer = malloc(mbuffer_size);
8993 if (!mbuffer)
8994 return -ENOMEM12;
8995 memset(mbuffer, 0, mbuffer_size);
8996 }
8997
8998 if (opcode & 1) {
8999 err = read(dfd, (void *)buffer, cfg.data_size);
9000 if (err < 0) {
9001 err = -errno(*__errno_location ());
9002 nvme_show_error("failed to read data buffer from input file %s", libnvme_strerror(errno))nvme_show_message(1, "failed to read data buffer from input file %s"
, libnvme_strerror((*__errno_location ())))
;
9003 return err;
9004 }
9005 }
9006
9007 if ((opcode & 1) && cfg.metadata_size) {
9008 err = read(mfd, (void *)mbuffer, mbuffer_size);
9009 if (err < 0) {
9010 err = -errno(*__errno_location ());
9011 nvme_show_error("failed to read meta-data buffer from input file %s", libnvme_strerror(errno))nvme_show_message(1, "failed to read meta-data buffer from input file %s"
, libnvme_strerror((*__errno_location ())))
;
9012 return err;
9013 }
9014 }
9015
9016 if (cfg.show || nvme_args.dry_run) {
9017 nvme_show_result("opcode : %02x", opcode)nvme_show_message(0, "opcode : %02x", opcode);
9018 nvme_show_result("nsid : %02x", cfg.nsid)nvme_show_message(0, "nsid : %02x", cfg.nsid);
9019 nvme_show_result("flags : %02x", 0)nvme_show_message(0, "flags : %02x", 0);
9020 nvme_show_result("control : %04x", control)nvme_show_message(0, "control : %04x", control);
9021 nvme_show_result("nblocks : %04x", nblocks)nvme_show_message(0, "nblocks : %04x", nblocks);
9022 nvme_show_result("metadata : %"PRIx64, (uint64_t)(uintptr_t)mbuffer)nvme_show_message(0, "metadata : %""l" "x", (uint64_t)(uintptr_t
)mbuffer)
;
9023 nvme_show_result("addr : %"PRIx64, (uint64_t)(uintptr_t)buffer)nvme_show_message(0, "addr : %""l" "x", (uint64_t)(uintptr_t
)buffer)
;
9024 nvme_show_result("slba : %"PRIx64, (uint64_t)cfg.start_block)nvme_show_message(0, "slba : %""l" "x", (uint64_t)cfg
.start_block)
;
9025 nvme_show_result("dsmgmt : %08x", dsmgmt)nvme_show_message(0, "dsmgmt : %08x", dsmgmt);
9026 nvme_show_result("reftag : %"PRIx64, (uint64_t)cfg.ilbrt)nvme_show_message(0, "reftag : %""l" "x", (uint64_t)cfg
.ilbrt)
;
9027 nvme_show_result("apptag : %04x", cfg.lbat)nvme_show_message(0, "apptag : %04x", cfg.lbat);
9028 nvme_show_result("appmask : %04x", cfg.lbatm)nvme_show_message(0, "appmask : %04x", cfg.lbatm);
9029 nvme_show_result("storagetagcheck : %04x", cfg.stc)nvme_show_message(0, "storagetagcheck : %04x", cfg.stc);
9030 nvme_show_result("storagetag : %"PRIx64, (uint64_t)cfg.lbst)nvme_show_message(0, "storagetag : %""l" "x", (uint64_t)
cfg.lbst)
;
9031 nvme_show_result("pif : %02x", pif)nvme_show_message(0, "pif : %02x", pif);
9032 nvme_show_result("sts : %02x", sts)nvme_show_message(0, "sts : %02x", sts);
9033 }
9034 if (nvme_args.dry_run)
9035 return 0;
9036
9037 nvme_init_io(&cmd, opcode, cfg.nsid, cfg.start_block, buffer,
9038 buffer_size, mbuffer, mbuffer_size);
9039 cmd.cdw12 = NVME_FIELD_ENCODE(nblocks,(((__u32)(nblocks) & (NVME_IOCS_COMMON_CDW12_NLB_MASK)) <<
(NVME_IOCS_COMMON_CDW12_NLB_SHIFT))
9040 NVME_IOCS_COMMON_CDW12_NLB_SHIFT,(((__u32)(nblocks) & (NVME_IOCS_COMMON_CDW12_NLB_MASK)) <<
(NVME_IOCS_COMMON_CDW12_NLB_SHIFT))
9041 NVME_IOCS_COMMON_CDW12_NLB_MASK)(((__u32)(nblocks) & (NVME_IOCS_COMMON_CDW12_NLB_MASK)) <<
(NVME_IOCS_COMMON_CDW12_NLB_SHIFT))
|
9042 NVME_FIELD_ENCODE(control,(((__u32)(control) & (NVME_IOCS_COMMON_CDW12_CONTROL_MASK
)) << (NVME_IOCS_COMMON_CDW12_CONTROL_SHIFT))
9043 NVME_IOCS_COMMON_CDW12_CONTROL_SHIFT,(((__u32)(control) & (NVME_IOCS_COMMON_CDW12_CONTROL_MASK
)) << (NVME_IOCS_COMMON_CDW12_CONTROL_SHIFT))
9044 NVME_IOCS_COMMON_CDW12_CONTROL_MASK)(((__u32)(control) & (NVME_IOCS_COMMON_CDW12_CONTROL_MASK
)) << (NVME_IOCS_COMMON_CDW12_CONTROL_SHIFT))
;
9045 cmd.cdw13 = NVME_FIELD_ENCODE(cfg.dspec,(((__u32)(cfg.dspec) & (NVME_IOCS_COMMON_CDW13_DSPEC_MASK
)) << (NVME_IOCS_COMMON_CDW13_DSPEC_SHIFT))
9046 NVME_IOCS_COMMON_CDW13_DSPEC_SHIFT,(((__u32)(cfg.dspec) & (NVME_IOCS_COMMON_CDW13_DSPEC_MASK
)) << (NVME_IOCS_COMMON_CDW13_DSPEC_SHIFT))
9047 NVME_IOCS_COMMON_CDW13_DSPEC_MASK)(((__u32)(cfg.dspec) & (NVME_IOCS_COMMON_CDW13_DSPEC_MASK
)) << (NVME_IOCS_COMMON_CDW13_DSPEC_SHIFT))
|
9048 NVME_FIELD_ENCODE(cfg.dsmgmt,(((__u32)(cfg.dsmgmt) & (NVME_IOCS_COMMON_CDW13_DSM_MASK)
) << (NVME_IOCS_COMMON_CDW13_DSM_SHIFT))
9049 NVME_IOCS_COMMON_CDW13_DSM_SHIFT,(((__u32)(cfg.dsmgmt) & (NVME_IOCS_COMMON_CDW13_DSM_MASK)
) << (NVME_IOCS_COMMON_CDW13_DSM_SHIFT))
9050 NVME_IOCS_COMMON_CDW13_DSM_MASK)(((__u32)(cfg.dsmgmt) & (NVME_IOCS_COMMON_CDW13_DSM_MASK)
) << (NVME_IOCS_COMMON_CDW13_DSM_SHIFT))
;
9051 if (pi_available) {
9052 err = init_pi_tags(hdl, &cmd, cfg.nsid, cfg.ilbrt, cfg.lbst,
9053 cfg.lbat, cfg.lbatm);
9054 if (err)
9055 return err;
9056 }
9057 gettimeofday(&start_time, NULL((void*)0));
9058 err = libnvme_exec_io_passthru(hdl, &cmd);
9059 gettimeofday(&end_time, NULL((void*)0));
9060 if (cfg.latency)
9061 nvme_show_result(" latency: %s: %llu us", command, elapsed_utime(start_time, end_time))nvme_show_message(0, " latency: %s: %llu us", command, elapsed_utime
(start_time, end_time))
;
9062 if (err) {
9063 nvme_show_err(err, "submit-io");
9064 return err;
9065 }
9066
9067 if (!(opcode & 1) && write(dfd, (void *)buffer, buffer_size) < 0) {
9068 nvme_show_error(nvme_show_message(1, "write: %s: failed to write buffer to output file"
, libnvme_strerror((*__errno_location ())))
9069 "write: %s: failed to write buffer to output file",nvme_show_message(1, "write: %s: failed to write buffer to output file"
, libnvme_strerror((*__errno_location ())))
9070 libnvme_strerror(errno))nvme_show_message(1, "write: %s: failed to write buffer to output file"
, libnvme_strerror((*__errno_location ())))
;
9071 err = -EINVAL22;
9072 } else if (!(opcode & 1) && cfg.metadata_size &&
9073 write(mfd, (void *)mbuffer, mbuffer_size) < 0) {
9074 nvme_show_error(nvme_show_message(1, "write: %s: failed to write meta-data buffer to output file"
, libnvme_strerror((*__errno_location ())))
9075 "write: %s: failed to write meta-data buffer to output file",nvme_show_message(1, "write: %s: failed to write meta-data buffer to output file"
, libnvme_strerror((*__errno_location ())))
9076 libnvme_strerror(errno))nvme_show_message(1, "write: %s: failed to write meta-data buffer to output file"
, libnvme_strerror((*__errno_location ())))
;
9077 err = -EINVAL22;
9078 } else {
9079 nvme_show_verbose_result("%s: Success", command)nvme_show_verbose_message("%s: Success", command);
9080 }
9081
9082 return err;
9083}
9084
9085static int compare(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9086{
9087 const char *desc = "Compare specified logical blocks on\n"
9088 "device with specified data buffer; return failure if buffer\n"
9089 "and block(s) are dissimilar";
9090
9091 return submit_io(nvme_cmd_compare, "compare", desc, argc, argv);
9092}
9093
9094static int read_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9095{
9096 const char *desc = "Copy specified logical blocks on the given\n"
9097 "device to specified data buffer (default buffer is stdout).";
9098
9099 return submit_io(nvme_cmd_read, "read", desc, argc, argv);
9100}
9101
9102static int write_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9103{
9104 const char *desc = "Copy from provided data buffer (default\n"
9105 "buffer is stdin) to specified logical blocks on the given device.";
9106
9107 return submit_io(nvme_cmd_write, "write", desc, argc, argv);
9108}
9109
9110static int verify_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9111{
9112 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
9113 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
9114 struct libnvme_passthru_cmd cmd;
9115 __u16 control = 0;
9116 int err;
9117
9118 const char *desc = "Verify specified logical blocks on the given device.";
9119 const char *force_unit_access_verify =
9120 "force device to commit cached data before performing the verify operation";
9121 const char *storage_tag_check =
9122 "This bit specifies the Storage Tag field shall be checked as part of Verify operation";
9123
9124 struct config {
9125 __u32 nsid;
9126 __u64 start_block;
9127 __u16 block_count;
9128 bool_Bool limited_retry;
9129 bool_Bool force_unit_access;
9130 __u8 prinfo;
9131 __u32 ilbrt;
9132 __u16 lbat;
9133 __u16 lbatm;
9134 __u64 lbst;
9135 bool_Bool stc;
9136 };
9137
9138 struct config cfg = {
9139 .nsid = 0,
9140 .start_block = 0,
9141 .block_count = 0,
9142 .limited_retry = false0,
9143 .force_unit_access = false0,
9144 .prinfo = 0,
9145 .ilbrt = 0,
9146 .lbat = 0,
9147 .lbatm = 0,
9148 .lbst = 0,
9149 .stc = false0,
9150 };
9151
9152 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9153 OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9154 OPT_SUFFIX("start-block", 's', &cfg.start_block, start_block),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9155 OPT_SHRT("block-count", 'c', &cfg.block_count, block_count),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9156 OPT_FLAG("limited-retry", 'l', &cfg.limited_retry, limited_retry),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9157 OPT_FLAG("force-unit-access", 'f', &cfg.force_unit_access, force_unit_access_verify),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9158 OPT_BYTE("prinfo", 'p', &cfg.prinfo, prinfo),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9159 OPT_SUFFIX("ref-tag", 'r', &cfg.ilbrt, ref_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9160 OPT_SHRT("app-tag", 'a', &cfg.lbat, app_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9161 OPT_SHRT("app-tag-mask", 'm', &cfg.lbatm, app_tag_mask),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9162 OPT_SUFFIX("storage-tag", 'S', &cfg.lbst, storage_tag),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9163 OPT_FLAG("storage-tag-check", 'C', &cfg.stc, storage_tag_check))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.nsid
, 1, namespace_desired, 0, }, {"start-block", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.start_block, 1, start_block, 0, }, {"block-count",
'c', "NUM", CFG_SHORT, &cfg.block_count, 1, block_count,
0, }, {"limited-retry", 'l', ((void*)0), CFG_FLAG, &cfg.
limited_retry, 0, limited_retry, 0, }, {"force-unit-access", 'f'
, ((void*)0), CFG_FLAG, &cfg.force_unit_access, 0, force_unit_access_verify
, 0, }, {"prinfo", 'p', "NUM", CFG_BYTE, &cfg.prinfo, 1, prinfo
, 0, }, {"ref-tag", 'r', "IONUM", CFG_LONG_SUFFIX, &cfg.ilbrt
, 1, ref_tag, 0, }, {"app-tag", 'a', "NUM", CFG_SHORT, &cfg
.lbat, 1, app_tag, 0, }, {"app-tag-mask", 'm', "NUM", CFG_SHORT
, &cfg.lbatm, 1, app_tag_mask, 0, }, {"storage-tag", 'S',
"IONUM", CFG_LONG_SUFFIX, &cfg.lbst, 1, storage_tag, 0, }
, {"storage-tag-check", 'C', ((void*)0), CFG_FLAG, &cfg.stc
, 0, storage_tag_check, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
9164
9165
9166 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
9167 if (err)
9168 return err;
9169
9170 err = open_fallback_chardev(ctx, cfg.nsid, &hdl);
9171 if (err)
9172 return err;
9173
9174 if (cfg.prinfo > 0xf)
9175 return -EINVAL22;
9176
9177 control |= (cfg.prinfo << 10);
9178 if (cfg.limited_retry)
9179 control |= NVME_IO_LR;
9180 if (cfg.force_unit_access)
9181 control |= NVME_IO_FUA;
9182 if (cfg.stc)
9183 control |= NVME_IO_STC;
9184
9185 if (!cfg.nsid) {
9186 err = libnvme_get_nsid(hdl, &cfg.nsid);
9187 if (err < 0) {
9188 nvme_show_error("get-namespace-id: %s", libnvme_strerror(-err))nvme_show_message(1, "get-namespace-id: %s", libnvme_strerror
(-err))
;
9189 return err;
9190 }
9191 }
9192
9193 nvme_init_verify(&cmd, cfg.nsid, cfg.start_block,
9194 cfg.block_count, control, 0, NULL((void*)0), 0, NULL((void*)0), 0);
9195 err = init_pi_tags(hdl, &cmd, cfg.nsid, cfg.ilbrt, cfg.lbst,
9196 cfg.lbat, cfg.lbatm);
9197 if (err != 0 && err != NVME_SC_INVALID_FIELD)
9198 return err;
9199 err = libnvme_exec_io_passthru(hdl, &cmd);
9200 if (err) {
9201 nvme_show_err(err, "verify");
9202 return err;
9203 }
9204
9205 nvme_show_verbose_result("NVME Verify Success")nvme_show_verbose_message("NVME Verify Success");
9206
9207 return err;
9208}
9209
9210static int sec_recv(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9211{
9212 const char *desc = "Obtain results of one or more\n"
9213 "previously submitted security-sends. Results, and association\n"
9214 "between Security Send and Receive, depend on the security\n"
9215 "protocol field as they are defined by the security protocol\n"
9216 "used. A Security Receive must follow a Security Send made with\n"
9217 "the same security protocol.";
9218 const char *size = "size of buffer (prints to stdout on success)";
9219 const char *al = "allocation length (cf. SPC-4)";
9220
9221 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
9222 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
9223 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *sec_buf = NULL((void*)0);
9224 struct libnvme_passthru_cmd cmd;
9225 nvme_print_flags_t flags;
9226 int err;
9227
9228 struct config {
9229 bool_Bool ish;
9230 __u32 namespace_id;
9231 __u32 size;
9232 __u8 nssf;
9233 __u8 secp;
9234 __u16 spsp;
9235 __u32 al;
9236 bool_Bool raw_binary;
9237 };
9238
9239 struct config cfg = {
9240 .ish = false0,
9241 .namespace_id = 0,
9242 .size = 0,
9243 .nssf = 0,
9244 .secp = 0,
9245 .spsp = 0,
9246 .al = 0,
9247 .raw_binary = false0,
9248 };
9249
9250 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9251 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9252 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9253 OPT_UINT("size", 'x', &cfg.size, size),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9254 OPT_BYTE("nssf", 'N', &cfg.nssf, nssf),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9255 OPT_BYTE("secp", 'p', &cfg.secp, secp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9256 OPT_SHRT("spsp", 's', &cfg.spsp, spsp),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9257 OPT_UINT("al", 't', &cfg.al, al),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9258 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_dump))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"size", 'x', "NUM", CFG_POSITIVE
, &cfg.size, 1, size, 0, }, {"nssf", 'N', "NUM", CFG_BYTE
, &cfg.nssf, 1, nssf, 0, }, {"secp", 'p', "NUM", CFG_BYTE
, &cfg.secp, 1, secp, 0, }, {"spsp", 's', "NUM", CFG_SHORT
, &cfg.spsp, 1, spsp, 0, }, {"al", 't', "NUM", CFG_POSITIVE
, &cfg.al, 1, al, 0, }, {"raw-binary", 'b', ((void*)0), CFG_FLAG
, &cfg.raw_binary, 0, raw_dump, 0, }, {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options", 0, ((void
*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &nvme_args.
verbose, 0, "Increase output verbosity", 0, }, {"quiet", 0, (
(void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
9259
9260 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
9261 if (err)
9262 return err;
9263
9264 err = validate_output_format(nvme_args.output_format, &flags);
9265 if (err < 0) {
9266 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
9267 return err;
9268 }
9269
9270 if (cfg.size) {
9271 sec_buf = libnvme_alloc(cfg.size);
9272 if (!sec_buf)
9273 return -ENOMEM12;
9274 }
9275
9276 if (cfg.ish) {
9277 if (libnvme_transport_handle_is_mi(hdl))
9278 nvme_init_mi_cmd_flags(&cmd, ish);
9279 else
9280 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
9281 }
9282
9283 nvme_init_security_receive(&cmd, cfg.namespace_id, cfg.nssf, cfg.spsp,
9284 cfg.secp, cfg.al, sec_buf, cfg.size);
9285 err = libnvme_exec_admin_passthru(hdl, &cmd);
9286 if (err) {
9287 nvme_show_err(err, "security receive");
9288 return err;
9289 }
9290
9291 nvme_show_verbose_result("NVME Security Receive Command Success")nvme_show_verbose_message("NVME Security Receive Command Success"
)
;
9292 if (!cfg.raw_binary)
9293 d(sec_buf, cfg.size, 16, 1);
9294 else if (cfg.size)
9295 d_raw((unsigned char *)sec_buf, cfg.size);
9296
9297 return err;
9298}
9299
9300static int get_lba_status(int argc, char **argv, struct command *acmd,
9301 struct plugin *plugin)
9302{
9303 const char *desc = "Information about potentially unrecoverable LBAs.";
9304 const char *slba =
9305 "Starting LBA(SLBA) in 64-bit address of the first logical block addressed by this command";
9306 const char *mndw =
9307 "Maximum Number of Dwords(MNDW) specifies maximum number of dwords to return";
9308 const char *atype = "Action Type(ATYPE) specifies the mechanism\n"
9309 "the controller uses in determining the LBA Status Descriptors to return.";
9310 const char *rl =
9311 "Range Length(RL) specifies the length of the range of contiguous LBAs beginning at SLBA";
9312
9313 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
9314 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
9315 struct libnvme_passthru_cmd cmd;
9316 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *buf = NULL((void*)0);
9317 nvme_print_flags_t flags;
9318 unsigned long buf_len;
9319 int err;
9320
9321 struct config {
9322 bool_Bool ish;
9323 __u32 namespace_id;
9324 __u64 slba;
9325 __u32 mndw;
9326 __u8 atype;
9327 __u16 rl;
9328 };
9329
9330 struct config cfg = {
9331 .ish = false0,
9332 .namespace_id = 0,
9333 .slba = 0,
9334 .mndw = 0,
9335 .atype = 0,
9336 .rl = 0,
9337 };
9338
9339 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-lba", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.slba, 1, slba, 0, }, {"max-dw", 'm', "NUM", CFG_POSITIVE
, &cfg.mndw, 1, mndw, 0, }, {"action", 'a', "NUM", CFG_BYTE
, &cfg.atype, 1, atype, 0, }, {"range-len", 'l', "NUM", CFG_SHORT
, &cfg.rl, 1, rl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9340 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-lba", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.slba, 1, slba, 0, }, {"max-dw", 'm', "NUM", CFG_POSITIVE
, &cfg.mndw, 1, mndw, 0, }, {"action", 'a', "NUM", CFG_BYTE
, &cfg.atype, 1, atype, 0, }, {"range-len", 'l', "NUM", CFG_SHORT
, &cfg.rl, 1, rl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9341 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-lba", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.slba, 1, slba, 0, }, {"max-dw", 'm', "NUM", CFG_POSITIVE
, &cfg.mndw, 1, mndw, 0, }, {"action", 'a', "NUM", CFG_BYTE
, &cfg.atype, 1, atype, 0, }, {"range-len", 'l', "NUM", CFG_SHORT
, &cfg.rl, 1, rl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9342 OPT_SUFFIX("start-lba", 's', &cfg.slba, slba),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-lba", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.slba, 1, slba, 0, }, {"max-dw", 'm', "NUM", CFG_POSITIVE
, &cfg.mndw, 1, mndw, 0, }, {"action", 'a', "NUM", CFG_BYTE
, &cfg.atype, 1, atype, 0, }, {"range-len", 'l', "NUM", CFG_SHORT
, &cfg.rl, 1, rl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9343 OPT_UINT("max-dw", 'm', &cfg.mndw, mndw),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-lba", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.slba, 1, slba, 0, }, {"max-dw", 'm', "NUM", CFG_POSITIVE
, &cfg.mndw, 1, mndw, 0, }, {"action", 'a', "NUM", CFG_BYTE
, &cfg.atype, 1, atype, 0, }, {"range-len", 'l', "NUM", CFG_SHORT
, &cfg.rl, 1, rl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9344 OPT_BYTE("action", 'a', &cfg.atype, atype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-lba", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.slba, 1, slba, 0, }, {"max-dw", 'm', "NUM", CFG_POSITIVE
, &cfg.mndw, 1, mndw, 0, }, {"action", 'a', "NUM", CFG_BYTE
, &cfg.atype, 1, atype, 0, }, {"range-len", 'l', "NUM", CFG_SHORT
, &cfg.rl, 1, rl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9345 OPT_SHRT("range-len", 'l', &cfg.rl, rl))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"start-lba", 's', "IONUM", CFG_LONG_SUFFIX
, &cfg.slba, 1, slba, 0, }, {"max-dw", 'm', "NUM", CFG_POSITIVE
, &cfg.mndw, 1, mndw, 0, }, {"action", 'a', "NUM", CFG_BYTE
, &cfg.atype, 1, atype, 0, }, {"range-len", 'l', "NUM", CFG_SHORT
, &cfg.rl, 1, rl, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
9346
9347 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
9348 if (err)
9349 return err;
9350
9351 err = validate_output_format(nvme_args.output_format, &flags);
9352 if (err < 0) {
9353 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
9354 return err;
9355 }
9356
9357 if (!cfg.atype) {
9358 nvme_show_error("action type (--action) has to be given")nvme_show_message(1, "action type (--action) has to be given"
)
;
9359 return -EINVAL22;
9360 }
9361
9362 buf_len = (cfg.mndw + 1) * 4;
9363 buf = libnvme_alloc(buf_len);
9364 if (!buf)
9365 return -ENOMEM12;
9366
9367 nvme_init_get_lba_status(&cmd, cfg.namespace_id, cfg.slba, cfg.mndw,
9368 cfg.atype, cfg.rl, buf);
9369 if (cfg.ish) {
9370 if (libnvme_transport_handle_is_mi(hdl))
9371 nvme_init_mi_cmd_flags(&cmd, ish);
9372 else
9373 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
9374 }
9375 err = libnvme_exec_admin_passthru(hdl, &cmd);
9376 if (err) {
9377 nvme_show_err(err, "get lba status");
9378 return err;
9379 }
9380
9381 nvme_show_lba_status(buf, buf_len, flags);
9382
9383 return err;
9384}
9385
9386static int capacity_mgmt(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9387{
9388 const char *desc = "Host software uses the Capacity Management command to\n"
9389 "configure Endurance Groups and NVM Sets in an NVM subsystem by either\n"
9390 "selecting one of a set of supported configurations or by specifying the\n"
9391 "capacity of the Endurance Group or NVM Set to be created";
9392 const char *operation = "Operation to be performed by the controller";
9393 const char *element_id = "Value specific to the value of the Operation field.";
9394 const char *cap_lower =
9395 "Least significant 32 bits of the capacity in bytes of the Endurance Group or NVM Set to be created";
9396 const char *cap_upper =
9397 "Most significant 32 bits of the capacity in bytes of the Endurance Group or NVM Set to be created";
9398
9399 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
9400 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
9401 struct libnvme_passthru_cmd cmd;
9402 int err = -1;
9403 nvme_print_flags_t flags;
9404
9405 struct config {
9406 bool_Bool ish;
9407 __u8 operation;
9408 __u16 element_id;
9409 __u32 dw11;
9410 __u32 dw12;
9411 };
9412
9413 struct config cfg = {
9414 .ish = false0,
9415 .operation = 0xff,
9416 .element_id = 0xffff,
9417 .dw11 = 0,
9418 .dw12 = 0,
9419 };
9420
9421 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"operation", 'O', "NUM", CFG_BYTE, &cfg.operation
, 1, operation, 0, }, {"element-id", 'i', "NUM", CFG_SHORT, &
cfg.element_id, 1, element_id, 0, }, {"cap-lower", 'l', "NUM"
, CFG_POSITIVE, &cfg.dw11, 1, cap_lower, 0, }, {"cap-upper"
, 'u', "NUM", CFG_POSITIVE, &cfg.dw12, 1, cap_upper, 0, }
, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9422 OPT_FLAG("ish", 'I', &cfg.ish, ish),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"operation", 'O', "NUM", CFG_BYTE, &cfg.operation
, 1, operation, 0, }, {"element-id", 'i', "NUM", CFG_SHORT, &
cfg.element_id, 1, element_id, 0, }, {"cap-lower", 'l', "NUM"
, CFG_POSITIVE, &cfg.dw11, 1, cap_lower, 0, }, {"cap-upper"
, 'u', "NUM", CFG_POSITIVE, &cfg.dw12, 1, cap_upper, 0, }
, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9423 OPT_BYTE("operation", 'O', &cfg.operation, operation),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"operation", 'O', "NUM", CFG_BYTE, &cfg.operation
, 1, operation, 0, }, {"element-id", 'i', "NUM", CFG_SHORT, &
cfg.element_id, 1, element_id, 0, }, {"cap-lower", 'l', "NUM"
, CFG_POSITIVE, &cfg.dw11, 1, cap_lower, 0, }, {"cap-upper"
, 'u', "NUM", CFG_POSITIVE, &cfg.dw12, 1, cap_upper, 0, }
, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9424 OPT_SHRT("element-id", 'i', &cfg.element_id, element_id),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"operation", 'O', "NUM", CFG_BYTE, &cfg.operation
, 1, operation, 0, }, {"element-id", 'i', "NUM", CFG_SHORT, &
cfg.element_id, 1, element_id, 0, }, {"cap-lower", 'l', "NUM"
, CFG_POSITIVE, &cfg.dw11, 1, cap_lower, 0, }, {"cap-upper"
, 'u', "NUM", CFG_POSITIVE, &cfg.dw12, 1, cap_upper, 0, }
, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9425 OPT_UINT("cap-lower", 'l', &cfg.dw11, cap_lower),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"operation", 'O', "NUM", CFG_BYTE, &cfg.operation
, 1, operation, 0, }, {"element-id", 'i', "NUM", CFG_SHORT, &
cfg.element_id, 1, element_id, 0, }, {"cap-lower", 'l', "NUM"
, CFG_POSITIVE, &cfg.dw11, 1, cap_lower, 0, }, {"cap-upper"
, 'u', "NUM", CFG_POSITIVE, &cfg.dw12, 1, cap_upper, 0, }
, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9426 OPT_UINT("cap-upper", 'u', &cfg.dw12, cap_upper))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ish", 'I', ((void*)0), CFG_FLAG, &cfg.ish, 0, ish
, 0, }, {"operation", 'O', "NUM", CFG_BYTE, &cfg.operation
, 1, operation, 0, }, {"element-id", 'i', "NUM", CFG_SHORT, &
cfg.element_id, 1, element_id, 0, }, {"cap-lower", 'l', "NUM"
, CFG_POSITIVE, &cfg.dw11, 1, cap_lower, 0, }, {"cap-upper"
, 'u', "NUM", CFG_POSITIVE, &cfg.dw12, 1, cap_upper, 0, }
, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
9427
9428
9429 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
9430 if (err)
9431 return err;
9432
9433 err = validate_output_format(nvme_args.output_format, &flags);
9434 if (err < 0) {
9435 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
9436 return err;
9437 }
9438
9439 if (cfg.operation > 0xf) {
9440 nvme_show_error("invalid operation field: %u", cfg.operation)nvme_show_message(1, "invalid operation field: %u", cfg.operation
)
;
9441 return -1;
9442 }
9443
9444 nvme_init_capacity_mgmt(&cmd, cfg.operation, cfg.element_id,
9445 (__u64)cfg.dw12 << 32 | cfg.dw11);
9446 if (cfg.ish) {
9447 if (libnvme_transport_handle_is_mi(hdl))
9448 nvme_init_mi_cmd_flags(&cmd, ish);
9449 else
9450 nvme_show_error("ISH is supported only for NVMe-MI")nvme_show_message(1, "ISH is supported only for NVMe-MI");
9451 }
9452 err = libnvme_exec_admin_passthru(hdl, &cmd);
9453 if (err) {
9454 nvme_show_err(err, "capacity management");
9455 return err;
9456 }
9457
9458 nvme_show_verbose_result("Capacity Management Command is Success")nvme_show_verbose_message("Capacity Management Command is Success"
)
;
9459
9460 if (cfg.operation == 1)
9461 nvme_show_result("Created Element Identifier for Endurance Group is: %"nvme_show_message(0, "Created Element Identifier for Endurance Group is: %"
"l" "u", (uint64_t)cmd.result)
9462 PRIu64, (uint64_t)cmd.result)nvme_show_message(0, "Created Element Identifier for Endurance Group is: %"
"l" "u", (uint64_t)cmd.result)
;
9463 else if (cfg.operation == 3)
9464 nvme_show_result("Created Element Identifier for NVM Set is: %"nvme_show_message(0, "Created Element Identifier for NVM Set is: %"
"l" "u", (uint64_t)cmd.result)
9465 PRIu64, (uint64_t)cmd.result)nvme_show_message(0, "Created Element Identifier for NVM Set is: %"
"l" "u", (uint64_t)cmd.result)
;
9466
9467 return err;
9468}
9469
9470static int dir_receive(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9471{
9472 const char *desc = "Read directive parameters of the specified directive type.";
9473 const char *nsr = "namespace stream requested";
9474
9475 nvme_print_flags_t flags = NORMAL;
9476 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
9477 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
9478 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) void *buf = NULL((void*)0);
9479 struct libnvme_passthru_cmd cmd;
9480 __u32 dw12 = 0;
9481 int err;
9482
9483 struct config {
9484 __u32 namespace_id;
9485 __u32 data_len;
9486 bool_Bool raw_binary;
9487 __u8 dtype;
9488 __u16 dspec;
9489 __u8 doper;
9490 __u16 nsr; /* dw12 for NVME_DIR_ST_RCVOP_STATUS */
9491 };
9492
9493 struct config cfg = {
9494 .namespace_id = 1,
9495 .data_len = 0,
9496 .raw_binary = false0,
9497 .dtype = 0,
9498 .dspec = 0,
9499 .doper = 0,
9500 .nsr = 0,
9501 };
9502
9503 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"raw-binary", 'b', ((
void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_directive, 0,
}, {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"dir-oper", 'O', "NUM", CFG_BYTE, &
cfg.doper, 1, doper, 0, }, {"req-resource", 'r', "NUM", CFG_SHORT
, &cfg.nsr, 1, nsr, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9504 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"raw-binary", 'b', ((
void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_directive, 0,
}, {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"dir-oper", 'O', "NUM", CFG_BYTE, &
cfg.doper, 1, doper, 0, }, {"req-resource", 'r', "NUM", CFG_SHORT
, &cfg.nsr, 1, nsr, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9505 OPT_UINT("data-len", 'l', &cfg.data_len, buf_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"raw-binary", 'b', ((
void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_directive, 0,
}, {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"dir-oper", 'O', "NUM", CFG_BYTE, &
cfg.doper, 1, doper, 0, }, {"req-resource", 'r', "NUM", CFG_SHORT
, &cfg.nsr, 1, nsr, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9506 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_directive),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"raw-binary", 'b', ((
void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_directive, 0,
}, {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"dir-oper", 'O', "NUM", CFG_BYTE, &
cfg.doper, 1, doper, 0, }, {"req-resource", 'r', "NUM", CFG_SHORT
, &cfg.nsr, 1, nsr, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9507 OPT_BYTE("dir-type", 'D', &cfg.dtype, dtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"raw-binary", 'b', ((
void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_directive, 0,
}, {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"dir-oper", 'O', "NUM", CFG_BYTE, &
cfg.doper, 1, doper, 0, }, {"req-resource", 'r', "NUM", CFG_SHORT
, &cfg.nsr, 1, nsr, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9508 OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec_w_dtype),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"raw-binary", 'b', ((
void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_directive, 0,
}, {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"dir-oper", 'O', "NUM", CFG_BYTE, &
cfg.doper, 1, doper, 0, }, {"req-resource", 'r', "NUM", CFG_SHORT
, &cfg.nsr, 1, nsr, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9509 OPT_BYTE("dir-oper", 'O', &cfg.doper, doper),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"raw-binary", 'b', ((
void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_directive, 0,
}, {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"dir-oper", 'O', "NUM", CFG_BYTE, &
cfg.doper, 1, doper, 0, }, {"req-resource", 'r', "NUM", CFG_SHORT
, &cfg.nsr, 1, nsr, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9510 OPT_SHRT("req-resource", 'r', &cfg.nsr, nsr))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, buf_len, 0, }, {"raw-binary", 'b', ((
void*)0), CFG_FLAG, &cfg.raw_binary, 0, raw_directive, 0,
}, {"dir-type", 'D', "NUM", CFG_BYTE, &cfg.dtype, 1, dtype
, 0, }, {"dir-spec", 'S', "NUM", CFG_SHORT, &cfg.dspec, 1
, dspec_w_dtype, 0, }, {"dir-oper", 'O', "NUM", CFG_BYTE, &
cfg.doper, 1, doper, 0, }, {"req-resource", 'r', "NUM", CFG_SHORT
, &cfg.nsr, 1, nsr, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
9511
9512 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
9513 if (err)
9514 return err;
9515
9516 if (nvme_args.verbose)
9517 flags |= VERBOSE;
9518 if (cfg.raw_binary)
9519 flags = BINARY;
9520
9521 switch (cfg.dtype) {
9522 case NVME_DIRECTIVE_DTYPE_IDENTIFY:
9523 switch (cfg.doper) {
9524 case NVME_DIRECTIVE_RECEIVE_IDENTIFY_DOPER_PARAM:
9525 if (!cfg.data_len)
9526 cfg.data_len = 4096;
9527 break;
9528 default:
9529 nvme_show_error("invalid directive operations for Identify Directives")nvme_show_message(1, "invalid directive operations for Identify Directives"
)
;
9530 return -EINVAL22;
9531 }
9532 break;
9533 case NVME_DIRECTIVE_DTYPE_STREAMS:
9534 switch (cfg.doper) {
9535 case NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_PARAM:
9536 if (!cfg.data_len)
9537 cfg.data_len = 32;
9538 break;
9539 case NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_STATUS:
9540 if (!cfg.data_len)
9541 cfg.data_len = 128 * 1024;
9542 break;
9543 case NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_RESOURCE:
9544 dw12 = cfg.nsr;
9545 break;
9546 default:
9547 nvme_show_error("invalid directive operations for Streams Directives")nvme_show_message(1, "invalid directive operations for Streams Directives"
)
;
9548 return -EINVAL22;
9549 }
9550 break;
9551 default:
9552 nvme_show_error("invalid directive type")nvme_show_message(1, "invalid directive type");
9553 return -EINVAL22;
9554 }
9555
9556 if (cfg.data_len) {
9557 buf = libnvme_alloc(cfg.data_len);
9558 if (!buf)
9559 return -ENOMEM12;
9560 }
9561
9562 nvme_init_directive_recv(&cmd, cfg.namespace_id, cfg.doper, cfg.dtype,
9563 cfg.dspec, buf, cfg.data_len);
9564 cmd.cdw12 = dw12;
9565 err = libnvme_exec_admin_passthru(hdl, &cmd);
9566 if (err) {
9567 nvme_show_err(err, "dir-receive");
9568 return err;
9569 }
9570
9571 nvme_directive_show(cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id,
9572 cmd.result, buf, cfg.data_len, flags);
9573
9574 return err;
9575}
9576
9577/* rpmb_cmd_option is defined in nvme-rpmb.c */
9578extern int rpmb_cmd_option(int, char **, struct command *, struct plugin *);
9579static int rpmb_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9580{
9581 return rpmb_cmd_option(argc, argv, acmd, plugin);
9582}
9583
9584static int lockdown_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9585{
9586 const char *desc = "The Lockdown command is used to control the\n"
9587 "Command and Feature Lockdown capability which configures the\n"
9588 "prohibition or allowance of execution of the specified command\n"
9589 "or Set Features command targeting a specific Feature Identifier.";
9590 const char *ofi_desc = "Opcode or Feature Identifier (OFI)\n"
9591 "specifies the command opcode or Set Features Feature Identifier\n"
9592 "identified by the Scope field.";
9593 const char *ifc_desc =
9594 "[0-3] Interface (INF) field identifies the interfaces affected by this command.";
9595 const char *prhbt_desc = "[0-1]Prohibit(PRHBT) bit specifies whether\n"
9596 "to prohibit or allow the command opcode or Set Features Feature\n"
9597 "Identifier specified by this command.";
9598 const char *scp_desc =
9599 "[0-15]Scope(SCP) field specifies the contents of the Opcode or Feature Identifier field.";
9600 const char *uuid_desc = "UUID Index - If this field is set to a non-zero\n"
9601 "value, then the value of this field is the index of a UUID in the UUID\n"
9602 "List that is used by the command.If this field is cleared to 0h,\n"
9603 "then no UUID index is specified";
9604
9605 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
9606 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
9607 struct libnvme_passthru_cmd cmd;
9608 int err = -1;
9609
9610 struct config {
9611 __u8 ofi;
9612 __u8 ifc;
9613 __u8 prhbt;
9614 __u8 scp;
9615 __u8 uuid;
9616 };
9617
9618 struct config cfg = {
9619 .ofi = 0,
9620 .ifc = 0,
9621 .prhbt = 0,
9622 .scp = 0,
9623 .uuid = 0,
9624 };
9625
9626 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ofi", 'O', "NUM", CFG_BYTE, &cfg.ofi, 1, ofi_desc
, 0, }, {"ifc", 'f', "NUM", CFG_BYTE, &cfg.ifc, 1, ifc_desc
, 0, }, {"prhbt", 'p', "NUM", CFG_BYTE, &cfg.prhbt, 1, prhbt_desc
, 0, }, {"scp", 's', "NUM", CFG_BYTE, &cfg.scp, 1, scp_desc
, 0, }, {"uuid", 'U', "NUM", CFG_BYTE, &cfg.uuid, 1, uuid_desc
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9627 OPT_BYTE("ofi", 'O', &cfg.ofi, ofi_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ofi", 'O', "NUM", CFG_BYTE, &cfg.ofi, 1, ofi_desc
, 0, }, {"ifc", 'f', "NUM", CFG_BYTE, &cfg.ifc, 1, ifc_desc
, 0, }, {"prhbt", 'p', "NUM", CFG_BYTE, &cfg.prhbt, 1, prhbt_desc
, 0, }, {"scp", 's', "NUM", CFG_BYTE, &cfg.scp, 1, scp_desc
, 0, }, {"uuid", 'U', "NUM", CFG_BYTE, &cfg.uuid, 1, uuid_desc
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9628 OPT_BYTE("ifc", 'f', &cfg.ifc, ifc_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ofi", 'O', "NUM", CFG_BYTE, &cfg.ofi, 1, ofi_desc
, 0, }, {"ifc", 'f', "NUM", CFG_BYTE, &cfg.ifc, 1, ifc_desc
, 0, }, {"prhbt", 'p', "NUM", CFG_BYTE, &cfg.prhbt, 1, prhbt_desc
, 0, }, {"scp", 's', "NUM", CFG_BYTE, &cfg.scp, 1, scp_desc
, 0, }, {"uuid", 'U', "NUM", CFG_BYTE, &cfg.uuid, 1, uuid_desc
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9629 OPT_BYTE("prhbt", 'p', &cfg.prhbt, prhbt_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ofi", 'O', "NUM", CFG_BYTE, &cfg.ofi, 1, ofi_desc
, 0, }, {"ifc", 'f', "NUM", CFG_BYTE, &cfg.ifc, 1, ifc_desc
, 0, }, {"prhbt", 'p', "NUM", CFG_BYTE, &cfg.prhbt, 1, prhbt_desc
, 0, }, {"scp", 's', "NUM", CFG_BYTE, &cfg.scp, 1, scp_desc
, 0, }, {"uuid", 'U', "NUM", CFG_BYTE, &cfg.uuid, 1, uuid_desc
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9630 OPT_BYTE("scp", 's', &cfg.scp, scp_desc),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ofi", 'O', "NUM", CFG_BYTE, &cfg.ofi, 1, ofi_desc
, 0, }, {"ifc", 'f', "NUM", CFG_BYTE, &cfg.ifc, 1, ifc_desc
, 0, }, {"prhbt", 'p', "NUM", CFG_BYTE, &cfg.prhbt, 1, prhbt_desc
, 0, }, {"scp", 's', "NUM", CFG_BYTE, &cfg.scp, 1, scp_desc
, 0, }, {"uuid", 'U', "NUM", CFG_BYTE, &cfg.uuid, 1, uuid_desc
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9631 OPT_BYTE("uuid", 'U', &cfg.uuid, uuid_desc))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"ofi", 'O', "NUM", CFG_BYTE, &cfg.ofi, 1, ofi_desc
, 0, }, {"ifc", 'f', "NUM", CFG_BYTE, &cfg.ifc, 1, ifc_desc
, 0, }, {"prhbt", 'p', "NUM", CFG_BYTE, &cfg.prhbt, 1, prhbt_desc
, 0, }, {"scp", 's', "NUM", CFG_BYTE, &cfg.scp, 1, scp_desc
, 0, }, {"uuid", 'U', "NUM", CFG_BYTE, &cfg.uuid, 1, uuid_desc
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
9632
9633 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
9634 if (err)
9635 return err;
9636
9637 /* check for input argument limit */
9638 if (cfg.ifc > 3) {
9639 nvme_show_error("invalid interface settings:%d", cfg.ifc)nvme_show_message(1, "invalid interface settings:%d", cfg.ifc
)
;
9640 return -1;
9641 }
9642 if (cfg.prhbt > 1) {
9643 nvme_show_error("invalid prohibit settings:%d", cfg.prhbt)nvme_show_message(1, "invalid prohibit settings:%d", cfg.prhbt
)
;
9644 return -1;
9645 }
9646 if (cfg.scp > 15) {
9647 nvme_show_error("invalid scope settings:%d", cfg.scp)nvme_show_message(1, "invalid scope settings:%d", cfg.scp);
9648 return -1;
9649 }
9650 if (cfg.uuid > 127) {
9651 nvme_show_error("invalid UUID index settings:%d", cfg.uuid)nvme_show_message(1, "invalid UUID index settings:%d", cfg.uuid
)
;
9652 return -1;
9653 }
9654
9655 nvme_init_lockdown(&cmd, cfg.scp, cfg.prhbt, cfg.ifc, cfg.ofi,
9656 cfg.uuid);
9657 err = libnvme_exec_admin_passthru(hdl, &cmd);
9658 if (err) {
9659 nvme_show_err(err, "lockdown");
9660 return err;
9661 }
9662
9663 nvme_show_verbose_result("Lockdown Command is Successful")nvme_show_verbose_message("Lockdown Command is Successful");
9664
9665 return err;
9666}
9667
9668static void passthru_print_read_output(struct passthru_config cfg, void *data, int dfd, void *mdata,
9669 int mfd, int err)
9670{
9671 if (strlen(cfg.input_file)) {
9672 if (write(dfd, (void *)data, cfg.data_len) < 0)
9673 perror("failed to write data buffer");
9674 } else if (data) {
9675 if (cfg.raw_binary)
9676 d_raw((unsigned char *)data, cfg.data_len);
9677 else if (!err)
9678 d((unsigned char *)data, cfg.data_len, 16, 1);
9679 }
9680 if (cfg.metadata_len && cfg.metadata) {
9681 if (strlen(cfg.metadata)) {
9682 if (write(mfd, (void *)mdata, cfg.metadata_len) < 0)
9683 perror("failed to write metadata buffer");
9684 } else {
9685 if (cfg.raw_binary)
9686 d_raw((unsigned char *)mdata, cfg.metadata_len);
9687 else if (!err)
9688 d((unsigned char *)mdata, cfg.metadata_len, 16, 1);
9689 }
9690 }
9691}
9692
9693static int passthru(int argc, char **argv, bool_Bool admin,
9694 const char *desc, struct command *acmd)
9695{
9696 const char *opcode = "opcode (required)";
9697 const char *cflags = "command flags";
9698 const char *rsvd = "value for reserved field";
9699 const char *data_len = "data I/O length (bytes)";
9700 const char *metadata_len = "metadata seg. length (bytes)";
9701 const char *metadata = "metadata input or output file";
9702 const char *cdw2 = "command dword 2 value";
9703 const char *cdw3 = "command dword 3 value";
9704 const char *cdw10 = "command dword 10 value";
9705 const char *cdw11 = "command dword 11 value";
9706 const char *cdw12 = "command dword 12 value";
9707 const char *cdw13 = "command dword 13 value";
9708 const char *cdw14 = "command dword 14 value";
9709 const char *cdw15 = "command dword 15 value";
9710 const char *input = "data input or output file";
9711 const char *show = "print command before sending";
9712 const char *re = "set dataflow direction to receive";
9713 const char *wr = "set dataflow direction to send";
9714 const char *prefill = "prefill buffers with known byte-value, default 0";
9715
9716 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
9717 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
9718 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
9719 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int dfd = -1, mfd = -1;
9720 int flags = -1;
9721 int mode = 0644;
9722 void *data = NULL((void*)0);
9723 __cleanup_free__attribute__((cleanup(shr_freep))) void *mdata = NULL((void*)0);
9724 int err = 0;
9725 const char *cmd_name = NULL((void*)0);
9726 struct timeval start_time, end_time;
9727 nvme_print_flags_t flags_t;
9728
9729 struct passthru_config cfg = {
9730 .opcode = 0,
9731 .flags = 0,
9732 .prefill = 0,
9733 .rsvd = 0,
9734 .namespace_id = 0,
9735 .data_len = 0,
9736 .metadata_len = 0,
9737 .cdw2 = 0,
9738 .cdw3 = 0,
9739 .cdw10 = 0,
9740 .cdw11 = 0,
9741 .cdw12 = 0,
9742 .cdw13 = 0,
9743 .cdw14 = 0,
9744 .cdw15 = 0,
9745 .input_file = "",
9746 .metadata = "",
9747 .raw_binary = false0,
9748 .show_command = false0,
9749 .read = false0,
9750 .write = false0,
9751 .latency = false0,
9752 };
9753
9754 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9755 OPT_BYTE("opcode", 'O', &cfg.opcode, opcode),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9756 OPT_BYTE("flags", 'f', &cfg.flags, cflags),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9757 OPT_BYTE("prefill", 'p', &cfg.prefill, prefill),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9758 OPT_SHRT("rsvd", 'R', &cfg.rsvd, rsvd),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9759 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9760 OPT_UINT("data-len", 'l', &cfg.data_len, data_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9761 OPT_UINT("metadata-len", 'm', &cfg.metadata_len, metadata_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9762 OPT_UINT("cdw2", '2', &cfg.cdw2, cdw2),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9763 OPT_UINT("cdw3", '3', &cfg.cdw3, cdw3),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9764 OPT_UINT("cdw10", '4', &cfg.cdw10, cdw10),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9765 OPT_UINT("cdw11", '5', &cfg.cdw11, cdw11),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9766 OPT_UINT("cdw12", '6', &cfg.cdw12, cdw12),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9767 OPT_UINT("cdw13", '7', &cfg.cdw13, cdw13),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9768 OPT_UINT("cdw14", '8', &cfg.cdw14, cdw14),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9769 OPT_UINT("cdw15", '9', &cfg.cdw15, cdw15),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9770 OPT_FILE("input-file", 'i', &cfg.input_file, input),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9771 OPT_FILE("metadata", 'M', &cfg.metadata, metadata),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9772 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_dump),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9773 OPT_FLAG("show-command", 's', &cfg.show_command, show),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9774 OPT_FLAG("read", 'r', &cfg.read, re),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9775 OPT_FLAG("write", 'w', &cfg.write, wr),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
9776 OPT_FLAG("latency", 'T', &cfg.latency, latency))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"flags", 'f', "NUM", CFG_BYTE, &cfg.flags, 1, cflags
, 0, }, {"prefill", 'p', "NUM", CFG_BYTE, &cfg.prefill, 1
, prefill, 0, }, {"rsvd", 'R', "NUM", CFG_SHORT, &cfg.rsvd
, 1, rsvd, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &
cfg.namespace_id, 1, namespace_desired, 0, }, {"data-len", 'l'
, "NUM", CFG_POSITIVE, &cfg.data_len, 1, data_len, 0, }, {
"metadata-len", 'm', "NUM", CFG_POSITIVE, &cfg.metadata_len
, 1, metadata_len, 0, }, {"cdw2", '2', "NUM", CFG_POSITIVE, &
cfg.cdw2, 1, cdw2, 0, }, {"cdw3", '3', "NUM", CFG_POSITIVE, &
cfg.cdw3, 1, cdw3, 0, }, {"cdw10", '4', "NUM", CFG_POSITIVE, &
cfg.cdw10, 1, cdw10, 0, }, {"cdw11", '5', "NUM", CFG_POSITIVE
, &cfg.cdw11, 1, cdw11, 0, }, {"cdw12", '6', "NUM", CFG_POSITIVE
, &cfg.cdw12, 1, cdw12, 0, }, {"cdw13", '7', "NUM", CFG_POSITIVE
, &cfg.cdw13, 1, cdw13, 0, }, {"cdw14", '8', "NUM", CFG_POSITIVE
, &cfg.cdw14, 1, cdw14, 0, }, {"cdw15", '9', "NUM", CFG_POSITIVE
, &cfg.cdw15, 1, cdw15, 0, }, {"input-file", 'i', "FILE",
CFG_STRING, &cfg.input_file, 1, input, 0, }, {"metadata"
, 'M', "FILE", CFG_STRING, &cfg.metadata, 1, metadata, 0,
}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_dump, 0, }, {"show-command", 's', ((void*)0), CFG_FLAG
, &cfg.show_command, 0, show, 0, }, {"read", 'r', ((void*
)0), CFG_FLAG, &cfg.read, 0, re, 0, }, {"write", 'w', ((void
*)0), CFG_FLAG, &cfg.write, 0, wr, 0, }, {"latency", 'T',
((void*)0), CFG_FLAG, &cfg.latency, 0, latency, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
9777
9778 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
9779 if (err)
9780 return err;
9781
9782 err = validate_output_format(nvme_args.output_format, &flags_t);
9783 if (err < 0) {
9784 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
9785 return err;
9786 }
9787
9788 if (!argconfig_parse_seen(opts, "opcode")) {
9789 nvme_show_error("%s: opcode parameter required", acmd->name)nvme_show_message(1, "%s: opcode parameter required", acmd->
name)
;
9790 return -EINVAL22;
9791 }
9792
9793 if (cfg.opcode & 0x01) {
9794 cfg.write = true1;
9795 flags = O_RDONLY00;
9796 dfd = mfd = STDIN_FILENO0;
9797 }
9798
9799 if (cfg.opcode & 0x02) {
9800 cfg.read = true1;
9801 flags = O_WRONLY01 | O_CREAT0100 | O_TRUNC01000;
9802 dfd = mfd = STDOUT_FILENO1;
9803 }
9804
9805 /*
9806 * Fallback to user specified data direction in case from opcode
9807 * we can't decode direction.
9808 */
9809 if (cfg.write && flags < 0) {
9810 flags = O_RDONLY00;
9811 dfd = mfd = STDIN_FILENO0;
9812 }
9813
9814 if (cfg.read && flags < 0) {
9815 flags = O_WRONLY01 | O_CREAT0100 | O_TRUNC01000;
9816 dfd = mfd = STDOUT_FILENO1;
9817 }
9818 if (strlen(cfg.input_file)) {
9819 if (flags < 0) {
9820 nvme_show_error("input file specified for opcode 0x%x "nvme_show_message(1, "input file specified for opcode 0x%x " "without a data transfer direction"
, cfg.opcode)
9821 "without a data transfer direction",nvme_show_message(1, "input file specified for opcode 0x%x " "without a data transfer direction"
, cfg.opcode)
9822 cfg.opcode)nvme_show_message(1, "input file specified for opcode 0x%x " "without a data transfer direction"
, cfg.opcode)
;
9823 return -EINVAL22;
9824 }
9825 dfd = nvme_open_rawdata(cfg.input_file, flags, mode)open((cfg.input_file), (flags), mode);
9826 if (dfd < 0) {
9827 nvme_show_perror(cfg.input_file);
9828 return -EINVAL22;
9829 }
9830 }
9831
9832 if (cfg.metadata && strlen(cfg.metadata)) {
9833 if (flags < 0) {
9834 nvme_show_error("metadata file specified for opcode 0x%x "nvme_show_message(1, "metadata file specified for opcode 0x%x "
"without a data transfer direction", cfg.opcode)
9835 "without a data transfer direction",nvme_show_message(1, "metadata file specified for opcode 0x%x "
"without a data transfer direction", cfg.opcode)
9836 cfg.opcode)nvme_show_message(1, "metadata file specified for opcode 0x%x "
"without a data transfer direction", cfg.opcode)
;
9837 return -EINVAL22;
9838 }
9839 mfd = nvme_open_rawdata(cfg.metadata, flags, mode)open((cfg.metadata), (flags), mode);
9840 if (mfd < 0) {
9841 nvme_show_perror(cfg.metadata);
9842 return -EINVAL22;
9843 }
9844 }
9845
9846 if (cfg.metadata_len) {
9847 mdata = malloc(cfg.metadata_len);
9848 if (!mdata)
9849 return -ENOMEM12;
9850
9851 if (cfg.write) {
9852 if (read(mfd, mdata, cfg.metadata_len) < 0) {
9853 err = -errno(*__errno_location ());
9854 nvme_show_perror("failed to read metadata write buffer");
9855 return err;
9856 }
9857 } else {
9858 memset(mdata, cfg.prefill, cfg.metadata_len);
9859 }
9860 }
9861
9862 if (cfg.data_len) {
9863 data = libnvme_alloc_huge(cfg.data_len, &mh);
9864 if (!data) {
9865 nvme_show_error("failed to allocate huge memory")nvme_show_message(1, "failed to allocate huge memory");
9866 return -ENOMEM12;
9867 }
9868
9869 memset(data, cfg.prefill, cfg.data_len);
9870 if (!cfg.read && !cfg.write) {
9871 nvme_show_error("data direction not given")nvme_show_message(1, "data direction not given");
9872 return -EINVAL22;
9873 } else if (cfg.write) {
9874 if (read(dfd, data, cfg.data_len) < 0) {
9875 err = -errno(*__errno_location ());
9876 nvme_show_error("failed to read write buffer %s", libnvme_strerror(errno))nvme_show_message(1, "failed to read write buffer %s", libnvme_strerror
((*__errno_location ())))
;
9877 return err;
9878 }
9879 }
9880 }
9881
9882 if (cfg.show_command || nvme_args.dry_run) {
9883 nvme_show_result("opcode : %02x", cfg.opcode)nvme_show_message(0, "opcode : %02x", cfg.opcode);
9884 nvme_show_result("flags : %02x", cfg.flags)nvme_show_message(0, "flags : %02x", cfg.flags);
9885 nvme_show_result("rsvd1 : %04x", cfg.rsvd)nvme_show_message(0, "rsvd1 : %04x", cfg.rsvd);
9886 nvme_show_result("nsid : %08x", cfg.namespace_id)nvme_show_message(0, "nsid : %08x", cfg.namespace_id);
9887 nvme_show_result("cdw2 : %08x", cfg.cdw2)nvme_show_message(0, "cdw2 : %08x", cfg.cdw2);
9888 nvme_show_result("cdw3 : %08x", cfg.cdw3)nvme_show_message(0, "cdw3 : %08x", cfg.cdw3);
9889 nvme_show_result("data_len : %08x", cfg.data_len)nvme_show_message(0, "data_len : %08x", cfg.data_len);
9890 nvme_show_result("metadata_len : %08x", cfg.metadata_len)nvme_show_message(0, "metadata_len : %08x", cfg.metadata_len);
9891 nvme_show_result("addr : %"PRIx64, (uint64_t)(uintptr_t)data)nvme_show_message(0, "addr : %""l" "x", (uint64_t)(uintptr_t
)data)
;
9892 nvme_show_result("metadata : %"PRIx64, (uint64_t)(uintptr_t)mdata)nvme_show_message(0, "metadata : %""l" "x", (uint64_t)(uintptr_t
)mdata)
;
9893 nvme_show_result("cdw10 : %08x", cfg.cdw10)nvme_show_message(0, "cdw10 : %08x", cfg.cdw10);
9894 nvme_show_result("cdw11 : %08x", cfg.cdw11)nvme_show_message(0, "cdw11 : %08x", cfg.cdw11);
9895 nvme_show_result("cdw12 : %08x", cfg.cdw12)nvme_show_message(0, "cdw12 : %08x", cfg.cdw12);
9896 nvme_show_result("cdw13 : %08x", cfg.cdw13)nvme_show_message(0, "cdw13 : %08x", cfg.cdw13);
9897 nvme_show_result("cdw14 : %08x", cfg.cdw14)nvme_show_message(0, "cdw14 : %08x", cfg.cdw14);
9898 nvme_show_result("cdw15 : %08x", cfg.cdw15)nvme_show_message(0, "cdw15 : %08x", cfg.cdw15);
9899 nvme_show_result("timeout_ms : %08x", nvme_args.timeout)nvme_show_message(0, "timeout_ms : %08x", nvme_args.timeout
)
;
9900 }
9901 if (nvme_args.dry_run)
9902 return 0;
9903
9904 gettimeofday(&start_time, NULL((void*)0));
9905
9906 struct libnvme_passthru_cmd cmd = {
9907 .opcode = cfg.opcode,
9908 .flags = cfg.flags,
9909 .nsid = cfg.namespace_id,
9910 .cdw2 = cfg.cdw2,
9911 .cdw3 = cfg.cdw3,
9912 .metadata = (__u64)(uintptr_t)mdata,
9913 .addr = (__u64)(uintptr_t)data,
9914 .metadata_len = cfg.metadata_len,
9915 .data_len = cfg.data_len,
9916 .cdw10 = cfg.cdw10,
9917 .cdw11 = cfg.cdw11,
9918 .cdw12 = cfg.cdw12,
9919 .cdw13 = cfg.cdw13,
9920 .cdw14 = cfg.cdw14,
9921 .cdw15 = cfg.cdw15,
9922 .timeout_ms = nvme_args.timeout,
9923 };
9924 if (admin)
9925 err = libnvme_exec_admin_passthru(hdl, &cmd);
9926 else
9927 err = libnvme_exec_io_passthru(hdl, &cmd);
9928
9929 gettimeofday(&end_time, NULL((void*)0));
9930 cmd_name = nvme_cmd_to_string(admin, cfg.opcode);
9931 if (cfg.latency)
9932 nvme_show_result("%s Command %s latency: %llu us", admin ? "Admin" : "IO",nvme_show_message(0, "%s Command %s latency: %llu us", admin ?
"Admin" : "IO", strcmp(cmd_name, "Unknown") ? cmd_name : "Vendor Specific"
, elapsed_utime(start_time, end_time))
9933 strcmp(cmd_name, "Unknown") ? cmd_name : "Vendor Specific",nvme_show_message(0, "%s Command %s latency: %llu us", admin ?
"Admin" : "IO", strcmp(cmd_name, "Unknown") ? cmd_name : "Vendor Specific"
, elapsed_utime(start_time, end_time))
9934 elapsed_utime(start_time, end_time))nvme_show_message(0, "%s Command %s latency: %llu us", admin ?
"Admin" : "IO", strcmp(cmd_name, "Unknown") ? cmd_name : "Vendor Specific"
, elapsed_utime(start_time, end_time))
;
9935
9936 if (err) {
9937 nvme_show_err(err, __func__);
9938 return err;
9939 }
9940
9941 nvme_show_verbose_result("%s Command %s is Success and result: 0x%" PRIx64,nvme_show_verbose_message("%s Command %s is Success and result: 0x%"
"l" "x", admin ? "Admin" : "IO", strcmp(cmd_name, "Unknown")
? cmd_name : "Vendor Specific", (uint64_t)cmd.result)
9942 admin ? "Admin" : "IO",nvme_show_verbose_message("%s Command %s is Success and result: 0x%"
"l" "x", admin ? "Admin" : "IO", strcmp(cmd_name, "Unknown")
? cmd_name : "Vendor Specific", (uint64_t)cmd.result)
9943 strcmp(cmd_name, "Unknown") ?nvme_show_verbose_message("%s Command %s is Success and result: 0x%"
"l" "x", admin ? "Admin" : "IO", strcmp(cmd_name, "Unknown")
? cmd_name : "Vendor Specific", (uint64_t)cmd.result)
9944 cmd_name : "Vendor Specific", (uint64_t)cmd.result)nvme_show_verbose_message("%s Command %s is Success and result: 0x%"
"l" "x", admin ? "Admin" : "IO", strcmp(cmd_name, "Unknown")
? cmd_name : "Vendor Specific", (uint64_t)cmd.result)
;
9945 if (cfg.read)
9946 passthru_print_read_output(cfg, data, dfd, mdata, mfd, err);
9947
9948 return err;
9949}
9950
9951static int io_passthru(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9952{
9953 const char *desc =
9954 "Send a user-defined IO command to the specified device via IOCTL passthrough, return results.";
9955
9956 return passthru(argc, argv, false0, desc, acmd);
9957}
9958
9959static int admin_passthru(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9960{
9961 const char *desc =
9962 "Send a user-defined Admin command to the specified device via IOCTL passthrough, return results.";
9963
9964 return passthru(argc, argv, true1, desc, acmd);
9965}
9966
9967#ifdef CONFIG_FABRICS
9968static int gen_hostnqn_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9969{
9970 const char *desc = "Generate a hostnqn";
9971
9972 __cleanup_free__attribute__((cleanup(shr_freep))) char *hostnqn = NULL((void*)0);
9973 int err;
9974
9975 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
9976
9977 err = parse_args(argc, argv, desc, opts);
9978 if (err)
9979 return err;
9980
9981 hostnqn = libnvmf_generate_hostnqn();
9982 if (!hostnqn) {
9983 nvme_show_error("\"%s\" not supported. Install lib uuid and rebuild.",nvme_show_message(1, "\"%s\" not supported. Install lib uuid and rebuild."
, acmd->name)
9984 acmd->name)nvme_show_message(1, "\"%s\" not supported. Install lib uuid and rebuild."
, acmd->name)
;
9985 return -ENOTSUP95;
9986 }
9987
9988 nvme_show_result("%s", hostnqn)nvme_show_message(0, "%s", hostnqn);
9989
9990 return 0;
9991}
9992
9993static int show_hostnqn_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
9994{
9995 const char *desc = "Show hostnqn";
9996
9997 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
9998 __cleanup_free__attribute__((cleanup(shr_freep))) char *hostnqn = NULL((void*)0);
9999 int err;
10000
10001 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10002
10003 err = parse_args(argc, argv, desc, opts);
10004 if (err)
10005 return err;
10006
10007 ctx = libnvme_create_global_ctx();
10008 if (!ctx)
10009 return -ENOMEM12;
10010
10011 hostnqn = libnvmf_read_hostnqn(ctx);
10012 if (!hostnqn)
10013 hostnqn = libnvmf_generate_hostnqn();
10014
10015 if (!hostnqn) {
10016 nvme_show_error("hostnqn is not available -- use nvme gen-hostnqn")nvme_show_message(1, "hostnqn is not available -- use nvme gen-hostnqn"
)
;
10017 return -ENOENT2;
10018 }
10019
10020 nvme_show_result("%s", hostnqn)nvme_show_message(0, "%s", hostnqn);
10021
10022 return 0;
10023}
10024
10025#endif /* CONFIG_FABRICS */
10026
10027static int show_topology_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10028{
10029 const char *desc = "Show the topology\n";
10030 const char *ranking = "Ranking order: namespace|ctrl|multipath";
10031 nvme_print_flags_t flags;
10032 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
10033 char *devname = NULL((void*)0);
10034 libnvme_scan_filter_t filter = NULL((void*)0);
10035 enum nvme_cli_topo_ranking rank;
10036 int err;
10037
10038#ifdef CONFIG_JSONC
10039 nvme_print_flags_t supported_formats = (NORMAL | JSON | TABULAR);
10040 const char *supported_formats_desc = "Output format: normal|json|tabular";
10041#else /* CONFIG_JSONC */
10042 nvme_print_flags_t supported_formats = (NORMAL | TABULAR);
10043 const char *supported_formats_desc = "Output format: normal|tabular";
10044#endif /* CONFIG_JSONC */
10045
10046 struct config {
10047 char *ranking;
10048 };
10049
10050 struct config cfg = {
10051 .ranking = "namespace",
10052 };
10053
10054 NVME_ARGS_OUTPUT_FORMATS(opts, supported_formats, supported_formats_desc,nvme_args.supported_output_formats = supported_formats; struct
argconfig_commandline_options opts[] = { {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void*)0)
}, {"ranking", 'r', "FMT", CFG_STRING, &cfg.ranking, 1, ranking
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, supported_formats_desc, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE
, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10055 OPT_FMT("ranking", 'r', &cfg.ranking, ranking))nvme_args.supported_output_formats = supported_formats; struct
argconfig_commandline_options opts[] = { {"", 0, ((void*)0),
CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void*)0)
}, {"ranking", 'r', "FMT", CFG_STRING, &cfg.ranking, 1, ranking
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, supported_formats_desc, 0, }, {"timeout", 0, "NUM", CFG_POSITIVE
, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10056
10057 err = parse_args(argc, argv, desc, opts);
10058 if (err)
10059 return err;
10060
10061 err = validate_output_format(nvme_args.output_format, &flags);
10062 if (err < 0) {
10063 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
10064 return err;
10065 }
10066
10067 if (nvme_args.verbose)
10068 flags |= VERBOSE;
10069
10070 if (!strcmp(cfg.ranking, "namespace")) {
10071 rank = NVME_CLI_TOPO_NAMESPACE;
10072 } else if (!strcmp(cfg.ranking, "ctrl")) {
10073 rank = NVME_CLI_TOPO_CTRL;
10074 } else if (!strcmp(cfg.ranking, "multipath")) {
10075 rank = NVME_CLI_TOPO_MULTIPATH;
10076 } else {
10077 nvme_show_error("Invalid ranking argument: %s", cfg.ranking)nvme_show_message(1, "Invalid ranking argument: %s", cfg.ranking
)
;
10078 return -EINVAL22;
10079 }
10080
10081 err = nvme_create_global_ctx(&ctx);
10082 if (err)
10083 return err;
10084
10085 if (optind < argc)
10086 devname = basename__xpg_basename(argv[optind++]);
10087
10088 if (devname) {
10089 int subsys_id, nsid;
10090
10091 if (sscanf(devname, "nvme%dn%d", &subsys_id, &nsid) < 1 &&
10092 sscanf(devname, "ng%dn%d", &subsys_id, &nsid) != 2) {
10093 nvme_show_error("Invalid device name %s\n", devname)nvme_show_message(1, "Invalid device name %s\n", devname);
10094 return -EINVAL22;
10095 }
10096 filter = nvme_match_device_filter;
10097 }
10098
10099 err = libnvme_scan_topology(ctx, filter, (void *)devname);
10100 if (err < 0)
10101 return handle_scan_topology_error(err);
10102
10103 if (flags & TABULAR)
10104 nvme_show_topology_tabular(ctx, flags);
10105 else
10106 nvme_show_topology(ctx, rank, flags);
10107
10108 return err;
10109}
10110
10111#ifdef CONFIG_FABRICS
10112static int discover_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10113{
10114 const char *desc = "Send Get Log Page request to Discovery Controller.";
10115
10116 return fabrics_discover(desc, argc, argv, false0);
10117}
10118
10119static int connect_all_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10120{
10121 const char *desc = "Discover NVMeoF subsystems and connect to them";
10122
10123 return fabrics_discover(desc, argc, argv, true1);
10124}
10125
10126static int connect_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10127{
10128 const char *desc = "Connect to NVMeoF subsystem";
10129
10130 return fabrics_connect(desc, argc, argv);
10131}
10132
10133static int disconnect_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10134{
10135 const char *desc = "Disconnect from NVMeoF subsystem";
10136
10137 return fabrics_disconnect(desc, argc, argv);
10138}
10139
10140int disconnect_all_cmd(int argc, char **argv, struct command *acmd,
10141 struct plugin *plugin)
10142{
10143 const char *desc = "Disconnect from all connected NVMeoF subsystems";
10144
10145 return fabrics_disconnect_all(desc, argc, argv);
10146}
10147
10148static int dim_cmd(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10149{
10150 const char *desc =
10151 "Send Discovery Information Management command to a Discovery Controller (DC)";
10152
10153 return fabrics_dim(desc, argc, argv);
10154}
10155
10156#ifdef CONFIG_DEPRECATED_CMDS
10157static struct plugin *find_keys_plugin(void)
10158{
10159 struct plugin *keys = nvme.extensions->next;
10160
10161 while (keys && (!keys->name || strcmp(keys->name, "keys")))
10162 keys = keys->next;
10163
10164 return keys;
10165}
10166
10167static int forward_to_keys_plugin(const char *old_name, const char *subcmd,
10168 int argc, char **argv)
10169{
10170 struct plugin *keys = find_keys_plugin();
10171 __cleanup_free__attribute__((cleanup(shr_freep))) char **sub_argv = NULL((void*)0);
10172
10173 if (!keys) {
10174 fprintf(stderrstderr, "ERROR: '%s' is deprecated and requires the 'keys' plugin, which is not available in this build; use 'nvme keys %s'\n",
10175 old_name, subcmd);
10176 return -ENOTTY25;
10177 }
10178
10179 fprintf(stderrstderr, "WARNING: '%s' is deprecated, use 'nvme keys %s' instead\n",
10180 old_name, subcmd);
10181
10182 /*
10183 * handle_plugin() expects argv[0] to be a throwaway name (its own
10184 * global-option parsing skips it like a program name) and argv[1]
10185 * to be the subcommand it dispatches on, so forwarding into the
10186 * 'keys' plugin needs both slots, not just a renamed argv[0].
10187 */
10188 sub_argv = calloc(argc + 1, sizeof(*sub_argv));
10189 if (!sub_argv)
10190 return -ENOMEM12;
10191
10192 sub_argv[0] = (char *)keys->name;
10193 sub_argv[1] = (char *)subcmd;
10194 memcpy(&sub_argv[2], &argv[1], (argc - 1) * sizeof(*argv));
10195
10196 return handle_plugin(argc + 1, sub_argv, keys);
10197}
10198
10199static int gen_dhchap_key(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10200{
10201 return forward_to_keys_plugin("gen-dhchap-key", "gen-kxchap", argc, argv);
10202}
10203
10204static int check_dhchap_key(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10205{
10206 return forward_to_keys_plugin("check-dhchap-key", "check-kxchap", argc, argv);
10207}
10208
10209static int gen_tls_key(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10210{
10211 return forward_to_keys_plugin("gen-tls-key", "gen-tls", argc, argv);
10212}
10213
10214static int check_tls_key(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10215{
10216 return forward_to_keys_plugin("check-tls-key", "check-tls", argc, argv);
10217}
10218
10219/*
10220 * The old 'tls-key' command bundled import/export/revoke behind
10221 * -i/-e/-r mode flags sharing -k/-t/-f; the 'keys' plugin split these
10222 * into separate subcommands with their own option sets, so unlike the
10223 * other legacy aliases this one has to translate argv instead of just
10224 * renaming argv[0].
10225 */
10226static int tls_key(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10227{
10228 static const struct option opts[] = {
10229 { "keyring", required_argument1, NULL((void*)0), 'k' },
10230 { "keytype", required_argument1, NULL((void*)0), 't' },
10231 { "keyfile", required_argument1, NULL((void*)0), 'f' },
10232 { "import", no_argument0, NULL((void*)0), 'i' },
10233 { "export", no_argument0, NULL((void*)0), 'e' },
10234 { "revoke", required_argument1, NULL((void*)0), 'r' },
10235 { NULL((void*)0), 0, NULL((void*)0), 0 },
10236 };
10237 __cleanup_free__attribute__((cleanup(shr_freep))) char *keyring_opt = NULL((void*)0);
10238 __cleanup_free__attribute__((cleanup(shr_freep))) char *keytype_opt = NULL((void*)0);
10239 __cleanup_free__attribute__((cleanup(shr_freep))) char *keyfile_opt = NULL((void*)0);
10240 __cleanup_free__attribute__((cleanup(shr_freep))) char *identity_opt = NULL((void*)0);
10241 __cleanup_free__attribute__((cleanup(shr_freep))) char **sub_argv = NULL((void*)0);
10242 const char *keyring = NULL((void*)0), *keytype = NULL((void*)0), *keyfile = NULL((void*)0), *revoke = NULL((void*)0);
10243 const char *subcmd = NULL((void*)0);
10244 struct plugin *keys;
10245 int nsub = 0, c;
10246
10247 optind = 1;
10248 while ((c = getopt_long(argc, argv, "k:t:f:ier:", opts, NULL((void*)0))) != -1) {
10249 switch (c) {
10250 case 'k':
10251 keyring = optarg;
10252 break;
10253 case 't':
10254 keytype = optarg;
10255 break;
10256 case 'f':
10257 keyfile = optarg;
10258 break;
10259 case 'i':
10260 case 'e':
10261 if (subcmd) {
10262 fprintf(stderrstderr, "ERROR: only one of --import, --export, or --revoke may be given\n");
10263 return -EINVAL22;
10264 }
10265 subcmd = c == 'i' ? "import" : "export";
10266 break;
10267 case 'r':
10268 if (subcmd) {
10269 fprintf(stderrstderr, "ERROR: only one of --import, --export, or --revoke may be given\n");
10270 return -EINVAL22;
10271 }
10272 subcmd = "revoke";
10273 revoke = optarg;
10274 break;
10275 default:
10276 return -EINVAL22;
10277 }
10278 }
10279
10280 if (!subcmd) {
10281 fprintf(stderrstderr, "ERROR: 'tls-key' requires one of --import, --export, or --revoke\n");
10282 return -EINVAL22;
10283 }
10284
10285 keys = find_keys_plugin();
10286 if (!keys) {
10287 fprintf(stderrstderr, "ERROR: 'tls-key' is deprecated and requires the 'keys' plugin, which is not available in this build; use 'nvme keys %s'\n",
10288 subcmd);
10289 return -ENOTTY25;
10290 }
10291
10292 sub_argv = calloc(6, sizeof(*sub_argv));
10293 if (!sub_argv)
10294 return -ENOMEM12;
10295
10296 sub_argv[nsub++] = (char *)keys->name;
10297 sub_argv[nsub++] = (char *)subcmd;
10298
10299 if (keyring) {
10300 if (asprintf(&keyring_opt, "--keyring=%s", keyring) < 0)
10301 return -ENOMEM12;
10302 sub_argv[nsub++] = keyring_opt;
10303 }
10304
10305 if (!strcmp(subcmd, "revoke")) {
10306 if (keytype) {
10307 if (asprintf(&keytype_opt, "--keytype=%s", keytype) < 0)
10308 return -ENOMEM12;
10309 sub_argv[nsub++] = keytype_opt;
10310 }
10311 if (asprintf(&identity_opt, "--identity=%s", revoke) < 0)
10312 return -ENOMEM12;
10313 sub_argv[nsub++] = identity_opt;
10314 } else if (keyfile) {
10315 if (asprintf(&keyfile_opt, "--keyfile=%s", keyfile) < 0)
10316 return -ENOMEM12;
10317 sub_argv[nsub++] = keyfile_opt;
10318 }
10319
10320 fprintf(stderrstderr, "WARNING: 'tls-key' is deprecated, use 'nvme keys %s' instead\n", subcmd);
10321
10322 return handle_plugin(nsub, sub_argv, keys);
10323}
10324#endif /* CONFIG_DEPRECATED_CMDS */
10325#endif /* CONFIG_FABRICS */
10326
10327#ifdef CONFIG_MI
10328static int libnvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc)
10329{
10330 const char *opcode = "opcode (required)";
10331 const char *data_len = "data I/O length (bytes)";
10332 const char *nmimt = "nvme-mi message type";
10333 const char *nmd0 = "nvme management dword 0 value";
10334 const char *nmd1 = "nvme management dword 1 value";
10335 const char *input = "data input or output file";
10336
10337 int mode = 0644;
10338 void *data = NULL((void*)0);
10339 int err = 0;
10340 bool_Bool send;
10341 __cleanup_fd__attribute__((cleanup(shr_cleanup_fd))) int fd = -1;
10342 int flags;
10343 __cleanup_huge__attribute__((cleanup(libnvme_free_huge))) struct libnvme_mem_huge mh = { 0, };
10344 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
10345 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
10346 __u32 result;
10347
10348 struct config {
10349 __u8 opcode;
10350 __u32 namespace_id;
10351 __u32 data_len;
10352 __u32 nmimt;
10353 __u32 nmd0;
10354 __u32 nmd1;
10355 char *input_file;
10356 };
10357
10358 struct config cfg = {
10359 .opcode = 0,
10360 .namespace_id = 0,
10361 .data_len = 0,
10362 .nmimt = 0,
10363 .nmd0 = 0,
10364 .nmd1 = 0,
10365 .input_file = "",
10366 };
10367
10368 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, data_len, 0, }, {"nmimt", 'm', "NUM",
CFG_POSITIVE, &cfg.nmimt, 1, nmimt, 0, }, {"nmd0", '0', "NUM"
, CFG_POSITIVE, &cfg.nmd0, 1, nmd0, 0, }, {"nmd1", '1', "NUM"
, CFG_POSITIVE, &cfg.nmd1, 1, nmd1, 0, }, {"input-file", 'i'
, "FILE", CFG_STRING, &cfg.input_file, 1, input, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10369 OPT_BYTE("opcode", 'O', &cfg.opcode, opcode),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, data_len, 0, }, {"nmimt", 'm', "NUM",
CFG_POSITIVE, &cfg.nmimt, 1, nmimt, 0, }, {"nmd0", '0', "NUM"
, CFG_POSITIVE, &cfg.nmd0, 1, nmd0, 0, }, {"nmd1", '1', "NUM"
, CFG_POSITIVE, &cfg.nmd1, 1, nmd1, 0, }, {"input-file", 'i'
, "FILE", CFG_STRING, &cfg.input_file, 1, input, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10370 OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_desired),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, data_len, 0, }, {"nmimt", 'm', "NUM",
CFG_POSITIVE, &cfg.nmimt, 1, nmimt, 0, }, {"nmd0", '0', "NUM"
, CFG_POSITIVE, &cfg.nmd0, 1, nmd0, 0, }, {"nmd1", '1', "NUM"
, CFG_POSITIVE, &cfg.nmd1, 1, nmd1, 0, }, {"input-file", 'i'
, "FILE", CFG_STRING, &cfg.input_file, 1, input, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10371 OPT_UINT("data-len", 'l', &cfg.data_len, data_len),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, data_len, 0, }, {"nmimt", 'm', "NUM",
CFG_POSITIVE, &cfg.nmimt, 1, nmimt, 0, }, {"nmd0", '0', "NUM"
, CFG_POSITIVE, &cfg.nmd0, 1, nmd0, 0, }, {"nmd1", '1', "NUM"
, CFG_POSITIVE, &cfg.nmd1, 1, nmd1, 0, }, {"input-file", 'i'
, "FILE", CFG_STRING, &cfg.input_file, 1, input, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10372 OPT_UINT("nmimt", 'm', &cfg.nmimt, nmimt),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, data_len, 0, }, {"nmimt", 'm', "NUM",
CFG_POSITIVE, &cfg.nmimt, 1, nmimt, 0, }, {"nmd0", '0', "NUM"
, CFG_POSITIVE, &cfg.nmd0, 1, nmd0, 0, }, {"nmd1", '1', "NUM"
, CFG_POSITIVE, &cfg.nmd1, 1, nmd1, 0, }, {"input-file", 'i'
, "FILE", CFG_STRING, &cfg.input_file, 1, input, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10373 OPT_UINT("nmd0", '0', &cfg.nmd0, nmd0),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, data_len, 0, }, {"nmimt", 'm', "NUM",
CFG_POSITIVE, &cfg.nmimt, 1, nmimt, 0, }, {"nmd0", '0', "NUM"
, CFG_POSITIVE, &cfg.nmd0, 1, nmd0, 0, }, {"nmd1", '1', "NUM"
, CFG_POSITIVE, &cfg.nmd1, 1, nmd1, 0, }, {"input-file", 'i'
, "FILE", CFG_STRING, &cfg.input_file, 1, input, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10374 OPT_UINT("nmd1", '1', &cfg.nmd1, nmd1),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, data_len, 0, }, {"nmimt", 'm', "NUM",
CFG_POSITIVE, &cfg.nmimt, 1, nmimt, 0, }, {"nmd0", '0', "NUM"
, CFG_POSITIVE, &cfg.nmd0, 1, nmd0, 0, }, {"nmd1", '1', "NUM"
, CFG_POSITIVE, &cfg.nmd1, 1, nmd1, 0, }, {"input-file", 'i'
, "FILE", CFG_STRING, &cfg.input_file, 1, input, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10375 OPT_FILE("input-file", 'i', &cfg.input_file, input))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"opcode", 'O', "NUM", CFG_BYTE, &cfg.opcode, 1, opcode
, 0, }, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_desired, 0, }, {"data-len", 'l', "NUM", CFG_POSITIVE
, &cfg.data_len, 1, data_len, 0, }, {"nmimt", 'm', "NUM",
CFG_POSITIVE, &cfg.nmimt, 1, nmimt, 0, }, {"nmd0", '0', "NUM"
, CFG_POSITIVE, &cfg.nmd0, 1, nmd0, 0, }, {"nmd1", '1', "NUM"
, CFG_POSITIVE, &cfg.nmd1, 1, nmd1, 0, }, {"input-file", 'i'
, "FILE", CFG_STRING, &cfg.input_file, 1, input, 0, }, {""
, 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Global options"
, 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT, &
nvme_args.verbose, 0, "Increase output verbosity", 0, }, {"quiet"
, 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0, "suppress output messages, overwrites verbose mode"
, 0, }, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args
.output_format, 1, "Output format: normal|json|binary", 0, },
{"timeout", 0, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1
, "timeout value, in milliseconds", 0, }, {"dry-run", 0, ((void
*)0), CFG_FLAG, &nvme_args.dry_run, 0, "show command instead of executing"
, 0, }, {"no-retries", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_retries, 0, "disable retry logic on errors", 0, }, {"no-ioctl-probing"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_ioctl_probing, 0
, "disable 64-bit IOCTL support probing", 0, }, {"output-format-version"
, 0, "NUM", CFG_POSITIVE, &nvme_args.output_format_ver, 1
, "output format version: 1|2", 0, }, {"human-readable", 'H',
((void*)0), CFG_FLAG, &nvme_args.verbose, 0, ((void*)0),
0, ((void*)0), 1}, {"set-options", 0, "KEY=VALUE", CFG_STRING
, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10376
10377 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
10378 if (err)
10379 return err;
10380
10381 if (!argconfig_parse_seen(opts, "opcode")) {
10382 nvme_show_error("%s: opcode parameter required", *argv)nvme_show_message(1, "%s: opcode parameter required", *argv);
10383 return -EINVAL22;
10384 }
10385
10386 if (admin_opcode == nvme_admin_nvme_mi_send) {
10387 flags = O_RDONLY00;
10388 fd = STDIN_FILENO0;
10389 send = true1;
10390 } else {
10391 flags = O_WRONLY01 | O_CREAT0100 | O_TRUNC01000;
10392 fd = STDOUT_FILENO1;
10393 send = false0;
10394 }
10395
10396 if (strlen(cfg.input_file)) {
10397 fd = nvme_open_rawdata(cfg.input_file, flags, mode)open((cfg.input_file), (flags), mode);
10398 if (fd < 0) {
10399 nvme_show_perror(cfg.input_file);
10400 return -EINVAL22;
10401 }
10402 }
10403
10404 if (cfg.data_len) {
10405 data = libnvme_alloc_huge(cfg.data_len, &mh);
10406 if (!data) {
10407 nvme_show_error("failed to allocate huge memory")nvme_show_message(1, "failed to allocate huge memory");
10408 return -ENOMEM12;
10409 }
10410
10411 if (send) {
10412 if (read(fd, data, cfg.data_len) < 0) {
10413 err = -errno(*__errno_location ());
10414 nvme_show_error("failed to read write buffer %s", libnvme_strerror(errno))nvme_show_message(1, "failed to read write buffer %s", libnvme_strerror
((*__errno_location ())))
;
10415 return err;
10416 }
10417 }
10418 }
10419
10420 struct libnvme_passthru_cmd cmd = {
10421 .opcode = admin_opcode,
10422 .nsid = cfg.namespace_id,
10423 .cdw10 = cfg.nmimt << 11 | 4,
10424 .cdw11 = cfg.opcode,
10425 .cdw12 = cfg.nmd0,
10426 .cdw13 = cfg.nmd1,
10427 .addr = (__u64)(uintptr_t)data,
10428 .data_len = cfg.data_len,
10429 };
10430
10431 err = libnvme_exec_admin_passthru(hdl, &cmd);
10432 if (err) {
10433 nvme_show_err(err, "nmi_recv");
10434 return err;
10435 }
10436
10437 result = cmd.result;
10438 nvme_show_verbose_result(nvme_show_verbose_message("%s Command is Success and result: 0x%08x (status: 0x%02x, response: 0x%06x)"
, nvme_cmd_to_string(1, admin_opcode), result, result & 0xff
, result >> 8)
10439 "%s Command is Success and result: 0x%08x (status: 0x%02x, response: 0x%06x)",nvme_show_verbose_message("%s Command is Success and result: 0x%08x (status: 0x%02x, response: 0x%06x)"
, nvme_cmd_to_string(1, admin_opcode), result, result & 0xff
, result >> 8)
10440 nvme_cmd_to_string(true, admin_opcode), result,nvme_show_verbose_message("%s Command is Success and result: 0x%08x (status: 0x%02x, response: 0x%06x)"
, nvme_cmd_to_string(1, admin_opcode), result, result & 0xff
, result >> 8)
10441 result & 0xff, result >> 8)nvme_show_verbose_message("%s Command is Success and result: 0x%08x (status: 0x%02x, response: 0x%06x)"
, nvme_cmd_to_string(1, admin_opcode), result, result & 0xff
, result >> 8)
;
10442 if (result & 0xff)
10443 nvme_show_verbose_result("status: %s",nvme_show_verbose_message("status: %s", libnvme_mi_status_to_string
(result & 0xff))
10444 libnvme_mi_status_to_string(result & 0xff))nvme_show_verbose_message("status: %s", libnvme_mi_status_to_string
(result & 0xff))
;
10445 if (!send && strlen(cfg.input_file)) {
10446 if (write(fd, (void *)data, cfg.data_len) < 0)
10447 perror("failed to write data buffer");
10448 } else if (data && !send && !err) {
10449 d((unsigned char *)data, cfg.data_len, 16, 1);
10450 }
10451
10452 return err;
10453}
10454
10455static int nmi_recv(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10456{
10457 const char *desc =
10458 "Send a NVMe-MI Receive command to the specified device, return results.";
10459
10460 return libnvme_mi(argc, argv, nvme_admin_nvme_mi_recv, desc);
10461}
10462
10463static int nmi_send(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10464{
10465 const char *desc = "Send a NVMe-MI Send command to the specified device, return results.";
10466
10467 return libnvme_mi(argc, argv, nvme_admin_nvme_mi_send, desc);
10468}
10469#endif /* CONFIG_MI */
10470
10471static int get_mgmt_addr_list_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
10472{
10473 const char *desc = "Retrieve Management Address List Log, show it";
10474 nvme_print_flags_t flags;
10475 int err = -1;
10476
10477 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_mgmt_addr_list_log *ma_log = NULL((void*)0);
10478 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
10479 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
10480
10481 NVME_ARGS(opts)nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10482
10483 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
10484 if (err)
10485 return err;
10486
10487 err = validate_output_format(nvme_args.output_format, &flags);
10488 if (err < 0) {
10489 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
10490 return err;
10491 }
10492
10493 ma_log = libnvme_alloc(sizeof(*ma_log));
10494 if (!ma_log)
10495 return -ENOMEM12;
10496
10497 err = nvme_get_log_mgmt_addr_list(hdl, ma_log, sizeof(*ma_log));
10498 if (err) {
10499 nvme_show_err(err, "management address list log");
10500 return err;
10501 }
10502
10503 nvme_show_mgmt_addr_list_log(ma_log, flags);
10504
10505 return err;
10506}
10507
10508static int get_rotational_media_info_log(int argc, char **argv, struct command *acmd,
10509 struct plugin *plugin)
10510{
10511 const char *desc = "Retrieve Rotational Media Information Log, show it";
10512 nvme_print_flags_t flags;
10513 int err = -1;
10514
10515 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_rotational_media_info_log *info = NULL((void*)0);
10516 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
10517 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
10518
10519 struct config {
10520 __u16 endgid;
10521 };
10522
10523 struct config cfg = {
10524 .endgid = 0,
10525 };
10526
10527 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"endg-id", 'e', "NUM", CFG_POSITIVE, &cfg.endgid,
1, endgid, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((
void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10528 OPT_UINT("endg-id", 'e', &cfg.endgid, endgid))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"endg-id", 'e', "NUM", CFG_POSITIVE, &cfg.endgid,
1, endgid, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((
void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v'
, "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10529
10530 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
10531 if (err)
10532 return err;
10533
10534 err = validate_output_format(nvme_args.output_format, &flags);
10535 if (err < 0) {
10536 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
10537 return err;
10538 }
10539
10540 info = libnvme_alloc(sizeof(*info));
10541 if (!info)
10542 return -ENOMEM12;
10543
10544 err = nvme_get_log_rotational_media_info(hdl, cfg.endgid, info, sizeof(*info));
10545 if (err) {
10546 nvme_show_err(err, "rotational media info log");
10547 return err;
10548 }
10549
10550 nvme_show_rotational_media_info_log(info, flags);
10551
10552 return err;
10553}
10554
10555static int get_dispersed_ns_psub(struct libnvme_transport_handle *hdl, __u32 nsid,
10556 struct nvme_dispersed_ns_participating_nss_log **logp)
10557{
10558 int err;
10559 __u64 header_len = sizeof(**logp);
10560 __u64 psub_list_len;
10561 struct nvme_dispersed_ns_participating_nss_log *log = libnvme_alloc(header_len);
10562 struct libnvme_passthru_cmd cmd;
10563
10564 if (!log)
10565 return -ENOMEM12;
10566
10567 err = nvme_get_log_dispersed_ns_participating_nss(hdl, nsid, log, header_len);
10568 if (err)
10569 goto err_free;
10570
10571 psub_list_len = le64_to_cpu(log->numpsub) * NVME_NQN_LENGTH;
10572
10573 log = libnvme_realloc(log, header_len + psub_list_len);
10574 if (!log) {
10575 err = -ENOMEM12;
10576 goto err_free;
10577 }
10578
10579 nvme_init_get_log_dispersed_ns_participating_nss(&cmd, nsid,
10580 (void *)log->participating_nss, psub_list_len);
10581 cmd.cdw12 = header_len & 0xffffffff;
10582 cmd.cdw13 = header_len >> 32;
10583 err = libnvme_get_log(hdl, &cmd, false0, NVME_LOG_PAGE_PDU_SIZE4096);
10584 if (err)
10585 goto err_free;
10586
10587 *logp = log;
10588 return 0;
10589
10590err_free:
10591 libnvme_free(log);
10592 return err;
10593}
10594
10595static int get_dispersed_ns_participating_nss_log(int argc, char **argv, struct command *acmd,
10596 struct plugin *plugin)
10597{
10598 const char *desc = "Retrieve Dispersed Namespace Participating NVM Subsystems Log, show it";
10599 nvme_print_flags_t flags;
10600 int err;
10601
10602 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
10603 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
10604 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_dispersed_ns_participating_nss_log *log = NULL((void*)0);
10605
10606 struct config {
10607 __u32 namespace_id;
10608 };
10609
10610 struct config cfg = {
10611 .namespace_id = 1,
10612 };
10613
10614 NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id
, 1, namespace_id_desired, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10615
10616 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
10617 if (err)
10618 return err;
10619
10620 err = validate_output_format(nvme_args.output_format, &flags);
10621 if (err < 0) {
10622 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
10623 return err;
10624 }
10625
10626 err = get_dispersed_ns_psub(hdl, cfg.namespace_id, &log);
10627 if (err) {
10628 nvme_show_err(err, "dispersed ns participating nss log");
10629 return err;
10630 }
10631
10632 nvme_show_dispersed_ns_psub_log(log, flags);
10633
10634 return err;
10635}
10636
10637static int get_power_measurement_log(int argc, char **argv, struct command *acmd,
10638 struct plugin *plugin)
10639{
10640 const char *desc = "Retrieve Power Measurement Log (Log ID 0x25) "
10641 "for the given device in either decoded format (default), "
10642 "json, or binary.";
10643
10644 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
10645 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
10646 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_power_meas_log *log = NULL((void*)0);
10647 nvme_print_flags_t flags;
10648 __u32 min_log_size = sizeof(struct nvme_power_meas_log);
10649 __u32 log_size;
10650 int err = -1;
10651
10652 struct config {
10653 bool_Bool raw_binary;
10654 };
10655
10656 struct config cfg = {
10657 .raw_binary = false0,
10658 };
10659
10660 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_output, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10661 OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_output))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"raw-binary", 'b', ((void*)0), CFG_FLAG, &cfg.raw_binary
, 0, raw_output, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10662
10663 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
10664 if (err)
10665 return err;
10666
10667 err = validate_output_format(nvme_args.output_format, &flags);
10668 if (err < 0) {
10669 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
10670 return err;
10671 }
10672
10673 if (cfg.raw_binary)
10674 flags = BINARY;
10675
10676 if (nvme_args.verbose)
10677 flags |= VERBOSE;
10678
10679 /* First read minimum size to discover the full log size */
10680 log = libnvme_alloc(min_log_size);
10681 if (!log)
10682 return -ENOMEM12;
10683
10684 err = nvme_get_log_power_measurement(hdl, log, min_log_size);
10685 if (err) {
10686 nvme_show_err(err, "power-measurement-log");
10687 return err;
10688 }
10689
10690 log_size = le32_to_cpu(log->sze);
10691
10692 /* If sze is 0 or smaller than the minimum, just use minimum */
10693 if (log_size < min_log_size)
10694 log_size = min_log_size;
10695
10696 /* If the log is larger, re-read with full size */
10697 if (log_size > min_log_size) {
10698 log = libnvme_realloc(log, log_size);
10699 if (!log)
10700 return -ENOMEM12;
10701
10702 err = nvme_get_log_power_measurement(hdl, log, log_size);
10703 if (err) {
10704 nvme_show_err(err, "power-measurement-log");
10705 return err;
10706 }
10707 }
10708
10709 nvme_show_power_meas_log(log, log_size, flags);
10710
10711 return err;
10712}
10713
10714static int get_log_offset(struct libnvme_transport_handle *hdl,
10715 struct nvme_get_log_args *args, __u64 *offset,
10716 __u32 len, void **log)
10717{
10718 struct libnvme_passthru_cmd cmd;
10719 int err;
10720
10721 args->lpo = *offset;
10722 args->len = len;
10723 *offset += args->len;
10724
10725 *log = libnvme_realloc(*log, *offset);
10726 if (!*log)
10727 return -ENOMEM12;
10728
10729 args->log = (char *)*log + args->lpo;
10730
10731 nvme_init_get_log(&cmd, args->nsid, args->lid,
10732 args->csi, args->log, args->len);
10733 cmd.cdw10 |= NVME_FIELD_ENCODE(args->lsp,(((__u32)(args->lsp) & (NVME_LOG_CDW10_LSP_MASK)) <<
(NVME_LOG_CDW10_LSP_SHIFT))
10734 NVME_LOG_CDW10_LSP_SHIFT,(((__u32)(args->lsp) & (NVME_LOG_CDW10_LSP_MASK)) <<
(NVME_LOG_CDW10_LSP_SHIFT))
10735 NVME_LOG_CDW10_LSP_MASK)(((__u32)(args->lsp) & (NVME_LOG_CDW10_LSP_MASK)) <<
(NVME_LOG_CDW10_LSP_SHIFT))
;
10736 cmd.cdw11 |= NVME_FIELD_ENCODE(args->lsi,(((__u32)(args->lsi) & (NVME_LOG_CDW11_LSI_MASK)) <<
(NVME_LOG_CDW11_LSI_SHIFT))
10737 NVME_LOG_CDW11_LSI_SHIFT,(((__u32)(args->lsi) & (NVME_LOG_CDW11_LSI_MASK)) <<
(NVME_LOG_CDW11_LSI_SHIFT))
10738 NVME_LOG_CDW11_LSI_MASK)(((__u32)(args->lsi) & (NVME_LOG_CDW11_LSI_MASK)) <<
(NVME_LOG_CDW11_LSI_SHIFT))
;
10739 cmd.cdw12 = args->lpo & 0xffffffff;
10740 cmd.cdw13 = args->lpo >> 32;
10741 cmd.cdw14 |= NVME_FIELD_ENCODE(args->uidx,(((__u32)(args->uidx) & (NVME_LOG_CDW14_UUID_MASK)) <<
(NVME_LOG_CDW14_UUID_SHIFT))
10742 NVME_LOG_CDW14_UUID_SHIFT,(((__u32)(args->uidx) & (NVME_LOG_CDW14_UUID_MASK)) <<
(NVME_LOG_CDW14_UUID_SHIFT))
10743 NVME_LOG_CDW14_UUID_MASK)(((__u32)(args->uidx) & (NVME_LOG_CDW14_UUID_MASK)) <<
(NVME_LOG_CDW14_UUID_SHIFT))
|
10744 NVME_FIELD_ENCODE(args->ot,(((__u32)(args->ot) & (NVME_LOG_CDW14_OT_MASK)) <<
(NVME_LOG_CDW14_OT_SHIFT))
10745 NVME_LOG_CDW14_OT_SHIFT,(((__u32)(args->ot) & (NVME_LOG_CDW14_OT_MASK)) <<
(NVME_LOG_CDW14_OT_SHIFT))
10746 NVME_LOG_CDW14_OT_MASK)(((__u32)(args->ot) & (NVME_LOG_CDW14_OT_MASK)) <<
(NVME_LOG_CDW14_OT_SHIFT))
;
10747
10748 err = libnvme_get_log(hdl, &cmd, args->rae, NVME_LOG_PAGE_PDU_SIZE4096);
10749 if (args->result)
10750 *args->result = cmd.result;
10751 return err;
10752}
10753
10754static int get_reachability_group_desc(struct libnvme_transport_handle *hdl, struct nvme_get_log_args *args,
10755 __u64 *offset, struct nvme_reachability_groups_log **logp)
10756{
10757 int err;
10758 struct nvme_reachability_groups_log *log = *logp;
10759 __u16 i;
10760 __u32 len;
10761
10762 for (i = 0; i < le16_to_cpu(log->nrgd); i++) {
10763 len = sizeof(*log->rgd);
10764 err = get_log_offset(hdl, args, offset, len, (void **)&log);
10765 if (err)
10766 goto err_free;
10767 len = le32_to_cpu(log->rgd[i].nnid) * sizeof(*log->rgd[i].nsid);
10768 err = get_log_offset(hdl, args, offset, len, (void **)&log);
10769 if (err)
10770 goto err_free;
10771 }
10772
10773 *logp = log;
10774 return 0;
10775
10776err_free:
10777 libnvme_free(log);
10778 *logp = NULL((void*)0);
10779 return err;
10780}
10781
10782static int get_reachability_groups(struct libnvme_transport_handle *hdl, bool_Bool rgo, bool_Bool rae,
10783 struct nvme_reachability_groups_log **logp,
10784 __u64 *lenp)
10785{
10786 int err;
10787 struct nvme_reachability_groups_log *log;
10788 __u64 log_len = sizeof(*log);
10789 struct nvme_get_log_args args = {
10790 .lid = NVME_LOG_LID_REACHABILITY_GROUPS,
10791 .nsid = NVME_NSID_ALL,
10792 .lsp = rgo,
10793 .rae = rae,
10794 };
10795
10796 log = libnvme_alloc(log_len);
10797 if (!log)
10798 return -ENOMEM12;
10799
10800 err = nvme_get_log_reachability_groups(hdl, rgo, rae, log, log_len);
10801 if (err)
10802 goto err_free;
10803
10804 err = get_reachability_group_desc(hdl, &args, &log_len, &log);
10805 if (err)
10806 goto err_free;
10807
10808 *logp = log;
10809 *lenp = log_len;
10810 return 0;
10811
10812err_free:
10813 libnvme_free(log);
10814 return err;
10815}
10816
10817static int get_reachability_groups_log(int argc, char **argv, struct command *acmd,
10818 struct plugin *plugin)
10819{
10820 const char *desc = "Retrieve Reachability Groups Log, show it";
10821 const char *rgo = "Return Groups Only";
10822 nvme_print_flags_t flags;
10823 int err;
10824 __u64 len = 0;
10825 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_reachability_groups_log *log = NULL((void*)0);
10826 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
10827 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
10828
10829 struct config {
10830 bool_Bool rgo;
10831 bool_Bool rae;
10832 };
10833
10834 struct config cfg = {
10835 .rgo = false0,
10836 .rae = false0,
10837 };
10838
10839 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"groups-only", 'g', ((void*)0), CFG_FLAG, &cfg.rgo
, 0, rgo, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae
, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10840 OPT_FLAG("groups-only", 'g', &cfg.rgo, rgo),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"groups-only", 'g', ((void*)0), CFG_FLAG, &cfg.rgo
, 0, rgo, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae
, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10841 OPT_FLAG("rae", 'r', &cfg.rae, rae))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"groups-only", 'g', ((void*)0), CFG_FLAG, &cfg.rgo
, 0, rgo, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae
, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void
*)0), 0, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM"
, CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10842
10843 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
10844 if (err)
10845 return err;
10846
10847 err = validate_output_format(nvme_args.output_format, &flags);
10848 if (err < 0) {
10849 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
10850 return err;
10851 }
10852
10853 err = get_reachability_groups(hdl, cfg.rgo, cfg.rae, &log, &len);
10854 if (err) {
10855 nvme_show_err(err, "reachability groups log");
10856 return err;
10857 }
10858
10859 nvme_show_reachability_groups_log(log, len, flags);
10860
10861 return err;
10862}
10863
10864static int get_reachability_association_desc(struct libnvme_transport_handle *hdl, struct nvme_get_log_args *args,
10865 __u64 *offset,
10866 struct nvme_reachability_associations_log **logp)
10867{
10868 int err;
10869 struct nvme_reachability_associations_log *log = *logp;
10870 __u16 i;
10871 __u32 len;
10872
10873 for (i = 0; i < le16_to_cpu(log->nrad); i++) {
10874 len = sizeof(*log->rad);
10875 err = get_log_offset(hdl, args, offset, len, (void **)&log);
10876 if (err)
10877 goto err_free;
10878 len = le32_to_cpu(log->rad[i].nrid) * sizeof(*log->rad[i].rgid);
10879 err = get_log_offset(hdl, args, offset, len, (void **)&log);
10880 if (err)
10881 goto err_free;
10882 }
10883
10884 *logp = log;
10885 return 0;
10886
10887err_free:
10888 libnvme_free(log);
10889 *logp = NULL((void*)0);
10890 return err;
10891}
10892
10893static int get_reachability_associations(struct libnvme_transport_handle *hdl, bool_Bool rao, bool_Bool rae,
10894 struct nvme_reachability_associations_log **logp,
10895 __u64 *lenp)
10896{
10897 int err;
10898 struct nvme_reachability_associations_log *log;
10899 __u64 log_len = sizeof(*log);
10900 struct nvme_get_log_args args = {
10901 .lid = NVME_LOG_LID_REACHABILITY_ASSOCIATIONS,
10902 .nsid = NVME_NSID_ALL,
10903 .lsp = rao,
10904 .rae = rae,
10905 };
10906
10907 log = libnvme_alloc(log_len);
10908 if (!log)
10909 return -ENOMEM12;
10910
10911 err = nvme_get_log_reachability_associations(hdl, rao, rae, log, log_len);
10912 if (err)
10913 goto err_free;
10914
10915 err = get_reachability_association_desc(hdl, &args, &log_len, &log);
10916 if (err)
10917 goto err_free;
10918
10919 *logp = log;
10920 *lenp = log_len;
10921 return 0;
10922
10923err_free:
10924 libnvme_free(log);
10925 return err;
10926}
10927
10928static int get_reachability_associations_log(int argc, char **argv, struct command *acmd,
10929 struct plugin *plugin)
10930{
10931 const char *desc = "Retrieve Reachability Associations Log, show it";
10932 const char *rao = "Return Associations Only";
10933 nvme_print_flags_t flags;
10934 int err;
10935 __u64 len = 0;
10936 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_reachability_associations_log *log = NULL((void*)0);
10937 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
10938 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
10939
10940 struct config {
10941 bool_Bool rao;
10942 bool_Bool rae;
10943 };
10944
10945 struct config cfg = {
10946 .rao = false0,
10947 .rae = false0,
10948 };
10949
10950 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"associations-only", 'a', ((void*)0), CFG_FLAG, &
cfg.rao, 0, rao, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10951 OPT_FLAG("associations-only", 'a', &cfg.rao, rao),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"associations-only", 'a', ((void*)0), CFG_FLAG, &
cfg.rao, 0, rao, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
10952 OPT_FLAG("rae", 'r', &cfg.rae, rae))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"associations-only", 'a', ((void*)0), CFG_FLAG, &
cfg.rao, 0, rao, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG, &
cfg.rae, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
10953
10954 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
10955 if (err)
10956 return err;
10957
10958 err = validate_output_format(nvme_args.output_format, &flags);
10959 if (err < 0) {
10960 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
10961 return err;
10962 }
10963
10964 err = get_reachability_associations(hdl, cfg.rao, cfg.rae, &log, &len);
10965 if (err) {
10966 nvme_show_err(err, "reachability associations log");
10967 return err;
10968 }
10969
10970 nvme_show_reachability_associations_log(log, len, flags);
10971
10972 return err;
10973}
10974
10975static int get_host_discovery(struct libnvme_transport_handle *hdl, bool_Bool allhoste, bool_Bool rae,
10976 struct nvme_host_discovery_log **logp)
10977{
10978 int err;
10979 struct nvme_host_discovery_log *log;
10980 __u64 log_len = sizeof(*log);
10981 struct nvme_get_log_args args = {
10982 .lid = NVME_LOG_LID_HOST_DISCOVERY,
10983 .nsid = NVME_NSID_ALL,
10984 .lsp = allhoste,
10985 .rae = rae,
10986 };
10987
10988 log = libnvme_alloc(log_len);
10989 if (!log)
10990 return -ENOMEM12;
10991
10992 err = nvme_get_log_host_discovery(hdl, allhoste, rae, log, log_len);
10993 if (err)
10994 goto err_free;
10995
10996 log_len = le32_to_cpu(log->thdlpl);
10997 err = get_log_offset(hdl, &args, &log_len, le32_to_cpu(log->thdlpl) - log_len,
10998 (void **)&log);
10999 if (err)
11000 goto err_free;
11001
11002 *logp = log;
11003 return 0;
11004
11005err_free:
11006 libnvme_free(log);
11007 return err;
11008}
11009
11010static int get_host_discovery_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
11011{
11012 const char *desc = "Retrieve Host Discovery Log, show it";
11013 const char *allhoste = "All Host Entries";
11014 nvme_print_flags_t flags;
11015 int err;
11016 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_host_discovery_log *log = NULL((void*)0);
11017 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
11018 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
11019
11020 struct config {
11021 bool_Bool allhoste;
11022 bool_Bool rae;
11023 };
11024
11025 struct config cfg = {
11026 .allhoste = false0,
11027 .rae = false0,
11028 };
11029
11030 NVME_ARGS(opts,nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"all-host-entries", 'a', ((void*)0), CFG_FLAG, &cfg
.allhoste, 0, allhoste, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG
, &cfg.rae, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
11031 OPT_FLAG("all-host-entries", 'a', &cfg.allhoste, allhoste),nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"all-host-entries", 'a', ((void*)0), CFG_FLAG, &cfg
.allhoste, 0, allhoste, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG
, &cfg.rae, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
11032 OPT_FLAG("rae", 'r', &cfg.rae, rae))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"all-host-entries", 'a', ((void*)0), CFG_FLAG, &cfg
.allhoste, 0, allhoste, 0, }, {"rae", 'r', ((void*)0), CFG_FLAG
, &cfg.rae, 0, rae, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR
, ((void*)0), 0, "Global options", 0, ((void*)0)}, {"verbose"
, 'v', "NUM", CFG_INCREMENT, &nvme_args.verbose, 0, "Increase output verbosity"
, 0, }, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet
, 0, "suppress output messages, overwrites verbose mode", 0, }
, {"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
11033
11034
11035 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
11036 if (err)
11037 return err;
11038
11039 err = validate_output_format(nvme_args.output_format, &flags);
11040 if (err < 0) {
11041 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
11042 return err;
11043 }
11044
11045 err = get_host_discovery(hdl, cfg.allhoste, cfg.rae, &log);
11046 if (err) {
11047 nvme_show_err(err, "host discovery log");
11048 return err;
11049 }
11050
11051 nvme_show_host_discovery_log(log, flags);
11052
11053 return err;
11054}
11055
11056static int get_ave_discovery(struct libnvme_transport_handle *hdl, bool_Bool rae,
11057 struct nvme_ave_discovery_log **logp)
11058{
11059 int err;
11060 struct nvme_ave_discovery_log *log;
11061 __u64 log_len = sizeof(*log);
11062 struct nvme_get_log_args args = {
11063 .lid = NVME_LOG_LID_AVE_DISCOVERY,
11064 .nsid = NVME_NSID_ALL,
11065 .rae = rae,
11066 };
11067
11068 log = libnvme_alloc(log_len);
11069 if (!log)
11070 return -ENOMEM12;
11071
11072 err = nvme_get_log_ave_discovery(hdl, rae, log, log_len);
11073 if (err)
11074 goto err_free;
11075
11076 log_len = le32_to_cpu(log->tadlpl);
11077 err = get_log_offset(hdl, &args, &log_len, le32_to_cpu(log->tadlpl) - log_len,
11078 (void **)&log);
11079 if (err)
11080 goto err_free;
11081
11082 *logp = log;
11083 return 0;
11084
11085err_free:
11086 libnvme_free(log);
11087 return err;
11088}
11089
11090static int get_ave_discovery_log(int argc, char **argv, struct command *acmd, struct plugin *plugin)
11091{
11092 const char *desc = "Retrieve AVE Discovery Log, show it";
11093 nvme_print_flags_t flags;
11094 int err;
11095
11096 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_ave_discovery_log *log = NULL((void*)0);
11097 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
11098 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
11099
11100 struct config {
11101 bool_Bool rae;
11102 };
11103
11104 struct config cfg = {
11105 .rae = false0,
11106 };
11107
11108 NVME_ARGS(opts, OPT_FLAG("rae", 'r', &cfg.rae, rae))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
11109
11110 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
11111 if (err)
11112 return err;
11113
11114 err = validate_output_format(nvme_args.output_format, &flags);
11115 if (err < 0) {
11116 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
11117 return err;
11118 }
11119
11120 err = get_ave_discovery(hdl, cfg.rae, &log);
11121 if (err) {
11122 nvme_show_err(err, "ave discovery log");
11123 return err;
11124 }
11125
11126 nvme_show_ave_discovery_log(log, flags);
11127
11128 return err;
11129}
11130
11131static int get_pull_model_ddc_req(struct libnvme_transport_handle *hdl,
11132 bool_Bool rae, struct nvme_pull_model_ddc_req_log **logp)
11133{
11134 int err;
11135 struct nvme_pull_model_ddc_req_log *log;
11136 __u64 log_len = sizeof(*log);
11137 struct nvme_get_log_args args = {
11138 .lid = NVME_LOG_LID_PULL_MODEL_DDC_REQ,
11139 .nsid = NVME_NSID_ALL,
11140 .rae = rae,
11141 };
11142
11143 log = libnvme_alloc(log_len);
11144 if (!log)
11145 return -ENOMEM12;
11146
11147 err = nvme_get_log_pull_model_ddc_req(hdl, rae, log, log_len);
11148 if (err)
11149 goto err_free;
11150
11151 log_len = le32_to_cpu(log->tpdrpl);
11152 err = get_log_offset(hdl, &args, &log_len, le32_to_cpu(log->tpdrpl) - log_len,
11153 (void **)&log);
11154 if (err)
11155 goto err_free;
11156
11157 *logp = log;
11158 return 0;
11159
11160err_free:
11161 libnvme_free(log);
11162 return err;
11163}
11164
11165static int get_pull_model_ddc_req_log(int argc, char **argv, struct command *acmd,
11166 struct plugin *plugin)
11167{
11168 const char *desc = "Retrieve Pull Model DDC Request Log, show it";
11169 nvme_print_flags_t flags;
11170 int err;
11171
11172 __cleanup_libnvme_free__attribute__((cleanup(libnvme_freep))) struct nvme_pull_model_ddc_req_log *log = NULL((void*)0);
11173 __cleanup_nvme_global_ctx__attribute__((cleanup(cleanup_nvme_global_ctx))) struct libnvme_global_ctx *ctx = NULL((void*)0);
11174 __cleanup_nvme_transport_handle__attribute__((cleanup(cleanup_nvme_transport_handle))) struct libnvme_transport_handle *hdl = NULL((void*)0);
11175
11176 struct config {
11177 bool_Bool rae;
11178 };
11179
11180 struct config cfg = {
11181 .rae = false0,
11182 };
11183
11184 NVME_ARGS(opts, OPT_FLAG("rae", 'r', &cfg.rae, rae))nvme_args.supported_output_formats = (NORMAL | JSON | BINARY)
; struct argconfig_commandline_options opts[] = { {"", 0, ((void
*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0, "Options", 0, ((void
*)0)}, {"rae", 'r', ((void*)0), CFG_FLAG, &cfg.rae, 0, rae
, 0, }, {"", 0, ((void*)0), CFG_GROUP_SEPARATOR, ((void*)0), 0
, "Global options", 0, ((void*)0)}, {"verbose", 'v', "NUM", CFG_INCREMENT
, &nvme_args.verbose, 0, "Increase output verbosity", 0, }
, {"quiet", 0, ((void*)0), CFG_FLAG, &nvme_args.quiet, 0,
"suppress output messages, overwrites verbose mode", 0, }, {
"output-format", 'o', "FMT", CFG_STRING, &nvme_args.output_format
, 1, "Output format: normal|json|binary", 0, }, {"timeout", 0
, "NUM", CFG_POSITIVE, &nvme_args.timeout, 1, "timeout value, in milliseconds"
, 0, }, {"dry-run", 0, ((void*)0), CFG_FLAG, &nvme_args.dry_run
, 0, "show command instead of executing", 0, }, {"no-retries"
, 0, ((void*)0), CFG_FLAG, &nvme_args.no_retries, 0, "disable retry logic on errors"
, 0, }, {"no-ioctl-probing", 0, ((void*)0), CFG_FLAG, &nvme_args
.no_ioctl_probing, 0, "disable 64-bit IOCTL support probing",
0, }, {"output-format-version", 0, "NUM", CFG_POSITIVE, &
nvme_args.output_format_ver, 1, "output format version: 1|2",
0, }, {"human-readable", 'H', ((void*)0), CFG_FLAG, &nvme_args
.verbose, 0, ((void*)0), 0, ((void*)0), 1}, {"set-options", 0
, "KEY=VALUE", CFG_STRING, &nvme_args.set_options, 1, "set a libnvme library option (key=value[,key=value,...]);"
, 0, }, { ((void*)0) } }
;
11185
11186 err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
1
Calling 'parse_and_open'
11187 if (err)
11188 return err;
11189
11190 err = validate_output_format(nvme_args.output_format, &flags);
11191 if (err < 0) {
11192 nvme_show_error("Invalid output format")nvme_show_message(1, "Invalid output format");
11193 return err;
11194 }
11195
11196 err = get_pull_model_ddc_req(hdl, cfg.rae, &log);
11197 if (err) {
11198 nvme_show_err(err, "pull model ddc req log");
11199 return err;
11200 }
11201
11202 nvme_show_pull_model_ddc_req_log(log, flags);
11203
11204 return err;
11205}
11206
11207void register_extension(struct plugin *plugin)
11208{
11209 plugin->parent = &nvme;
11210 nvme.extensions->tail->next = plugin;
11211 nvme.extensions->tail = plugin;
11212}
11213
11214int main(int argc, char **argv)
11215{
11216 int err;
11217
11218#ifdef _WIN32
11219 /*
11220 * Set stdout and stderr to binary mode to prevent Windows text-mode
11221 * translation from converting LF to CRLF and corrupting binary output.
11222 */
11223 _setmode(_fileno(stdoutstdout), O_BINARY);
11224 _setmode(_fileno(stderrstderr), O_BINARY);
11225#endif
11226
11227 nvme.extensions->parent = &nvme;
11228 if (argc < 2) {
11229 general_help(&builtin, NULL((void*)0));
11230 return 0;
11231 }
11232 setlocale(LC_ALL6, "");
11233
11234 err = nvme_load_global_config();
11235 if (err)
11236 return err;
11237
11238 err = shr_install_sigint_handler();
11239 if (err)
11240 return err;
11241
11242 err = handle_plugin(argc, argv, nvme.extensions);
11243 if (err == -ENOTTY25)
11244 general_help(&builtin, NULL((void*)0));
11245
11246 nvme_show_finish();
11247
11248 return err ? 1 : 0;
11249}