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 62361 2000-07-01 21:28:49Z n_hibma $
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, "dem: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
1558 while ((c = getopt(argc, argv, combinedopt)) != -1) {
1559 switch(c) {
1560 case 'd':
1561 arglist |= CAM_ARG_DBD;
1562 break;
1563 case 'e':
1564 arglist |= CAM_ARG_MODE_EDIT;
1565 break;
1566 case 'm':
1567 mode_page = strtol(optarg, NULL, 0);
1568 if (mode_page < 0)
1569 errx(1, "invalid mode page %d", mode_page);
1570 break;
1571 case 'P':
1572 page_control = strtol(optarg, NULL, 0);
1573 if ((page_control < 0) || (page_control > 3))
1574 errx(1, "invalid page control field %d",
1575 page_control);
1576 arglist |= CAM_ARG_PAGE_CNTL;
1577 break;
1578 default:
1579 break;
1580 }
1581 }
1582
1583 if (mode_page == -1)
1584 errx(1, "you must specify a mode page!");
1585
1586 mode_edit(device, mode_page, page_control, arglist & CAM_ARG_DBD,
1587 arglist & CAM_ARG_MODE_EDIT, retry_count, timeout);
1588}
1589
1590static int
1591scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
1592 int retry_count, int timeout)
1593{
1594 union ccb *ccb;
1595 u_int32_t flags = CAM_DIR_NONE;
--- 1374 unchanged lines hidden (view full) ---
2970" camcontrol tur [dev_id][generic args]\n"
2971" camcontrol inquiry [dev_id][generic args] [-D] [-S] [-R]\n"
2972" camcontrol start [dev_id][generic args]\n"
2973" camcontrol stop [dev_id][generic args]\n"
2974" camcontrol eject [dev_id][generic args]\n"
2975" camcontrol rescan <bus[:target:lun]>\n"
2976" camcontrol reset <bus[:target:lun]>\n"
2977" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n"
2978" camcontrol modepage [dev_id][generic args] <-m page> [-P pagectl]\n"
2979" [-e][-d]\n"
2980" camcontrol cmd [dev_id][generic args] <-c cmd [args]>\n"
2981" [-i len fmt|-o len fmt [args]]\n"
2982" camcontrol debug [-I][-T][-S][-c] <all|bus[:target[:lun]]|off>\n"
2983" camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n"
2984" camcontrol negotiate [dev_id][generic args] [-a][-c]\n"
2985" [-D <enable|disable>][-O offset][-q]\n"
2986" [-R syncrate][-v][-T <enable|disable>]\n"
2987" [-U][-W bus_width]\n"
--- 29 unchanged lines hidden (view full) ---
3017"-t timeout command timeout in seconds, overrides default timeout\n"
3018"-n dev_name specify device name, e.g. \"da\", \"cd\"\n"
3019"-u unit specify unit number, e.g. \"0\", \"5\"\n"
3020"-E have the kernel attempt to perform SCSI error recovery\n"
3021"-C count specify the SCSI command retry count (needs -E to work)\n"
3022"modepage arguments:\n"
3023"-m page specify the mode page to view or edit\n"
3024"-e edit the specified mode page\n"
3025"-d disable block descriptors for mode sense\n"
3026"-P pgctl page control field 0-3\n"
3027"defects arguments:\n"
3028"-f format specify defect list format (block, bfi or phys)\n"
3029"-G get the grown defect list\n"
3030"-P get the permanant defect list\n"
3031"inquiry arguments:\n"
3032"-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 62361 2000-07-01 21:28:49Z n_hibma $
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, "dem: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
1558 while ((c = getopt(argc, argv, combinedopt)) != -1) {
1559 switch(c) {
1560 case 'd':
1561 arglist |= CAM_ARG_DBD;
1562 break;
1563 case 'e':
1564 arglist |= CAM_ARG_MODE_EDIT;
1565 break;
1566 case 'm':
1567 mode_page = strtol(optarg, NULL, 0);
1568 if (mode_page < 0)
1569 errx(1, "invalid mode page %d", mode_page);
1570 break;
1571 case 'P':
1572 page_control = strtol(optarg, NULL, 0);
1573 if ((page_control < 0) || (page_control > 3))
1574 errx(1, "invalid page control field %d",
1575 page_control);
1576 arglist |= CAM_ARG_PAGE_CNTL;
1577 break;
1578 default:
1579 break;
1580 }
1581 }
1582
1583 if (mode_page == -1)
1584 errx(1, "you must specify a mode page!");
1585
1586 mode_edit(device, mode_page, page_control, arglist & CAM_ARG_DBD,
1587 arglist & CAM_ARG_MODE_EDIT, retry_count, timeout);
1588}
1589
1590static int
1591scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
1592 int retry_count, int timeout)
1593{
1594 union ccb *ccb;
1595 u_int32_t flags = CAM_DIR_NONE;
--- 1374 unchanged lines hidden (view full) ---
2970" camcontrol tur [dev_id][generic args]\n"
2971" camcontrol inquiry [dev_id][generic args] [-D] [-S] [-R]\n"
2972" camcontrol start [dev_id][generic args]\n"
2973" camcontrol stop [dev_id][generic args]\n"
2974" camcontrol eject [dev_id][generic args]\n"
2975" camcontrol rescan <bus[:target:lun]>\n"
2976" camcontrol reset <bus[:target:lun]>\n"
2977" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n"
2978" camcontrol modepage [dev_id][generic args] <-m page> [-P pagectl]\n"
2979" [-e][-d]\n"
2980" camcontrol cmd [dev_id][generic args] <-c cmd [args]>\n"
2981" [-i len fmt|-o len fmt [args]]\n"
2982" camcontrol debug [-I][-T][-S][-c] <all|bus[:target[:lun]]|off>\n"
2983" camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n"
2984" camcontrol negotiate [dev_id][generic args] [-a][-c]\n"
2985" [-D <enable|disable>][-O offset][-q]\n"
2986" [-R syncrate][-v][-T <enable|disable>]\n"
2987" [-U][-W bus_width]\n"
--- 29 unchanged lines hidden (view full) ---
3017"-t timeout command timeout in seconds, overrides default timeout\n"
3018"-n dev_name specify device name, e.g. \"da\", \"cd\"\n"
3019"-u unit specify unit number, e.g. \"0\", \"5\"\n"
3020"-E have the kernel attempt to perform SCSI error recovery\n"
3021"-C count specify the SCSI command retry count (needs -E to work)\n"
3022"modepage arguments:\n"
3023"-m page specify the mode page to view or edit\n"
3024"-e edit the specified mode page\n"
3025"-d disable block descriptors for mode sense\n"
3026"-P pgctl page control field 0-3\n"
3027"defects arguments:\n"
3028"-f format specify defect list format (block, bfi or phys)\n"
3029"-G get the grown defect list\n"
3030"-P get the permanant defect list\n"
3031"inquiry arguments:\n"
3032"-D get the standard inquiry data\n"
--- 307 unchanged lines hidden ---