From owner-p4-projects@FreeBSD.ORG Fri Sep 4 18:08:38 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C19B21065672; Fri, 4 Sep 2009 18:08:38 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DB08106566C for ; Fri, 4 Sep 2009 18:08:38 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 5C1708FC1A for ; Fri, 4 Sep 2009 18:08:38 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n84I8cI9010754 for ; Fri, 4 Sep 2009 18:08:38 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n84I8bbK010752 for perforce@freebsd.org; Fri, 4 Sep 2009 18:08:37 GMT (envelope-from mav@freebsd.org) Date: Fri, 4 Sep 2009 18:08:37 GMT Message-Id: <200909041808.n84I8bbK010752@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Cc: Subject: PERFORCE change 168160 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2009 18:08:39 -0000 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" " \n" " camcontrol tags [dev_id][generic args] [-N tags] [-q] [-v]\n"