]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Added dry-run (-d) option to nvme-io-passthru
authorStephen Bates <stephen.bates@pmcs.com>
Sat, 7 Feb 2015 02:48:33 +0000 (02:48 +0000)
committerStephen Bates <stephen.bates@pmcs.com>
Sat, 7 Feb 2015 02:48:33 +0000 (02:48 +0000)
Added the option to dry-run the nvme-io-passthru command. Use with the
show option. The plan is to add this to other commands in due course.

Documentation/nvme-io-passthru.1
Documentation/nvme-io-passthru.txt
nvme.c

index 43b8601f172f1aacae38e9f9132ca47ab5c24ede..29a696e55e49faf434973c5b04f8f4bd6ce65bf7 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: nvme-io-passthru
 .\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\"      Date: 02/02/2015
+.\"      Date: 02/06/2015
 .\"    Manual: \ \&
 .\"    Source: \ \&
 .\"  Language: English
 .\"
-.TH "NVME\-IO\-PASSTHRU" "1" "02/02/2015" "\ \&" "\ \&"
+.TH "NVME\-IO\-PASSTHRU" "1" "02/06/2015" "\ \&" "\ \&"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -101,9 +101,14 @@ The data length for the buffer used for this command\&.
 The metadata length for the buffer used for this command\&.
 .RE
 .PP
-\-s, \-\-show\-cmd, \-\-dry\-run
+\-s, \-\-show\-cmd
 .RS 4
-Do not actually send the command; print out the command that would be sent\&.
+Print out the command to be sent\&.
+.RE
+.PP
+\-d, \-\-dry\-run
+.RS 4
+Do not actually send the command\&.
 .RE
 .PP
 \-b, \-\-raw\-binary
@@ -112,7 +117,7 @@ Print the raw returned buffer to stdout if the command returns data or a structu
 .RE
 .SH "EXAMPLES"
 .sp
-No examples yet\&.
+nvme io\-passthru /dev/nvme0n1 \-\-opcode=2 \-\-namespace\-id=1 \-\-data\-len=4096 \-\-read \-\-cdw10=0 \-\-cdw11=0 \-\-cdw12=0x70000 \-\-raw\-binary
 .SH "NVME"
 .sp
 Part of the nvme\-user suite
index ac97e8664a9ce04f5aacb03d6bdb5d30b0d66078..08ac19e7f5836d534ac9bdcadde82f9e3459f200 100644 (file)
@@ -83,9 +83,11 @@ OPTIONS
 
 -s::
 --show-cmd::
+       Print out the command to be sent.
+
+-d::
 --dry-run::
-       Do not actually send the command; print out the command that
-       would be sent.
+       Do not actually send the command.
 
 -b::
 --raw-binary::
@@ -94,7 +96,8 @@ OPTIONS
 
 EXAMPLES
 --------
-No examples yet.
+
+nvme io-passthru /dev/nvme0n1 --opcode=2 --namespace-id=1 --data-len=4096 --read --cdw10=0 --cdw11=0 --cdw12=0x70000 --raw-binary
 
 NVME
 ----
diff --git a/nvme.c b/nvme.c
index d39aae4b856883538ec436d34935041c74cd4baa..bfe60e303c4d554207137059e878eab3ab5e5caa 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -1872,7 +1872,7 @@ static int sec_recv(int argc, char **argv)
 static int nvme_passthru(int argc, char **argv, int ioctl_cmd)
 {
        int r = 0, w = 0;
-       int opt, err, raw = 0, show = 0, long_index = 0, wfd = STDIN_FILENO;
+       int opt, err, raw = 0, show = 0, dry_run = 0, long_index = 0, wfd = STDIN_FILENO;
        struct nvme_passthru_cmd cmd;
        static struct option opts[] = {
                {"opcode", required_argument, 0, 'o'},
@@ -1892,7 +1892,7 @@ static int nvme_passthru(int argc, char **argv, int ioctl_cmd)
                {"cdw15", required_argument, 0, '9'},
                {"raw-binary", no_argument, 0, 'b'},
                {"show-command", no_argument, 0, 's'},
-               {"dry-run", no_argument, 0, 's'},
+               {"dry-run", no_argument, 0, 'd'},
                {"read", no_argument, 0, 'r'},
                {"write", no_argument, 0, 'w'},
                {"input-file", no_argument, 0, 'i'},
@@ -1900,7 +1900,7 @@ static int nvme_passthru(int argc, char **argv, int ioctl_cmd)
        };
 
        memset(&cmd, 0, sizeof(cmd));
-       while ((opt = getopt_long(argc, (char **)argv, "o:n:f:l:R:m:t:i:bsrw", opts,
+       while ((opt = getopt_long(argc, (char **)argv, "o:n:f:l:R:m:t:i:bsdrw", opts,
                                                        &long_index)) != -1) {
                switch (opt) {
                case '2': get_int(optarg, &cmd.cdw2); break;
@@ -1920,6 +1920,7 @@ static int nvme_passthru(int argc, char **argv, int ioctl_cmd)
                case 't': get_int(optarg, &cmd.timeout_ms); break;
                case 'b': raw = 1; break;
                case 's': show = 1; break;
+               case 'd': dry_run = 1; break;
                case 'r': r = 1; break;
                case 'w': w = 1; break;
                case 'i':
@@ -1971,7 +1972,8 @@ static int nvme_passthru(int argc, char **argv, int ioctl_cmd)
                printf("cdw14        : %08x\n", cmd.cdw14);
                printf("cdw15        : %08x\n", cmd.cdw15);
                printf("timeout_ms   : %08x\n", cmd.timeout_ms);
-               return 0;
+               if (dry_run)
+                 return 0;
        }
        err = ioctl(fd, ioctl_cmd, &cmd);
        if (err >= 0) {