--- /dev/null
+'\" t
+.\" Title: nvme-compare
+.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
+.\" Date: 02/04/2015
+.\" Manual: \ \&
+.\" Source: \ \&
+.\" Language: English
+.\"
+.TH "NVME\-COMPARE" "1" "02/04/2015" "\ \&" "\ \&"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+nvme-read \- Send an NVMe Read command, provide results
+.SH "SYNOPSIS"
+.sp
+.nf
+\fInvme\-read\fR <device> [\-\-start\-block=<slba> | \-s <slba>]
+ [\-\-block\-count=<nlb> | \-c <nlb>]
+ [\-\-data\-size=<size> | \-z <size>]
+ [\-\-ref\-tag=<reftag> | \-r <reftag>]
+ [\-\-data=<data\-file> | \-d <data\-file>]
+ [\-\-prinfo=<prinfo> | \-p <prinfo>]
+ [\-\-app\-tag\-mask=<appmask> | \-m <appmask>]
+ [\-\-app\-tag=<apptag> | \-a <apptag>]
+ [\-\-limited\-retry | \-l]
+ [\-\-force\-unit\-access | \-f]
+.fi
+.SH "DESCRIPTION"
+.sp
+The Read command reads the logical blocks specified by the command from the medium and copies to the data data buffer provided\&. Will use stdout by default if you don\(cqt provide a file\&.
+.SH "OPTIONS"
+.PP
+\-\-start\-block=<slba>, \-s <slba>
+.RS 4
+Start block\&.
+.RE
+.SH "EXAMPLES"
+.sp
+No examples yet\&.
+.SH "NVME"
+.sp
+Part of the nvme\-user suite
--- /dev/null
+'\" t
+.\" Title: nvme-compare
+.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
+.\" Date: 02/04/2015
+.\" Manual: \ \&
+.\" Source: \ \&
+.\" Language: English
+.\"
+.TH "NVME\-COMPARE" "1" "02/04/2015" "\ \&" "\ \&"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+nvme-write \- Send an NVMe write command, provide results
+.SH "SYNOPSIS"
+.sp
+.nf
+\fInvme\-write\fR <device> [\-\-start\-block=<slba> | \-s <slba>]
+ [\-\-block\-count=<nlb> | \-c <nlb>]
+ [\-\-data\-size=<size> | \-z <size>]
+ [\-\-ref\-tag=<reftag> | \-r <reftag>]
+ [\-\-data=<data\-file> | \-d <data\-file>]
+ [\-\-prinfo=<prinfo> | \-p <prinfo>]
+ [\-\-app\-tag\-mask=<appmask> | \-m <appmask>]
+ [\-\-app\-tag=<apptag> | \-a <apptag>]
+ [\-\-limited\-retry | \-l]
+ [\-\-force\-unit\-access | \-f]
+.fi
+.SH "DESCRIPTION"
+.sp
+The Write command writes the logical blocks specified by the command to the medium from the data data buffer provided\&. Will use stdin by default if you don\(cqt provide a file\&.
+.SH "OPTIONS"
+.PP
+\-\-start\-block=<slba>, \-s <slba>
+.RS 4
+Start block\&.
+.RE
+.SH "EXAMPLES"
+.sp
+No examples yet\&.
+.SH "NVME"
+.sp
+Part of the nvme\-user suite
.\" Title: nvme
.\" Author: [see the "Authors" section]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: 02/03/2015
+.\" Date: 02/04/2015
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "NVME" "1" "02/03/2015" "\ \&" "\ \&"
+.TH "NVME" "1" "02/04/2015" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
The utility has sub\-commands for all admin and io commands defined in the specification and for displaying controller registers\&. There is also an option to submit completely arbitrary commands\&. For a list of commands available, run "nvme help"\&.
.SH "FURTHER DOCUMENTATION"
.sp
-See the freely available references on \m[blue]\fBOffical NVM\-Express Site\fR\m[]\&\s-2\u[1]\d\s+2\&.
+See the freely available references on the \m[blue]\fBOffical NVM\-Express Site\fR\m[]\&\s-2\u[1]\d\s+2\&.
.SH "AUTHORS"
.sp
This is written and maintained by \m[blue]\fBKeith Busch\fR\m[]\&\s-2\u[2]\d\s+2\&.
ENTRY(RESV_REPORT, "resv-report", "Submit a Reservation Report, return results", resv_report) \
ENTRY(FLUSH, "flush", "Submit a Flush command, return results", flush) \
ENTRY(COMPARE, "compare", "Submit a Comapre command, return results", compare) \
+ ENTRY(READ, "read", "Submit a read command, return results", read_cmd) \
+ ENTRY(WRITE, "write", "Submit a write command, return results", write_cmd) \
ENTRY(REGISTERS, "show-regs", "Shows the controller registers. Requires admin character device", show_registers) \
ENTRY(HELP, "help", "Display this help", help)
return 0;
}
-static int compare(int argc, char **argv)
+static int submit_io(int opcode, char *command, int argc, char **argv)
{
struct nvme_user_io io;
void *buffer;
- int err, opt, dfd = STDIN_FILENO, long_index = 0;
+ int err, opt, dfd = opcode & 1 ? STDIN_FILENO : STDOUT_FILENO,
+ long_index = 0;
unsigned int data_size = 0;
__u8 prinfo = 0;
+
+ /* XXX: metadata ? */
static struct option opts[] = {
{"start-block", required_argument, 0, 's'},
{"block-count", required_argument, 0, 'c'},
return EINVAL;
}
buffer = malloc(data_size);
- if (read(dfd, (void *)buffer, data_size) < 0) {
- fprintf(stderr, "failed to read compare buffer\n");
+ if ((opcode & 1) && read(dfd, (void *)buffer, data_size) < 0) {
+ fprintf(stderr, "failed to read buffer from input file\n");
return EINVAL;
}
- io.opcode = nvme_cmd_compare;
+ io.opcode = opcode;
io.addr = (__u64)buffer;
err = ioctl(fd, NVME_IOCTL_SUBMIT_IO, &io);
if (err < 0)
perror("ioctl");
- else
- printf("compare:%s(%04x)\n", nvme_status_to_string(err), err);
+ else if (err)
+ printf("%s:%s(%04x)\n", command, nvme_status_to_string(err), err);
+ else {
+ if (!(opcode & 1) && write(dfd, (void *)buffer, data_size) < 0) {
+ fprintf(stderr, "failed to write buffer to output file\n");
+ return EINVAL;
+ } else
+ printf("%s: success\n", command);
+ }
return 0;
}
+static int compare(int argc, char **argv)
+{
+ return submit_io(nvme_cmd_compare, "compare", argc, argv);
+}
+
+static int read_cmd(int argc, char **argv)
+{
+ return submit_io(nvme_cmd_read, "read", argc, argv);
+}
+
+static int write_cmd(int argc, char **argv)
+{
+ return submit_io(nvme_cmd_write, "write", argc, argv);
+}
+
static int sec_recv(int argc, char **argv)
{
struct nvme_admin_cmd cmd;