Lines Matching +full:no +full:- +full:can +full:- +full:fd
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (C) 2018-2019 Alexander Motin <mav@FreeBSD.org>
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
80 { arg_string, &active_opt.dev, "controller-id|namespace-id" },
113 { arg_string, &controllers_opt.dev, "controller-id|namespace-id" },
173 // OPT("block-size", 'b', arg_uint32, create_opt, block_size,
179 { arg_string, &create_opt.dev, "controller-id|namespace-id" },
198 .nsid = NONE - 1,
203 OPT("namespace-id", 'n', arg_uint32, delete_opt, nsid,
209 { arg_string, &delete_opt.dev, "controller-id|namespace-id" },
230 .ctrlrid = NONE - 1,
235 OPT("namespace-id", 'n', arg_uint32, attach_opt, nsid,
243 { arg_string, &attach_opt.dev, "controller-id|namespace-id" },
267 OPT("namespace-id", 'n', arg_uint32, attached_opt, nsid,
273 { arg_string, &attached_opt.dev, "controller-id|namespace-id" },
294 .ctrlrid = NONE - 1,
299 OPT("namespace-id", 'n', arg_uint32, detach_opt, nsid,
307 { arg_string, &detach_opt.dev, "controller-id|namespace-id" },
345 { arg_string, &identify_opt.dev, "controller-id|namespace-id" },
388 while (t->res != 0xFFFF) {
389 if (t->res == res)
390 return (t->str);
393 return t->str;
401 int fd, i;
408 open_dev(active_opt.dev, &fd, 0, 1);
409 get_nsid(fd, &path, &nsid);
411 close(fd);
412 open_dev(path, &fd, 0, 1);
415 if (read_controller_data(fd, &cd))
418 /* Check that controller can execute this command. */
429 if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
446 int fd, i;
453 open_dev(active_opt.dev, &fd, 0, 1);
454 get_nsid(fd, &path, &nsid);
456 close(fd);
457 open_dev(path, &fd, 0, 1);
460 if (read_controller_data(fd, &cd))
463 /* Check that controller can execute this command. */
474 if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
491 int fd, i, n;
498 open_dev(controllers_opt.dev, &fd, 0, 1);
499 get_nsid(fd, &path, &nsid);
501 close(fd);
502 open_dev(path, &fd, 0, 1);
505 if (read_controller_data(fd, &cd))
508 /* Check that controller can execute this command. */
518 if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
544 int fd, result;
559 open_dev(create_opt.dev, &fd, 1, 1);
560 get_nsid(fd, &path, &nsid);
562 close(fd);
563 open_dev(path, &fd, 1, 1);
566 if (read_controller_data(fd, &cd))
569 /* Check that controller can execute this command. */
607 /* Allow namespaces sharing if Multi-Path I/O is supported. */
618 if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0)
634 int fd, result;
642 open_dev(delete_opt.dev, &fd, 1, 1);
643 get_nsid(fd, &path, &nsid);
645 close(fd);
646 open_dev(path, &fd, 1, 1);
647 } else if (delete_opt.nsid == NONE - 1) {
648 close(fd);
649 fprintf(stderr, "No NSID specified\n");
652 if (delete_opt.nsid != NONE - 1)
655 if (read_controller_data(fd, &cd))
658 /* Check that controller can execute this command. */
670 if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0)
694 * 0x2 Invalid Field can occur if ctrlrid d.n.e in system.
701 int fd, result;
708 open_dev(attach_opt.dev, &fd, 1, 1);
709 get_nsid(fd, &path, &nsid);
711 close(fd);
712 open_dev(path, &fd, 1, 1);
714 close(fd);
715 fprintf(stderr, "No NSID specified\n");
720 if (read_controller_data(fd, &cd))
723 /* Check that controller can execute this command. */
735 if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
741 if (attach_opt.ctrlrid == NONE - 1)
755 if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0)
771 int fd, result;
778 open_dev(detach_opt.dev, &fd, 1, 1);
779 get_nsid(fd, &path, &nsid);
781 close(fd);
782 open_dev(path, &fd, 1, 1);
784 close(fd);
785 fprintf(stderr, "No NSID specified\n");
790 if (read_controller_data(fd, &cd))
793 /* Check that controller can execute this command. */
806 if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
818 if (detach_opt.ctrlrid == NONE - 1)
832 if ((result = ioctl(fd, NVME_PASSTHROUGH_CMD, &pt)) < 0)
848 int fd, i, n;
855 open_dev(attached_opt.dev, &fd, 0, 1);
856 get_nsid(fd, &path, &nsid);
858 close(fd);
859 open_dev(path, &fd, 1, 1);
861 close(fd);
862 fprintf(stderr, "No NSID specified\n");
867 if (read_controller_data(fd, &cd))
870 /* Check that controller can execute this command. */
881 if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
901 int fd;
908 open_dev(identify_opt.dev, &fd, 0, 1);
909 get_nsid(fd, &path, &nsid);
911 close(fd);
912 open_dev(path, &fd, 1, 1);
914 close(fd);
915 fprintf(stderr, "No NSID specified\n");
920 if (read_controller_data(fd, &cd))
923 /* Check that controller can execute this command. */
935 if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
941 close(fd);
957 for (; i > 384; i--) {
958 if (data[i - 1] != 0)