Douglas Gilbert | cad4899 | 2017-11-15 06:21:21 +0000 | [diff] [blame] | 1 | .TH SG_READ_ATTR "8" "November 2017" "sg3_utils\-1.43" SG3_UTILS |
Douglas Gilbert | 2f1a9f5 | 2016-02-08 04:53:45 +0000 | [diff] [blame] | 2 | .SH NAME |
| 3 | sg_read_attr \- send SCSI READ ATTRIBUTE command |
| 4 | .SH SYNOPSIS |
| 5 | .B sg_read_attr |
| 6 | [\fI\-\-cache\fR] [\fI\-\-enumerate\fR] [\fI\-\-ea=EA\fR] |
| 7 | [\fI\-\-filter=FL\fR] [\fI\-\-first=FAI\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR] |
| 8 | [\fI\-\-in=FN\fR] [\fI\-\-lvn=LVN\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-pn=PN\fR] |
| 9 | [\fI\-\-quiet\fR] [\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-sa=SA\fR] |
| 10 | [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR |
| 11 | .SH DESCRIPTION |
| 12 | .\" Add any additional description here |
| 13 | .PP |
| 14 | Sends a SCSI READ ATTRIBUTE command to \fIDEVICE\fR and outputs the data |
Douglas Gilbert | dc469cf | 2017-10-03 08:03:27 +0000 | [diff] [blame] | 15 | returned. This command was introduced in SPC\-3 revision 1 and thus is |
| 16 | applicable to all SCSI devices. In practice it is used mainly for tape |
| 17 | systems. This utility is based on the SPC\-5 draft standard, revision |
| 18 | 17 (spc5r17.pdf). |
Douglas Gilbert | 2f1a9f5 | 2016-02-08 04:53:45 +0000 | [diff] [blame] | 19 | .SH OPTIONS |
| 20 | Arguments to long options are mandatory for short options as well. |
| 21 | .TP |
| 22 | \fB\-c\fR, \fB\-\-cache\fR |
| 23 | sets the CACHE bit in the READ ATTRIBUTE cdb. This instructs the device |
| 24 | server to return cached attributes. By default that bit is cleared |
| 25 | which instructs the device server not to return cached attributes. |
| 26 | .TP |
| 27 | \fB\-e\fR, \fB\-\-enumerate\fR |
| 28 | enumerates all known attributes and service actions. Attributes include |
| 29 | an identifier, length, format and a name as defined by T10. If \fIDEVICE\fR |
| 30 | is given then it is ignored. |
| 31 | .TP |
| 32 | \fB\-E\fR, \fB\-\-ea\fR=\fIEA\fR |
| 33 | where \fIEA\fR is an element address which is placed in the READ ATTRIBUTE |
| 34 | cdb. This field is only found in SMC\-2 and SMC\-3 drafts for medium |
| 35 | changers usually associated with tape libraries. By default this field |
| 36 | is set to zero. |
| 37 | .TP |
| 38 | \fB\-f\fR, \fB\-\-filter\fR=\fIFL\fR |
| 39 | where \fIFL\fR is an attribute identifier in the range 0 to 65535 or \-1. |
Douglas Gilbert | cad4899 | 2017-11-15 06:21:21 +0000 | [diff] [blame] | 40 | Attribute identifiers are typically given in hexadecimal in which case the |
| 41 | hex number should be prefixed by "0x" or has a trailing "h". "\-1" is |
Douglas Gilbert | 2f1a9f5 | 2016-02-08 04:53:45 +0000 | [diff] [blame] | 42 | the default value and means 'match all'; for all other values of \fIFL\fR |
| 43 | on the matching attribute is output. |
| 44 | .TP |
| 45 | \fB\-F\fR, \fB\-\-first\fR=\fIFAI\fR |
| 46 | where \fIFAI\fR is the "first attribute identifier" field in the cdb. It |
| 47 | seems as though the intent of this field is that only attributes whose |
| 48 | identifiers are equal to or greater than \fIFAI\fR are returned. The default |
| 49 | value of \fIFAI\fR is zero. Attributes are returned in ascending identifier |
| 50 | order. |
| 51 | .TP |
| 52 | \fB\-h\fR, \fB\-\-help\fR |
| 53 | output the usage message then exit. |
| 54 | .TP |
| 55 | \fB\-H\fR, \fB\-\-hex\fR |
| 56 | output the response in hexadecimal to stdout. When used once the whole |
| 57 | response is output in ASCII hexadecimal with a leading address (starting at |
| 58 | 0) on each line. When used twice each attribute descriptor in the response |
| 59 | is output separately in hexadecimal. When used thrice the whole response is |
| 60 | output in hexadecimal with no leading address (on each line). |
| 61 | .br |
| 62 | Output generated by '\-HHH' (or \fI\-\-hex\fR used three times) can be |
| 63 | redirected to a file. That file will be in suitable format for \fI\-\-in=FN\fR |
| 64 | to use in a later invocation. |
| 65 | .TP |
| 66 | \fB\-i\fR, \fB\-\-in\fR=\fIFN\fR |
| 67 | \fIFN\fR is treated as a file name (or '\-' for stdin) which contains ASCII |
| 68 | hexadecimal or binary representing the response to a READ ATTRIBUTE command |
| 69 | with service action 0x0 (i.e (fetch) attribute values). When this option is |
| 70 | given then \fIDEVICE\fR (if also given) is ignored. |
| 71 | .br |
| 72 | By default \fIFN\fR is assumed to contain ASCII hexadecimal arranged as |
| 73 | bytes which a space, tab or comma delimited. All characters from (and |
| 74 | including) "#" to the end of line are ignored. If the \fI\-\-raw\fR option |
| 75 | is also given then \fIFN\fR is assumed to contain binary data. When the |
| 76 | \fI\-\-raw\fR option is given then after processing the input the |
| 77 | internal raw variable is reset to 0 so it has no effect on the output. |
| 78 | .br |
| 79 | Since the READ ATTRIBUTE response does not contain the service action number |
| 80 | that it is a response to, then the \fI\-\-sa=SA\fR should be given (if not |
| 81 | service action 0 (attribute values) is assumed. |
| 82 | .TP |
| 83 | \fB\-l\fR, \fB\-\-lvn\fR=\fILVN\fR |
| 84 | where \fILVN\fR is placed in the "logical volume number" field of the cdb. |
| 85 | The default value is zero which is required to be the logical volume number |
| 86 | if the device only has one volume. |
| 87 | .TP |
| 88 | \fB\-m\fR, \fB\-\-maxlen\fR=\fILEN\fR |
| 89 | where \fILEN\fR is the (maximum) response length in bytes. It is placed in |
| 90 | the cdb's "allocation length" field. If not given (or \fILEN\fR is zero) |
| 91 | then 8192 is used. The maximum allowed value of \fILEN\fR is 1048576. |
| 92 | .TP |
| 93 | \fB\-p\fR, \fB\-\-pn\fR=\fIPN\fR |
| 94 | where \fIPN\fR is placed in the "partition number" field of the cdb. If |
| 95 | the \fIDEVICE\fR only has one partition then its partition number must be |
| 96 | zero. The default value of \fIPN\fR is zero. |
| 97 | .TP |
| 98 | \fB\-q\fR, \fB\-\-quiet\fR |
| 99 | this option reduces the amount of information output. For example when |
| 100 | used once (\fISA\fR=0), it suppresses the header line announcing the |
| 101 | output of attributes; when used twice it suppresses the name of each |
| 102 | attribute, leaving only the associated attribute values (or strings). |
| 103 | .TP |
| 104 | \fB\-r\fR, \fB\-\-raw\fR |
| 105 | output the SCSI response (i.e. the data\-out buffer) in binary (to stdout). |
| 106 | .TP |
| 107 | \fB\-R\fR, \fB\-\-readonly\fR |
| 108 | open the \fIDEVICE\fR read\-only (e.g. in Unix with the O_RDONLY flag). |
| 109 | The default is to open it read\-write. |
| 110 | .TP |
| 111 | \fB\-s\fR, \fB\-\-sa\fR=\fISA\fR |
| 112 | where \fISA\fR is placed on the "service action" field of the cdb. Values |
| 113 | of 0 to 63 are accepted with a default of 0. spc5r08.pdf defines five |
| 114 | service actions: 0 for attributes values ; 1 for an attribute list (names, |
| 115 | not values), 2 for the logical volume list; 3 for the partition list; 4 |
| 116 | is restricted for SMC\-3; and 5 for the supported attribute list. |
| 117 | .br |
| 118 | Alternatively an acronym can be given for \fISA\fR. The acronym should be |
| 119 | one of "av", "al", "lvl", "pn", "smc" or "sa" for service actions 0 to 5 |
| 120 | respectively. The acronyms can also be given in upper case. |
| 121 | .TP |
| 122 | \fB\-v\fR, \fB\-\-verbose\fR |
| 123 | increase the level of verbosity, (i.e. debug output). |
| 124 | .TP |
| 125 | \fB\-V\fR, \fB\-\-version\fR |
| 126 | print the version string and then exit. |
| 127 | .SH NOTES |
| 128 | Only tape systems seem to implement the SCSI READ ATTRIBUTE command. The vast |
| 129 | majority of its definition is in the SPC standard so other device types could |
| 130 | use it. |
| 131 | .PP |
| 132 | Much of the information provided by READ ATTRIBUTE can also be found in |
| 133 | pages returned by LOG SENSE (see the sg_logs utility) and in the VPD |
| 134 | pages returned by the INQUIRY command. |
| 135 | .SH EXAMPLES |
| 136 | To list the attributes of a tape drive whose xxxx is /dev/sg1 the following |
| 137 | could be used: |
| 138 | .PP |
| 139 | # sg_read_attr \-s al /dev/sg1 |
| 140 | .br |
| 141 | Attribute list: |
| 142 | .br |
| 143 | Remaining capacity in partition [MiB] |
| 144 | .br |
| 145 | Maximum capacity in partition [MiB] |
| 146 | .br |
| 147 | TapeAlert flags |
| 148 | .br |
| 149 | Load count |
| 150 | .br |
| 151 | MAM space remaining [B] |
| 152 | .br |
| 153 | Assigning organization |
| 154 | .br |
| 155 | Format density code |
| 156 | .br |
| 157 | ... |
| 158 | .PP |
| 159 | To check the number of partitions: |
| 160 | .PP |
| 161 | # sg_read_attr \-s pl /dev/sg1 |
| 162 | .br |
| 163 | Partition number list: |
| 164 | .br |
| 165 | First partition number: 0 |
| 166 | .br |
| 167 | Number of partitions available: 2 |
| 168 | .PP |
| 169 | And to see the attribute values (which is the default service action): |
| 170 | .PP |
| 171 | # sg_read_attr /dev/sg1 |
| 172 | .br |
| 173 | Attribute values: |
| 174 | .br |
| 175 | Remaining capacity in partition [MiB]: 1386103 |
| 176 | .br |
| 177 | Maximum capacity in partition [MiB]: 1386103 |
| 178 | .br |
| 179 | TapeAlert flags: 0 |
| 180 | .br |
| 181 | .... |
| 182 | .PP |
| 183 | To redirect the attribute values response to a file for later decoding: |
| 184 | .PP |
| 185 | # sg_read_attr \-HHH /dev/sg1 > av.hex |
| 186 | .PP |
| 187 | And later the response held in the av.hex file could be decoded with: |
| 188 | .PP |
| 189 | # sg_read_attr \-s av \-\-in=av.hex |
| 190 | .br |
| 191 | Attribute values: |
| 192 | .br |
| 193 | Remaining capacity in partition [MiB]: 1386103 |
| 194 | .br |
| 195 | Maximum capacity in partition [MiB]: 1386103 |
| 196 | .br |
| 197 | TapeAlert flags: 0 |
| 198 | .br |
| 199 | .... |
| 200 | .PP |
| 201 | .SH EXIT STATUS |
| 202 | The exit status of sg_read_attr is 0 when it is successful. Otherwise see |
| 203 | the sg3_utils(8) man page. |
| 204 | .SH AUTHORS |
| 205 | Written by Douglas Gilbert. |
| 206 | .SH "REPORTING BUGS" |
| 207 | Report bugs to <dgilbert at interlog dot com>. |
| 208 | .SH COPYRIGHT |
Douglas Gilbert | dc469cf | 2017-10-03 08:03:27 +0000 | [diff] [blame] | 209 | Copyright \(co 2016\-2017 Douglas Gilbert |
Douglas Gilbert | 2f1a9f5 | 2016-02-08 04:53:45 +0000 | [diff] [blame] | 210 | .br |
| 211 | This software is distributed under a FreeBSD license. There is NO |
| 212 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 213 | .SH "SEE ALSO" |
| 214 | .B sg_vpd,sg_logs(sg3_utils) |