1/*
2 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sbin/camcontrol/camcontrol.c 64382 2000-08-08 06:24:17Z kbyanc $
29 */
30
31#include <sys/ioctl.h>
32#include <sys/types.h>
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36#include <unistd.h>
--- 82 unchanged lines hidden (view full) ---
119 {"rescan", CAM_ARG_RESCAN, NULL},
120 {"reset", CAM_ARG_RESET, NULL},
121 {"cmd", CAM_ARG_SCSI_CMD, scsicmd_opts},
122 {"command", CAM_ARG_SCSI_CMD, scsicmd_opts},
123 {"defects", CAM_ARG_READ_DEFECTS, readdefect_opts},
124 {"defectlist", CAM_ARG_READ_DEFECTS, readdefect_opts},
125 {"devlist", CAM_ARG_DEVTREE, NULL},
126 {"periphlist", CAM_ARG_DEVLIST, NULL},
127 {"modepage", CAM_ARG_MODE_PAGE, "bdelm:P:"},
128 {"tags", CAM_ARG_TAG, "N:q"},
129 {"negotiate", CAM_ARG_RATE, negotiate_opts},
130 {"rate", CAM_ARG_RATE, negotiate_opts},
131 {"debug", CAM_ARG_DEBUG, "ITSc"},
132 {"format", CAM_ARG_FORMAT, "qwy"},
133 {"help", CAM_ARG_USAGE, NULL},
134 {"-?", CAM_ARG_USAGE, NULL},
135 {"-h", CAM_ARG_USAGE, NULL},
--- 1413 unchanged lines hidden (view full) ---
1549 cam_freeccb(ccb);
1550}
1551
1552void
1553modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
1554 int retry_count, int timeout)
1555{
1556 int c, mode_page = -1, page_control = 0;
1557 int binary = 0, list = 0;
1558
1559 while ((c = getopt(argc, argv, combinedopt)) != -1) {
1560 switch(c) {
1561 case 'b':
1562 binary = 1;
1563 break;
1564 case 'd':
1565 arglist |= CAM_ARG_DBD;
1566 break;
1567 case 'e':
1568 arglist |= CAM_ARG_MODE_EDIT;
1569 break;
1570 case 'l':
1571 list = 1;
1572 break;
1573 case 'm':
1574 mode_page = strtol(optarg, NULL, 0);
1575 if (mode_page < 0)
1576 errx(1, "invalid mode page %d", mode_page);
1577 break;
1578 case 'P':
1579 page_control = strtol(optarg, NULL, 0);
1580 if ((page_control < 0) || (page_control > 3))
1581 errx(1, "invalid page control field %d",
1582 page_control);
1583 arglist |= CAM_ARG_PAGE_CNTL;
1584 break;
1585 default:
1586 break;
1587 }
1588 }
1589
1590 if (mode_page == -1 && list == 0)
1591 errx(1, "you must specify a mode page!");
1592
1593 if (list) {
1594 mode_list(device, page_control, arglist & CAM_ARG_DBD,
1595 retry_count, timeout);
1596 } else {
1597 mode_edit(device, mode_page, page_control,
1598 arglist & CAM_ARG_DBD, arglist & CAM_ARG_MODE_EDIT, binary,
1599 retry_count, timeout);
1600 }
1601}
1602
1603static int
1604scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
1605 int retry_count, int timeout)
1606{
1607 union ccb *ccb;
1608 u_int32_t flags = CAM_DIR_NONE;
--- 1374 unchanged lines hidden (view full) ---
2983" camcontrol tur [dev_id][generic args]\n"
2984" camcontrol inquiry [dev_id][generic args] [-D] [-S] [-R]\n"
2985" camcontrol start [dev_id][generic args]\n"
2986" camcontrol stop [dev_id][generic args]\n"
2987" camcontrol eject [dev_id][generic args]\n"
2988" camcontrol rescan <bus[:target:lun]>\n"
2989" camcontrol reset <bus[:target:lun]>\n"
2990" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n"
2991" camcontrol modepage [dev_id][generic args] <-m page | -l>\n"
2992" [-P pagectl][-e | -b][-d]\n"
2993" camcontrol cmd [dev_id][generic args] <-c cmd [args]>\n"
2994" [-i len fmt|-o len fmt [args]]\n"
2995" camcontrol debug [-I][-T][-S][-c] <all|bus[:target[:lun]]|off>\n"
2996" camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n"
2997" camcontrol negotiate [dev_id][generic args] [-a][-c]\n"
2998" [-D <enable|disable>][-O offset][-q]\n"
2999" [-R syncrate][-v][-T <enable|disable>]\n"
3000" [-U][-W bus_width]\n"
--- 29 unchanged lines hidden (view full) ---
3030"-t timeout command timeout in seconds, overrides default timeout\n"
3031"-n dev_name specify device name, e.g. \"da\", \"cd\"\n"
3032"-u unit specify unit number, e.g. \"0\", \"5\"\n"
3033"-E have the kernel attempt to perform SCSI error recovery\n"
3034"-C count specify the SCSI command retry count (needs -E to work)\n"
3035"modepage arguments:\n"
3036"-m page specify the mode page to view or edit\n"
3037"-e edit the specified mode page\n"
3038"-b force view to binary mode\n"
3039"-d disable block descriptors for mode sense\n"
3040"-P pgctl page control field 0-3\n"
3041"defects arguments:\n"
3042"-f format specify defect list format (block, bfi or phys)\n"
3043"-G get the grown defect list\n"
3044"-P get the permanant defect list\n"
3045"inquiry arguments:\n"
3046"-D get the standard inquiry data\n"
--- 307 unchanged lines hidden ---
2 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sbin/camcontrol/camcontrol.c 64382 2000-08-08 06:24:17Z kbyanc $
29 */
30
31#include <sys/ioctl.h>
32#include <sys/types.h>
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36#include <unistd.h>
--- 82 unchanged lines hidden (view full) ---
119 {"rescan", CAM_ARG_RESCAN, NULL},
120 {"reset", CAM_ARG_RESET, NULL},
121 {"cmd", CAM_ARG_SCSI_CMD, scsicmd_opts},
122 {"command", CAM_ARG_SCSI_CMD, scsicmd_opts},
123 {"defects", CAM_ARG_READ_DEFECTS, readdefect_opts},
124 {"defectlist", CAM_ARG_READ_DEFECTS, readdefect_opts},
125 {"devlist", CAM_ARG_DEVTREE, NULL},
126 {"periphlist", CAM_ARG_DEVLIST, NULL},
127 {"modepage", CAM_ARG_MODE_PAGE, "bdelm:P:"},
128 {"tags", CAM_ARG_TAG, "N:q"},
129 {"negotiate", CAM_ARG_RATE, negotiate_opts},
130 {"rate", CAM_ARG_RATE, negotiate_opts},
131 {"debug", CAM_ARG_DEBUG, "ITSc"},
132 {"format", CAM_ARG_FORMAT, "qwy"},
133 {"help", CAM_ARG_USAGE, NULL},
134 {"-?", CAM_ARG_USAGE, NULL},
135 {"-h", CAM_ARG_USAGE, NULL},
--- 1413 unchanged lines hidden (view full) ---
1549 cam_freeccb(ccb);
1550}
1551
1552void
1553modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
1554 int retry_count, int timeout)
1555{
1556 int c, mode_page = -1, page_control = 0;
1557 int binary = 0, list = 0;
1558
1559 while ((c = getopt(argc, argv, combinedopt)) != -1) {
1560 switch(c) {
1561 case 'b':
1562 binary = 1;
1563 break;
1564 case 'd':
1565 arglist |= CAM_ARG_DBD;
1566 break;
1567 case 'e':
1568 arglist |= CAM_ARG_MODE_EDIT;
1569 break;
1570 case 'l':
1571 list = 1;
1572 break;
1573 case 'm':
1574 mode_page = strtol(optarg, NULL, 0);
1575 if (mode_page < 0)
1576 errx(1, "invalid mode page %d", mode_page);
1577 break;
1578 case 'P':
1579 page_control = strtol(optarg, NULL, 0);
1580 if ((page_control < 0) || (page_control > 3))
1581 errx(1, "invalid page control field %d",
1582 page_control);
1583 arglist |= CAM_ARG_PAGE_CNTL;
1584 break;
1585 default:
1586 break;
1587 }
1588 }
1589
1590 if (mode_page == -1 && list == 0)
1591 errx(1, "you must specify a mode page!");
1592
1593 if (list) {
1594 mode_list(device, page_control, arglist & CAM_ARG_DBD,
1595 retry_count, timeout);
1596 } else {
1597 mode_edit(device, mode_page, page_control,
1598 arglist & CAM_ARG_DBD, arglist & CAM_ARG_MODE_EDIT, binary,
1599 retry_count, timeout);
1600 }
1601}
1602
1603static int
1604scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
1605 int retry_count, int timeout)
1606{
1607 union ccb *ccb;
1608 u_int32_t flags = CAM_DIR_NONE;
--- 1374 unchanged lines hidden (view full) ---
2983" camcontrol tur [dev_id][generic args]\n"
2984" camcontrol inquiry [dev_id][generic args] [-D] [-S] [-R]\n"
2985" camcontrol start [dev_id][generic args]\n"
2986" camcontrol stop [dev_id][generic args]\n"
2987" camcontrol eject [dev_id][generic args]\n"
2988" camcontrol rescan <bus[:target:lun]>\n"
2989" camcontrol reset <bus[:target:lun]>\n"
2990" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n"
2991" camcontrol modepage [dev_id][generic args] <-m page | -l>\n"
2992" [-P pagectl][-e | -b][-d]\n"
2993" camcontrol cmd [dev_id][generic args] <-c cmd [args]>\n"
2994" [-i len fmt|-o len fmt [args]]\n"
2995" camcontrol debug [-I][-T][-S][-c] <all|bus[:target[:lun]]|off>\n"
2996" camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n"
2997" camcontrol negotiate [dev_id][generic args] [-a][-c]\n"
2998" [-D <enable|disable>][-O offset][-q]\n"
2999" [-R syncrate][-v][-T <enable|disable>]\n"
3000" [-U][-W bus_width]\n"
--- 29 unchanged lines hidden (view full) ---
3030"-t timeout command timeout in seconds, overrides default timeout\n"
3031"-n dev_name specify device name, e.g. \"da\", \"cd\"\n"
3032"-u unit specify unit number, e.g. \"0\", \"5\"\n"
3033"-E have the kernel attempt to perform SCSI error recovery\n"
3034"-C count specify the SCSI command retry count (needs -E to work)\n"
3035"modepage arguments:\n"
3036"-m page specify the mode page to view or edit\n"
3037"-e edit the specified mode page\n"
3038"-b force view to binary mode\n"
3039"-d disable block descriptors for mode sense\n"
3040"-P pgctl page control field 0-3\n"
3041"defects arguments:\n"
3042"-f format specify defect list format (block, bfi or phys)\n"
3043"-G get the grown defect list\n"
3044"-P get the permanant defect list\n"
3045"inquiry arguments:\n"
3046"-D get the standard inquiry data\n"
--- 307 unchanged lines hidden ---