Use proper variable for device path.

It seems *-passthru commands were broken from the day one, since the
device path is fetched into opt.dev variable and not left in argv[optind].
The other three wrong argv[optind] instances are just in error messages.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
This commit is contained in:
mav 2020-10-28 17:28:48 +00:00
parent 3d93a38eab
commit 219c6ff7cd
3 changed files with 4 additions and 4 deletions

View File

@ -605,7 +605,7 @@ nscreate(const struct cmd *f, int argc, char *argv[])
pt.len = sizeof(struct nvme_namespace_data);
pt.is_read = 0; /* passthrough writes data to ctrlr */
if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0)
errx(1, "ioctl request to %s failed: %d", argv[optind], result);
errx(1, "ioctl request to %s failed: %d", create_opt.dev, result);
if (nvme_completion_is_error(&pt.cpl)) {
errx(1, "namespace creation failed: %s",
@ -822,7 +822,7 @@ nsdetach(const struct cmd *f, int argc, char *argv[])
pt.len = sizeof(clist);
if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0)
errx(1, "ioctl request to %s failed: %d", argv[optind], result);
errx(1, "ioctl request to %s failed: %d", detach_opt.dev, result);
if (nvme_completion_is_error(&pt.cpl)) {
errx(1, "namespace detach failed: %s",

View File

@ -164,7 +164,7 @@ passthru(const struct cmd *f, int argc, char *argv[])
if (arg_parse(argc, argv, f))
return;
open_dev(argv[optind], &fd, 1, 1);
open_dev(opt.dev, &fd, 1, 1);
if (opt.read && opt.write)
errx(1, "need exactly one of --read or --write");

View File

@ -70,7 +70,7 @@ reset(const struct cmd *f, int argc, char *argv[])
free(path);
if (ioctl(fd, NVME_RESET_CONTROLLER) < 0)
err(1, "reset request to %s failed", argv[optind]);
err(1, "reset request to %s failed", opt.dev);
exit(0);
}