summaryrefslogtreecommitdiffstats
path: root/sbin/camcontrol/camcontrol.c
diff options
context:
space:
mode:
authorkbyanc <kbyanc@FreeBSD.org>2000-08-08 06:24:17 +0000
committerkbyanc <kbyanc@FreeBSD.org>2000-08-08 06:24:17 +0000
commit8f0afc6b0aa752cb23dfcf91f2285bf6c825405d (patch)
tree034cb732a278c59e0304f2f93947626f19ea5385 /sbin/camcontrol/camcontrol.c
parent18a0d975369707cba8c9deeb3de4db05dafb9487 (diff)
downloadFreeBSD-src-8f0afc6b0aa752cb23dfcf91f2285bf6c825405d.zip
FreeBSD-src-8f0afc6b0aa752cb23dfcf91f2285bf6c825405d.tar.gz
This is an overhaul of the mode page handling in camcontrol as well as
related patches. These include: * Mode page editting can be scripted. This involves two things: first, if stdin is not a tty, changes are read from stdin rather than invoking $EDITOR. Second, and more importantly, not all modepage entries must be included in the change set. This means that camcontrol can now gracefully handle more intrusive editting from the $EDITOR, including removal or rearrangement of lines. It also means that you can do stuff like: # echo "WCE: 1" | camcontrol modepage da3 -m 8 -e # newfs /dev/da3 # echo "WCE: 0" | camcontrol modepage da3 -m 8 -e * Range-checking on user-supplied input values. modeedit.c now uses the field width specifiers to determine the maximum allowable value for a field. If the user enters a value larger than the maximum, it clips the value to the max and warns the user. This also involved patching cam_cmdparse.c to be more consistent with regards to the "count" parameter to arg_put (previously is was the length of strings and 1 for all integral types). The cam_cdbparse(3) man page was also updated to reflect the revised semantics. * In the process, I removed the 64 entry limit on mode pages (not that we were even close to hitting that limit). This was a nice side-effect of the other changes. * Technically, the new mode editting functionality allows editting of character array entries in mode pages (type 'c' or 'z'), however since buff_encode doesn't grok them it is currently useless. * Camcontrol gained two new options related to mode pages: -l and -b. The former lists all available mode pages for a given device. The latter forces mode page display in binary format (the default when no mode page definition was found in scsi_modes). * Added support for mode page names to scsi_modes. Allows names to be displayed alongside mode numbers in the mode page listing. Updated scsi_modes to use the new functionality. This also adds the semicolon into the scsi_modes syntax as an optional mode page definition terminator. This is needed to name pages without providing a page format definition. * Updated scsi_all.h to include a structure describing mode page headers. * Added $FreeBSD$ line to scsi_modes. Inspired by: dwhite Reviewed by: ken
Diffstat (limited to 'sbin/camcontrol/camcontrol.c')
-rw-r--r--sbin/camcontrol/camcontrol.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
index fcacca4..c7e96cd 100644
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -124,7 +124,7 @@ struct camcontrol_opts option_table[] = {
{"defectlist", CAM_ARG_READ_DEFECTS, readdefect_opts},
{"devlist", CAM_ARG_DEVTREE, NULL},
{"periphlist", CAM_ARG_DEVLIST, NULL},
- {"modepage", CAM_ARG_MODE_PAGE, "dem:P:"},
+ {"modepage", CAM_ARG_MODE_PAGE, "bdelm:P:"},
{"tags", CAM_ARG_TAG, "N:q"},
{"negotiate", CAM_ARG_RATE, negotiate_opts},
{"rate", CAM_ARG_RATE, negotiate_opts},
@@ -1554,15 +1554,22 @@ modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
int retry_count, int timeout)
{
int c, mode_page = -1, page_control = 0;
+ int binary = 0, list = 0;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
switch(c) {
+ case 'b':
+ binary = 1;
+ break;
case 'd':
arglist |= CAM_ARG_DBD;
break;
case 'e':
arglist |= CAM_ARG_MODE_EDIT;
break;
+ case 'l':
+ list = 1;
+ break;
case 'm':
mode_page = strtol(optarg, NULL, 0);
if (mode_page < 0)
@@ -1580,11 +1587,17 @@ modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
}
}
- if (mode_page == -1)
+ if (mode_page == -1 && list == 0)
errx(1, "you must specify a mode page!");
- mode_edit(device, mode_page, page_control, arglist & CAM_ARG_DBD,
- arglist & CAM_ARG_MODE_EDIT, retry_count, timeout);
+ if (list) {
+ mode_list(device, page_control, arglist & CAM_ARG_DBD,
+ retry_count, timeout);
+ } else {
+ mode_edit(device, mode_page, page_control,
+ arglist & CAM_ARG_DBD, arglist & CAM_ARG_MODE_EDIT, binary,
+ retry_count, timeout);
+ }
}
static int
@@ -2975,8 +2988,8 @@ usage(int verbose)
" camcontrol rescan <bus[:target:lun]>\n"
" camcontrol reset <bus[:target:lun]>\n"
" camcontrol defects [dev_id][generic args] <-f format> [-P][-G]\n"
-" camcontrol modepage [dev_id][generic args] <-m page> [-P pagectl]\n"
-" [-e][-d]\n"
+" camcontrol modepage [dev_id][generic args] <-m page | -l>\n"
+" [-P pagectl][-e | -b][-d]\n"
" camcontrol cmd [dev_id][generic args] <-c cmd [args]>\n"
" [-i len fmt|-o len fmt [args]]\n"
" camcontrol debug [-I][-T][-S][-c] <all|bus[:target[:lun]]|off>\n"
@@ -3022,6 +3035,7 @@ usage(int verbose)
"modepage arguments:\n"
"-m page specify the mode page to view or edit\n"
"-e edit the specified mode page\n"
+"-b force view to binary mode\n"
"-d disable block descriptors for mode sense\n"
"-P pgctl page control field 0-3\n"
"defects arguments:\n"
OpenPOWER on IntegriCloud