Date: Fri, 4 Sep 2009 18:08:37 GMT From: Alexander Motin <mav@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 168160 for review Message-ID: <200909041808.n84I8bbK010752@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=168160 Change 168160 by mav@mav_mavbook on 2009/09/04 18:08:15 Add format to -r argument and document changes. Affected files ... .. //depot/projects/scottl-camlock/src/sbin/camcontrol/camcontrol.8#7 edit .. //depot/projects/scottl-camlock/src/sbin/camcontrol/camcontrol.c#20 edit Differences ... ==== //depot/projects/scottl-camlock/src/sbin/camcontrol/camcontrol.8#7 (text+ko) ==== @@ -27,7 +27,7 @@ .\" .\" $FreeBSD: src/sbin/camcontrol/camcontrol.8,v 1.45 2009/07/10 08:18:08 scottl Exp $ .\" -.Dd June 29, 2009 +.Dd September 4, 2009 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -120,10 +120,12 @@ .Ic cmd .Op device id .Op generic args +.Aq Fl a Ar cmd Op args .Aq Fl c Ar cmd Op args .Op Fl i Ar len Ar fmt .Bk -words .Op Fl o Ar len Ar fmt Op args +.Op Fl r Ar fmt .Ek .Nm .Ic debug @@ -486,12 +488,14 @@ .El .El .It Ic cmd -Allows the user to send an arbitrary SCSI CDB to any device. +Allows the user to send an arbitrary ATA or SCSI CDB to any device. The .Ic cmd function requires the .Fl c -argument to specify the CDB. +argument to specify SCSI CDB or the +.Fl a +argument to specify ATA Command Block registers values. Other arguments are optional, depending on the command type. The command and data specification syntax is documented @@ -503,9 +507,13 @@ or .Fl o . .Bl -tag -width 17n +.It Fl a Ar cmd Op args +This specifies the content of 12 ATA Command Block registers (command, +features, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp. +lba_high_exp, features_exp, sector_count, sector_count_exp). .It Fl c Ar cmd Op args This specifies the SCSI CDB. -CDBs may be 6, 10, 12 or 16 bytes. +SCSI CDBs may be 6, 10, 12 or 16 bytes. .It Fl i Ar len Ar fmt This specifies the amount of data to read, and how it should be displayed. If the format is @@ -519,6 +527,13 @@ .Sq - , .Ar len bytes of data will be read from standard input and written to the device. +.It Fl r Ar fmt +This specifies that 11 result ATA Command Block registers should be displayed +(status, error, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp, +lba_high_exp, sector_count, sector_count_exp), and how. +If the format is +.Sq - , +11 result registers will be written to standard output in hex. .El .It Ic debug Turn on CAM debugging printfs in the kernel. ==== //depot/projects/scottl-camlock/src/sbin/camcontrol/camcontrol.c#20 (text+ko) ==== @@ -2084,9 +2084,9 @@ int cdb_len = 0; int atacmd_len = 0; int need_res = 0; - char *datastr = NULL, *tstr; + char *datastr = NULL, *tstr, *resstr = NULL; int error = 0; - int fd_data = 0; + int fd_data = 0, fd_res = 0; int retval; ccb = cam_getccb(device); @@ -2221,6 +2221,13 @@ break; case 'r': need_res = 1; + hook.argc = argc - optind; + hook.argv = argv + optind; + hook.got = 0; + resstr = cget(&hook, NULL); + if ((resstr != NULL) && (resstr[0] == '-')) + fd_res = 1; + optind += hook.got; break; default: break; @@ -2341,20 +2348,26 @@ } if (atacmd_len && need_res) { - fprintf(stdout, - "%02X %02X %02X %02X %02X %02X %02X %02X %02X 00 %02X %02X\n", - ccb->ataio.res.status, - ccb->ataio.res.error, - ccb->ataio.res.lba_low, - ccb->ataio.res.lba_mid, - ccb->ataio.res.lba_high, - ccb->ataio.res.device, - ccb->ataio.res.lba_low_exp, - ccb->ataio.res.lba_mid_exp, - ccb->ataio.res.lba_high_exp, - ccb->ataio.res.sector_count, - ccb->ataio.res.sector_count_exp); - fflush(stdout); + if (fd_res == 0) { + buff_decode_visit(&ccb->ataio.res.status, 11, resstr, + arg_put, NULL); + fprintf(stdout, "\n"); + } else { + fprintf(stdout, + "%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", + ccb->ataio.res.status, + ccb->ataio.res.error, + ccb->ataio.res.lba_low, + ccb->ataio.res.lba_mid, + ccb->ataio.res.lba_high, + ccb->ataio.res.device, + ccb->ataio.res.lba_low_exp, + ccb->ataio.res.lba_mid_exp, + ccb->ataio.res.lba_high_exp, + ccb->ataio.res.sector_count, + ccb->ataio.res.sector_count_exp); + fflush(stdout); + } } if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) @@ -4091,7 +4104,7 @@ " [-P pagectl][-e | -b][-d]\n" " camcontrol cmd [dev_id][generic args]\n" " <-a cmd [args] | -c cmd [args]>\n" -" [-i len fmt|-o len fmt [args]] [-r]\n" +" [-i len fmt|-o len fmt [args]] [-r fmt]\n" " camcontrol debug [-I][-P][-T][-S][-X][-c]\n" " <all|bus[:target[:lun]]|off>\n" " camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909041808.n84I8bbK010752>