camcontrol.c (87378) | camcontrol.c (89471) |
---|---|
1/* 2 * Copyright (c) 1997, 1998, 1999, 2000, 2001 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 * | 1/* 2 * Copyright (c) 1997, 1998, 1999, 2000, 2001 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 87378 2001-12-05 03:41:40Z ken $ | 28 * $FreeBSD: head/sbin/camcontrol/camcontrol.c 89471 2002-01-17 20:26:14Z joerg $ |
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> --- 62 unchanged lines hidden (view full) --- 99} cam_argmask; 100 101struct camcontrol_opts { 102 char *optname; 103 cam_argmask argnum; 104 const char *subopt; 105}; 106 | 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> --- 62 unchanged lines hidden (view full) --- 99} cam_argmask; 100 101struct camcontrol_opts { 102 char *optname; 103 cam_argmask argnum; 104 const char *subopt; 105}; 106 |
107#ifndef MINIMALISTIC |
|
107static const char scsicmd_opts[] = "c:i:o:"; 108static const char readdefect_opts[] = "f:GP"; 109static const char negotiate_opts[] = "acD:O:qR:T:UW:"; | 108static const char scsicmd_opts[] = "c:i:o:"; 109static const char readdefect_opts[] = "f:GP"; 110static const char negotiate_opts[] = "acD:O:qR:T:UW:"; |
111#endif |
|
110 111struct camcontrol_opts option_table[] = { | 112 113struct camcontrol_opts option_table[] = { |
114#ifndef MINIMALISTIC |
|
112 {"tur", CAM_ARG_TUR, NULL}, 113 {"inquiry", CAM_ARG_INQUIRY, "DSR"}, 114 {"start", CAM_ARG_STARTSTOP | CAM_ARG_START_UNIT, NULL}, 115 {"stop", CAM_ARG_STARTSTOP, NULL}, 116 {"eject", CAM_ARG_STARTSTOP | CAM_ARG_EJECT, NULL}, | 115 {"tur", CAM_ARG_TUR, NULL}, 116 {"inquiry", CAM_ARG_INQUIRY, "DSR"}, 117 {"start", CAM_ARG_STARTSTOP | CAM_ARG_START_UNIT, NULL}, 118 {"stop", CAM_ARG_STARTSTOP, NULL}, 119 {"eject", CAM_ARG_STARTSTOP | CAM_ARG_EJECT, NULL}, |
120#endif /* MINIMALISTIC */ |
|
117 {"rescan", CAM_ARG_RESCAN, NULL}, 118 {"reset", CAM_ARG_RESET, NULL}, | 121 {"rescan", CAM_ARG_RESCAN, NULL}, 122 {"reset", CAM_ARG_RESET, NULL}, |
123#ifndef MINIMALISTIC |
|
119 {"cmd", CAM_ARG_SCSI_CMD, scsicmd_opts}, 120 {"command", CAM_ARG_SCSI_CMD, scsicmd_opts}, 121 {"defects", CAM_ARG_READ_DEFECTS, readdefect_opts}, 122 {"defectlist", CAM_ARG_READ_DEFECTS, readdefect_opts}, 123 {"devlist", CAM_ARG_DEVTREE, NULL}, 124 {"periphlist", CAM_ARG_DEVLIST, NULL}, 125 {"modepage", CAM_ARG_MODE_PAGE, "bdelm:P:"}, 126 {"tags", CAM_ARG_TAG, "N:q"}, 127 {"negotiate", CAM_ARG_RATE, negotiate_opts}, 128 {"rate", CAM_ARG_RATE, negotiate_opts}, 129 {"debug", CAM_ARG_DEBUG, "ITSc"}, 130 {"format", CAM_ARG_FORMAT, "qwy"}, | 124 {"cmd", CAM_ARG_SCSI_CMD, scsicmd_opts}, 125 {"command", CAM_ARG_SCSI_CMD, scsicmd_opts}, 126 {"defects", CAM_ARG_READ_DEFECTS, readdefect_opts}, 127 {"defectlist", CAM_ARG_READ_DEFECTS, readdefect_opts}, 128 {"devlist", CAM_ARG_DEVTREE, NULL}, 129 {"periphlist", CAM_ARG_DEVLIST, NULL}, 130 {"modepage", CAM_ARG_MODE_PAGE, "bdelm:P:"}, 131 {"tags", CAM_ARG_TAG, "N:q"}, 132 {"negotiate", CAM_ARG_RATE, negotiate_opts}, 133 {"rate", CAM_ARG_RATE, negotiate_opts}, 134 {"debug", CAM_ARG_DEBUG, "ITSc"}, 135 {"format", CAM_ARG_FORMAT, "qwy"}, |
136#endif /* MINIMALISTIC */ |
|
131 {"help", CAM_ARG_USAGE, NULL}, 132 {"-?", CAM_ARG_USAGE, NULL}, 133 {"-h", CAM_ARG_USAGE, NULL}, 134 {NULL, 0, NULL} 135}; 136 137typedef enum { 138 CC_OR_NOT_FOUND, 139 CC_OR_AMBIGUOUS, 140 CC_OR_FOUND 141} camcontrol_optret; 142 143cam_argmask arglist; 144int bus, target, lun; 145 146 147camcontrol_optret getoption(char *arg, cam_argmask *argnum, char **subopt); | 137 {"help", CAM_ARG_USAGE, NULL}, 138 {"-?", CAM_ARG_USAGE, NULL}, 139 {"-h", CAM_ARG_USAGE, NULL}, 140 {NULL, 0, NULL} 141}; 142 143typedef enum { 144 CC_OR_NOT_FOUND, 145 CC_OR_AMBIGUOUS, 146 CC_OR_FOUND 147} camcontrol_optret; 148 149cam_argmask arglist; 150int bus, target, lun; 151 152 153camcontrol_optret getoption(char *arg, cam_argmask *argnum, char **subopt); |
154#ifndef MINIMALISTIC |
|
148static int getdevlist(struct cam_device *device); 149static int getdevtree(void); 150static int testunitready(struct cam_device *device, int retry_count, 151 int timeout, int quiet); 152static int scsistart(struct cam_device *device, int startstop, int loadeject, 153 int retry_count, int timeout); 154static int scsidoinquiry(struct cam_device *device, int argc, char **argv, 155 char *combinedopt, int retry_count, int timeout); 156static int scsiinquiry(struct cam_device *device, int retry_count, int timeout); 157static int scsiserial(struct cam_device *device, int retry_count, int timeout); 158static int scsixferrate(struct cam_device *device); | 155static int getdevlist(struct cam_device *device); 156static int getdevtree(void); 157static int testunitready(struct cam_device *device, int retry_count, 158 int timeout, int quiet); 159static int scsistart(struct cam_device *device, int startstop, int loadeject, 160 int retry_count, int timeout); 161static int scsidoinquiry(struct cam_device *device, int argc, char **argv, 162 char *combinedopt, int retry_count, int timeout); 163static int scsiinquiry(struct cam_device *device, int retry_count, int timeout); 164static int scsiserial(struct cam_device *device, int retry_count, int timeout); 165static int scsixferrate(struct cam_device *device); |
166#endif /* MINIMALISTIC */ |
|
159static int parse_btl(char *tstr, int *bus, int *target, int *lun, 160 cam_argmask *arglist); 161static int dorescan_or_reset(int argc, char **argv, int rescan); 162static int rescan_or_reset_bus(int bus, int rescan); 163static int scanlun_or_reset_dev(int bus, int target, int lun, int scan); | 167static int parse_btl(char *tstr, int *bus, int *target, int *lun, 168 cam_argmask *arglist); 169static int dorescan_or_reset(int argc, char **argv, int rescan); 170static int rescan_or_reset_bus(int bus, int rescan); 171static int scanlun_or_reset_dev(int bus, int target, int lun, int scan); |
172#ifndef MINIMALISTIC |
|
164static int readdefects(struct cam_device *device, int argc, char **argv, 165 char *combinedopt, int retry_count, int timeout); 166static void modepage(struct cam_device *device, int argc, char **argv, 167 char *combinedopt, int retry_count, int timeout); 168static int scsicmd(struct cam_device *device, int argc, char **argv, 169 char *combinedopt, int retry_count, int timeout); 170static int tagcontrol(struct cam_device *device, int argc, char **argv, 171 char *combinedopt); 172static void cts_print(struct cam_device *device, 173 struct ccb_trans_settings *cts); 174static void cpi_print(struct ccb_pathinq *cpi); 175static int get_cpi(struct cam_device *device, struct ccb_pathinq *cpi); 176static int get_print_cts(struct cam_device *device, int user_settings, 177 int quiet, struct ccb_trans_settings *cts); 178static int ratecontrol(struct cam_device *device, int retry_count, 179 int timeout, int argc, char **argv, char *combinedopt); 180static int scsiformat(struct cam_device *device, int argc, char **argv, 181 char *combinedopt, int retry_count, int timeout); | 173static int readdefects(struct cam_device *device, int argc, char **argv, 174 char *combinedopt, int retry_count, int timeout); 175static void modepage(struct cam_device *device, int argc, char **argv, 176 char *combinedopt, int retry_count, int timeout); 177static int scsicmd(struct cam_device *device, int argc, char **argv, 178 char *combinedopt, int retry_count, int timeout); 179static int tagcontrol(struct cam_device *device, int argc, char **argv, 180 char *combinedopt); 181static void cts_print(struct cam_device *device, 182 struct ccb_trans_settings *cts); 183static void cpi_print(struct ccb_pathinq *cpi); 184static int get_cpi(struct cam_device *device, struct ccb_pathinq *cpi); 185static int get_print_cts(struct cam_device *device, int user_settings, 186 int quiet, struct ccb_trans_settings *cts); 187static int ratecontrol(struct cam_device *device, int retry_count, 188 int timeout, int argc, char **argv, char *combinedopt); 189static int scsiformat(struct cam_device *device, int argc, char **argv, 190 char *combinedopt, int retry_count, int timeout); |
191#endif /* MINIMALISTIC */ |
|
182 183camcontrol_optret 184getoption(char *arg, cam_argmask *argnum, char **subopt) 185{ 186 struct camcontrol_opts *opts; 187 int num_matches = 0; 188 189 for (opts = option_table; (opts != NULL) && (opts->optname != NULL); --- 7 unchanged lines hidden (view full) --- 197 } 198 199 if (num_matches > 0) 200 return(CC_OR_FOUND); 201 else 202 return(CC_OR_NOT_FOUND); 203} 204 | 192 193camcontrol_optret 194getoption(char *arg, cam_argmask *argnum, char **subopt) 195{ 196 struct camcontrol_opts *opts; 197 int num_matches = 0; 198 199 for (opts = option_table; (opts != NULL) && (opts->optname != NULL); --- 7 unchanged lines hidden (view full) --- 207 } 208 209 if (num_matches > 0) 210 return(CC_OR_FOUND); 211 else 212 return(CC_OR_NOT_FOUND); 213} 214 |
215#ifndef MINIMALISTIC |
|
205static int 206getdevlist(struct cam_device *device) 207{ 208 union ccb *ccb; 209 char status[32]; 210 int error = 0; 211 212 ccb = cam_getccb(device); --- 693 unchanged lines hidden (view full) --- 906 fprintf(stdout, "\n"); 907 908xferrate_bailout: 909 910 cam_freeccb(ccb); 911 912 return(retval); 913} | 216static int 217getdevlist(struct cam_device *device) 218{ 219 union ccb *ccb; 220 char status[32]; 221 int error = 0; 222 223 ccb = cam_getccb(device); --- 693 unchanged lines hidden (view full) --- 917 fprintf(stdout, "\n"); 918 919xferrate_bailout: 920 921 cam_freeccb(ccb); 922 923 return(retval); 924} |
925#endif /* MINIMALISTIC */ |
|
914 915/* 916 * Parse out a bus, or a bus, target and lun in the following 917 * format: 918 * bus 919 * bus:target 920 * bus:target:lun 921 * --- 188 unchanged lines hidden (view full) --- 1110 } else { 1111 fprintf(stdout, "%s of %d:%d:%d returned error %#x\n", 1112 scan? "Re-scan" : "Reset", bus, target, lun, 1113 ccb.ccb_h.status & CAM_STATUS_MASK); 1114 return(1); 1115 } 1116} 1117 | 926 927/* 928 * Parse out a bus, or a bus, target and lun in the following 929 * format: 930 * bus 931 * bus:target 932 * bus:target:lun 933 * --- 188 unchanged lines hidden (view full) --- 1122 } else { 1123 fprintf(stdout, "%s of %d:%d:%d returned error %#x\n", 1124 scan? "Re-scan" : "Reset", bus, target, lun, 1125 ccb.ccb_h.status & CAM_STATUS_MASK); 1126 return(1); 1127 } 1128} 1129 |
1130#ifndef MINIMALISTIC |
|
1118static int 1119readdefects(struct cam_device *device, int argc, char **argv, 1120 char *combinedopt, int retry_count, int timeout) 1121{ 1122 union ccb *ccb = NULL; 1123 struct scsi_read_defect_data_10 *rdd_cdb; 1124 u_int8_t *defect_list = NULL; 1125 u_int32_t dlist_length = 65000; --- 273 unchanged lines hidden (view full) --- 1399 if (defect_list != NULL) 1400 free(defect_list); 1401 1402 if (ccb != NULL) 1403 cam_freeccb(ccb); 1404 1405 return(error); 1406} | 1131static int 1132readdefects(struct cam_device *device, int argc, char **argv, 1133 char *combinedopt, int retry_count, int timeout) 1134{ 1135 union ccb *ccb = NULL; 1136 struct scsi_read_defect_data_10 *rdd_cdb; 1137 u_int8_t *defect_list = NULL; 1138 u_int32_t dlist_length = 65000; --- 273 unchanged lines hidden (view full) --- 1412 if (defect_list != NULL) 1413 free(defect_list); 1414 1415 if (ccb != NULL) 1416 cam_freeccb(ccb); 1417 1418 return(error); 1419} |
1420#endif /* MINIMALISTIC */ |
|
1407 1408#if 0 1409void 1410reassignblocks(struct cam_device *device, u_int32_t *blocks, int num_blocks) 1411{ 1412 union ccb *ccb; 1413 1414 ccb = cam_getccb(device); 1415 1416 cam_freeccb(ccb); 1417} 1418#endif 1419 | 1421 1422#if 0 1423void 1424reassignblocks(struct cam_device *device, u_int32_t *blocks, int num_blocks) 1425{ 1426 union ccb *ccb; 1427 1428 ccb = cam_getccb(device); 1429 1430 cam_freeccb(ccb); 1431} 1432#endif 1433 |
1434#ifndef MINIMALISTIC |
|
1420void 1421mode_sense(struct cam_device *device, int mode_page, int page_control, 1422 int dbd, int retry_count, int timeout, u_int8_t *data, int datalen) 1423{ 1424 union ccb *ccb; 1425 int retval; 1426 1427 ccb = cam_getccb(device); --- 1533 unchanged lines hidden (view full) --- 2961 fprintf(stdout, "\nFormat Complete\n"); 2962 2963scsiformat_bailout: 2964 2965 cam_freeccb(ccb); 2966 2967 return(error); 2968} | 1435void 1436mode_sense(struct cam_device *device, int mode_page, int page_control, 1437 int dbd, int retry_count, int timeout, u_int8_t *data, int datalen) 1438{ 1439 union ccb *ccb; 1440 int retval; 1441 1442 ccb = cam_getccb(device); --- 1533 unchanged lines hidden (view full) --- 2976 fprintf(stdout, "\nFormat Complete\n"); 2977 2978scsiformat_bailout: 2979 2980 cam_freeccb(ccb); 2981 2982 return(error); 2983} |
2984#endif /* MINIMALISTIC */ |
|
2969 2970void 2971usage(int verbose) 2972{ 2973 fprintf(verbose ? stdout : stderr, 2974"usage: camcontrol <command> [device id][generic args][command args]\n" | 2985 2986void 2987usage(int verbose) 2988{ 2989 fprintf(verbose ? stdout : stderr, 2990"usage: camcontrol <command> [device id][generic args][command args]\n" |
2991#ifndef MINIMALISTIC |
|
2975" camcontrol devlist [-v]\n" 2976" camcontrol periphlist [dev_id][-n dev_name] [-u unit]\n" 2977" camcontrol tur [dev_id][generic args]\n" 2978" camcontrol inquiry [dev_id][generic args] [-D] [-S] [-R]\n" 2979" camcontrol start [dev_id][generic args]\n" 2980" camcontrol stop [dev_id][generic args]\n" 2981" camcontrol eject [dev_id][generic args]\n" | 2992" camcontrol devlist [-v]\n" 2993" camcontrol periphlist [dev_id][-n dev_name] [-u unit]\n" 2994" camcontrol tur [dev_id][generic args]\n" 2995" camcontrol inquiry [dev_id][generic args] [-D] [-S] [-R]\n" 2996" camcontrol start [dev_id][generic args]\n" 2997" camcontrol stop [dev_id][generic args]\n" 2998" camcontrol eject [dev_id][generic args]\n" |
2999#endif /* MINIMALISTIC */ |
|
2982" camcontrol rescan <bus[:target:lun]>\n" 2983" camcontrol reset <bus[:target:lun]>\n" | 3000" camcontrol rescan <bus[:target:lun]>\n" 3001" camcontrol reset <bus[:target:lun]>\n" |
3002#ifndef MINIMALISTIC |
|
2984" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n" 2985" camcontrol modepage [dev_id][generic args] <-m page | -l>\n" 2986" [-P pagectl][-e | -b][-d]\n" 2987" camcontrol cmd [dev_id][generic args] <-c cmd [args]>\n" 2988" [-i len fmt|-o len fmt [args]]\n" 2989" camcontrol debug [-I][-T][-S][-c] <all|bus[:target[:lun]]|off>\n" 2990" camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n" 2991" camcontrol negotiate [dev_id][generic args] [-a][-c]\n" 2992" [-D <enable|disable>][-O offset][-q]\n" 2993" [-R syncrate][-v][-T <enable|disable>]\n" 2994" [-U][-W bus_width]\n" 2995" camcontrol format [dev_id][generic args][-q][-w][-y]\n" | 3003" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n" 3004" camcontrol modepage [dev_id][generic args] <-m page | -l>\n" 3005" [-P pagectl][-e | -b][-d]\n" 3006" camcontrol cmd [dev_id][generic args] <-c cmd [args]>\n" 3007" [-i len fmt|-o len fmt [args]]\n" 3008" camcontrol debug [-I][-T][-S][-c] <all|bus[:target[:lun]]|off>\n" 3009" camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n" 3010" camcontrol negotiate [dev_id][generic args] [-a][-c]\n" 3011" [-D <enable|disable>][-O offset][-q]\n" 3012" [-R syncrate][-v][-T <enable|disable>]\n" 3013" [-U][-W bus_width]\n" 3014" camcontrol format [dev_id][generic args][-q][-w][-y]\n" |
3015#endif /* MINIMALISTIC */ |
|
2996" camcontrol help\n"); 2997 if (!verbose) 2998 return; | 3016" camcontrol help\n"); 3017 if (!verbose) 3018 return; |
3019#ifndef MINIMALISTIC |
|
2999 fprintf(stdout, 3000"Specify one of the following options:\n" 3001"devlist list all CAM devices\n" 3002"periphlist list all CAM peripheral drivers attached to a device\n" 3003"tur send a test unit ready to the named device\n" 3004"inquiry send a SCSI inquiry command to the named device\n" 3005"start send a Start Unit command to the device\n" 3006"stop send a Stop Unit command to the device\n" --- 57 unchanged lines hidden (view full) --- 3064"-T <arg> \"enable\" or \"disable\" tagged queueing\n" 3065"-U report/set user negotiation settings\n" 3066"-W bus_width set the bus width in bits (8, 16 or 32)\n" 3067"-v also print a Path Inquiry CCB for the controller\n" 3068"format arguments:\n" 3069"-q be quiet, don't print status messages\n" 3070"-w don't send immediate format command\n" 3071"-y don't ask any questions\n"); | 3020 fprintf(stdout, 3021"Specify one of the following options:\n" 3022"devlist list all CAM devices\n" 3023"periphlist list all CAM peripheral drivers attached to a device\n" 3024"tur send a test unit ready to the named device\n" 3025"inquiry send a SCSI inquiry command to the named device\n" 3026"start send a Start Unit command to the device\n" 3027"stop send a Stop Unit command to the device\n" --- 57 unchanged lines hidden (view full) --- 3085"-T <arg> \"enable\" or \"disable\" tagged queueing\n" 3086"-U report/set user negotiation settings\n" 3087"-W bus_width set the bus width in bits (8, 16 or 32)\n" 3088"-v also print a Path Inquiry CCB for the controller\n" 3089"format arguments:\n" 3090"-q be quiet, don't print status messages\n" 3091"-w don't send immediate format command\n" 3092"-y don't ask any questions\n"); |
3093#endif /* MINIMALISTIC */ |
|
3072} 3073 3074int 3075main(int argc, char **argv) 3076{ 3077 int c; 3078 char *device = NULL; 3079 int unit = 0; --- 87 unchanged lines hidden (view full) --- 3167 */ 3168 if (((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_RESCAN) 3169 || ((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_RESET) 3170 || ((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_DEVTREE) 3171 || ((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_USAGE) 3172 || ((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_DEBUG)) 3173 devopen = 0; 3174 | 3094} 3095 3096int 3097main(int argc, char **argv) 3098{ 3099 int c; 3100 char *device = NULL; 3101 int unit = 0; --- 87 unchanged lines hidden (view full) --- 3189 */ 3190 if (((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_RESCAN) 3191 || ((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_RESET) 3192 || ((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_DEVTREE) 3193 || ((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_USAGE) 3194 || ((arglist & CAM_ARG_OPT_MASK) == CAM_ARG_DEBUG)) 3195 devopen = 0; 3196 |
3197#ifndef MINIMALISTIC |
|
3175 if ((devopen == 1) 3176 && (argc > 2 && argv[2][0] != '-')) { 3177 char name[30]; 3178 int rv; 3179 3180 /* 3181 * First catch people who try to do things like: 3182 * camcontrol tur /dev/rsd0.ctl --- 14 unchanged lines hidden (view full) --- 3197 if (cam_get_device(argv[2], name, sizeof name, &unit) 3198 == -1) 3199 errx(1, "%s", cam_errbuf); 3200 device = strdup(name); 3201 arglist |= CAM_ARG_DEVICE | CAM_ARG_UNIT; 3202 optstart++; 3203 } 3204 } | 3198 if ((devopen == 1) 3199 && (argc > 2 && argv[2][0] != '-')) { 3200 char name[30]; 3201 int rv; 3202 3203 /* 3204 * First catch people who try to do things like: 3205 * camcontrol tur /dev/rsd0.ctl --- 14 unchanged lines hidden (view full) --- 3220 if (cam_get_device(argv[2], name, sizeof name, &unit) 3221 == -1) 3222 errx(1, "%s", cam_errbuf); 3223 device = strdup(name); 3224 arglist |= CAM_ARG_DEVICE | CAM_ARG_UNIT; 3225 optstart++; 3226 } 3227 } |
3228#endif /* MINIMALISTIC */ |
|
3205 /* 3206 * Start getopt processing at argv[2/3], since we've already 3207 * accepted argv[1..2] as the command name, and as a possible 3208 * device name. 3209 */ 3210 optind = optstart; 3211 3212 /* --- 35 unchanged lines hidden (view full) --- 3248 case 'v': 3249 arglist |= CAM_ARG_VERBOSE; 3250 break; 3251 default: 3252 break; 3253 } 3254 } 3255 | 3229 /* 3230 * Start getopt processing at argv[2/3], since we've already 3231 * accepted argv[1..2] as the command name, and as a possible 3232 * device name. 3233 */ 3234 optind = optstart; 3235 3236 /* --- 35 unchanged lines hidden (view full) --- 3272 case 'v': 3273 arglist |= CAM_ARG_VERBOSE; 3274 break; 3275 default: 3276 break; 3277 } 3278 } 3279 |
3280#ifndef MINIMALISTIC |
|
3256 /* 3257 * For most commands we'll want to open the passthrough device 3258 * associated with the specified device. In the case of the rescan 3259 * commands, we don't use a passthrough device at all, just the 3260 * transport layer device. 3261 */ 3262 if (devopen == 1) { 3263 if (((arglist & (CAM_ARG_BUS|CAM_ARG_TARGET)) == 0) --- 4 unchanged lines hidden (view full) --- 3268 } 3269 3270 if ((cam_dev = ((arglist & (CAM_ARG_BUS | CAM_ARG_TARGET))? 3271 cam_open_btl(bus, target, lun, O_RDWR, NULL) : 3272 cam_open_spec_device(device,unit,O_RDWR,NULL))) 3273 == NULL) 3274 errx(1,"%s", cam_errbuf); 3275 } | 3281 /* 3282 * For most commands we'll want to open the passthrough device 3283 * associated with the specified device. In the case of the rescan 3284 * commands, we don't use a passthrough device at all, just the 3285 * transport layer device. 3286 */ 3287 if (devopen == 1) { 3288 if (((arglist & (CAM_ARG_BUS|CAM_ARG_TARGET)) == 0) --- 4 unchanged lines hidden (view full) --- 3293 } 3294 3295 if ((cam_dev = ((arglist & (CAM_ARG_BUS | CAM_ARG_TARGET))? 3296 cam_open_btl(bus, target, lun, O_RDWR, NULL) : 3297 cam_open_spec_device(device,unit,O_RDWR,NULL))) 3298 == NULL) 3299 errx(1,"%s", cam_errbuf); 3300 } |
3301#endif /* MINIMALISTIC */ |
|
3276 3277 /* 3278 * Reset optind to 2, and reset getopt, so these routines can parse 3279 * the arguments again. 3280 */ 3281 optind = optstart; 3282 optreset = 1; 3283 3284 switch(arglist & CAM_ARG_OPT_MASK) { | 3302 3303 /* 3304 * Reset optind to 2, and reset getopt, so these routines can parse 3305 * the arguments again. 3306 */ 3307 optind = optstart; 3308 optreset = 1; 3309 3310 switch(arglist & CAM_ARG_OPT_MASK) { |
3311#ifndef MINIMALISTIC |
|
3285 case CAM_ARG_DEVLIST: 3286 error = getdevlist(cam_dev); 3287 break; 3288 case CAM_ARG_DEVTREE: 3289 error = getdevtree(); 3290 break; 3291 case CAM_ARG_TUR: 3292 error = testunitready(cam_dev, retry_count, timeout, 0); 3293 break; 3294 case CAM_ARG_INQUIRY: 3295 error = scsidoinquiry(cam_dev, argc, argv, combinedopt, 3296 retry_count, timeout); 3297 break; 3298 case CAM_ARG_STARTSTOP: 3299 error = scsistart(cam_dev, arglist & CAM_ARG_START_UNIT, 3300 arglist & CAM_ARG_EJECT, retry_count, 3301 timeout); 3302 break; | 3312 case CAM_ARG_DEVLIST: 3313 error = getdevlist(cam_dev); 3314 break; 3315 case CAM_ARG_DEVTREE: 3316 error = getdevtree(); 3317 break; 3318 case CAM_ARG_TUR: 3319 error = testunitready(cam_dev, retry_count, timeout, 0); 3320 break; 3321 case CAM_ARG_INQUIRY: 3322 error = scsidoinquiry(cam_dev, argc, argv, combinedopt, 3323 retry_count, timeout); 3324 break; 3325 case CAM_ARG_STARTSTOP: 3326 error = scsistart(cam_dev, arglist & CAM_ARG_START_UNIT, 3327 arglist & CAM_ARG_EJECT, retry_count, 3328 timeout); 3329 break; |
3330#endif /* MINIMALISTIC */ |
|
3303 case CAM_ARG_RESCAN: 3304 error = dorescan_or_reset(argc, argv, 1); 3305 break; 3306 case CAM_ARG_RESET: 3307 error = dorescan_or_reset(argc, argv, 0); 3308 break; | 3331 case CAM_ARG_RESCAN: 3332 error = dorescan_or_reset(argc, argv, 1); 3333 break; 3334 case CAM_ARG_RESET: 3335 error = dorescan_or_reset(argc, argv, 0); 3336 break; |
3337#ifndef MINIMALISTIC |
|
3309 case CAM_ARG_READ_DEFECTS: 3310 error = readdefects(cam_dev, argc, argv, combinedopt, 3311 retry_count, timeout); 3312 break; 3313 case CAM_ARG_MODE_PAGE: 3314 modepage(cam_dev, argc, argv, combinedopt, 3315 retry_count, timeout); 3316 break; --- 10 unchanged lines hidden (view full) --- 3327 case CAM_ARG_RATE: 3328 error = ratecontrol(cam_dev, retry_count, timeout, 3329 argc, argv, combinedopt); 3330 break; 3331 case CAM_ARG_FORMAT: 3332 error = scsiformat(cam_dev, argc, argv, 3333 combinedopt, retry_count, timeout); 3334 break; | 3338 case CAM_ARG_READ_DEFECTS: 3339 error = readdefects(cam_dev, argc, argv, combinedopt, 3340 retry_count, timeout); 3341 break; 3342 case CAM_ARG_MODE_PAGE: 3343 modepage(cam_dev, argc, argv, combinedopt, 3344 retry_count, timeout); 3345 break; --- 10 unchanged lines hidden (view full) --- 3356 case CAM_ARG_RATE: 3357 error = ratecontrol(cam_dev, retry_count, timeout, 3358 argc, argv, combinedopt); 3359 break; 3360 case CAM_ARG_FORMAT: 3361 error = scsiformat(cam_dev, argc, argv, 3362 combinedopt, retry_count, timeout); 3363 break; |
3364#endif /* MINIMALISTIC */ |
|
3335 case CAM_ARG_USAGE: 3336 usage(1); 3337 break; 3338 default: 3339 usage(0); 3340 error = 1; 3341 break; 3342 } 3343 3344 if (cam_dev != NULL) 3345 cam_close_device(cam_dev); 3346 3347 exit(error); 3348} | 3365 case CAM_ARG_USAGE: 3366 usage(1); 3367 break; 3368 default: 3369 usage(0); 3370 error = 1; 3371 break; 3372 } 3373 3374 if (cam_dev != NULL) 3375 cam_close_device(cam_dev); 3376 3377 exit(error); 3378} |