]>
Commit | Line | Data |
---|---|---|
e5b5728c PB |
1 | /* |
2 | * SCSI helpers | |
3 | * | |
4 | * Copyright 2017 Red Hat, Inc. | |
5 | * | |
6 | * Authors: | |
7 | * Fam Zheng <famz@redhat.com> | |
8 | * Paolo Bonzini <pbonzini@redhat.com> | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify it | |
11 | * under the terms of the GNU General Public License as published by the Free | |
12 | * Software Foundation; either version 2 of the License, or (at your option) | |
13 | * any later version. | |
14 | */ | |
15 | ||
16 | #include "qemu/osdep.h" | |
17 | #include "block/scsi.h" | |
18 | #include "scsi/utils.h" | |
19 | #include "qemu/bswap.h" | |
20 | ||
21 | uint32_t scsi_data_cdb_xfer(uint8_t *buf) | |
22 | { | |
23 | if ((buf[0] >> 5) == 0 && buf[4] == 0) { | |
24 | return 256; | |
25 | } else { | |
26 | return scsi_cdb_xfer(buf); | |
27 | } | |
28 | } | |
29 | ||
30 | uint32_t scsi_cdb_xfer(uint8_t *buf) | |
31 | { | |
32 | switch (buf[0] >> 5) { | |
33 | case 0: | |
34 | return buf[4]; | |
35 | break; | |
36 | case 1: | |
37 | case 2: | |
38 | return lduw_be_p(&buf[7]); | |
39 | break; | |
40 | case 4: | |
41 | return ldl_be_p(&buf[10]) & 0xffffffffULL; | |
42 | break; | |
43 | case 5: | |
44 | return ldl_be_p(&buf[6]) & 0xffffffffULL; | |
45 | break; | |
46 | default: | |
47 | return -1; | |
48 | } | |
49 | } | |
50 | ||
51 | uint64_t scsi_cmd_lba(SCSICommand *cmd) | |
52 | { | |
53 | uint8_t *buf = cmd->buf; | |
54 | uint64_t lba; | |
55 | ||
56 | switch (buf[0] >> 5) { | |
57 | case 0: | |
58 | lba = ldl_be_p(&buf[0]) & 0x1fffff; | |
59 | break; | |
60 | case 1: | |
61 | case 2: | |
62 | case 5: | |
63 | lba = ldl_be_p(&buf[2]) & 0xffffffffULL; | |
64 | break; | |
65 | case 4: | |
66 | lba = ldq_be_p(&buf[2]); | |
67 | break; | |
68 | default: | |
69 | lba = -1; | |
70 | ||
71 | } | |
72 | return lba; | |
73 | } | |
74 | ||
75 | int scsi_cdb_length(uint8_t *buf) | |
76 | { | |
77 | int cdb_len; | |
78 | ||
79 | switch (buf[0] >> 5) { | |
80 | case 0: | |
81 | cdb_len = 6; | |
82 | break; | |
83 | case 1: | |
84 | case 2: | |
85 | cdb_len = 10; | |
86 | break; | |
87 | case 4: | |
88 | cdb_len = 16; | |
89 | break; | |
90 | case 5: | |
91 | cdb_len = 12; | |
92 | break; | |
93 | default: | |
94 | cdb_len = -1; | |
95 | } | |
96 | return cdb_len; | |
97 | } | |
98 | ||
99 | /* | |
100 | * Predefined sense codes | |
101 | */ | |
102 | ||
103 | /* No sense data available */ | |
104 | const struct SCSISense sense_code_NO_SENSE = { | |
105 | .key = NO_SENSE , .asc = 0x00 , .ascq = 0x00 | |
106 | }; | |
107 | ||
108 | /* LUN not ready, Manual intervention required */ | |
109 | const struct SCSISense sense_code_LUN_NOT_READY = { | |
110 | .key = NOT_READY, .asc = 0x04, .ascq = 0x03 | |
111 | }; | |
112 | ||
113 | /* LUN not ready, Medium not present */ | |
114 | const struct SCSISense sense_code_NO_MEDIUM = { | |
115 | .key = NOT_READY, .asc = 0x3a, .ascq = 0x00 | |
116 | }; | |
117 | ||
118 | /* LUN not ready, medium removal prevented */ | |
119 | const struct SCSISense sense_code_NOT_READY_REMOVAL_PREVENTED = { | |
120 | .key = NOT_READY, .asc = 0x53, .ascq = 0x02 | |
121 | }; | |
122 | ||
123 | /* Hardware error, internal target failure */ | |
124 | const struct SCSISense sense_code_TARGET_FAILURE = { | |
125 | .key = HARDWARE_ERROR, .asc = 0x44, .ascq = 0x00 | |
126 | }; | |
127 | ||
128 | /* Illegal request, invalid command operation code */ | |
129 | const struct SCSISense sense_code_INVALID_OPCODE = { | |
130 | .key = ILLEGAL_REQUEST, .asc = 0x20, .ascq = 0x00 | |
131 | }; | |
132 | ||
133 | /* Illegal request, LBA out of range */ | |
134 | const struct SCSISense sense_code_LBA_OUT_OF_RANGE = { | |
135 | .key = ILLEGAL_REQUEST, .asc = 0x21, .ascq = 0x00 | |
136 | }; | |
137 | ||
138 | /* Illegal request, Invalid field in CDB */ | |
139 | const struct SCSISense sense_code_INVALID_FIELD = { | |
140 | .key = ILLEGAL_REQUEST, .asc = 0x24, .ascq = 0x00 | |
141 | }; | |
142 | ||
143 | /* Illegal request, Invalid field in parameter list */ | |
144 | const struct SCSISense sense_code_INVALID_PARAM = { | |
145 | .key = ILLEGAL_REQUEST, .asc = 0x26, .ascq = 0x00 | |
146 | }; | |
147 | ||
148 | /* Illegal request, Parameter list length error */ | |
149 | const struct SCSISense sense_code_INVALID_PARAM_LEN = { | |
150 | .key = ILLEGAL_REQUEST, .asc = 0x1a, .ascq = 0x00 | |
151 | }; | |
152 | ||
153 | /* Illegal request, LUN not supported */ | |
154 | const struct SCSISense sense_code_LUN_NOT_SUPPORTED = { | |
155 | .key = ILLEGAL_REQUEST, .asc = 0x25, .ascq = 0x00 | |
156 | }; | |
157 | ||
158 | /* Illegal request, Saving parameters not supported */ | |
159 | const struct SCSISense sense_code_SAVING_PARAMS_NOT_SUPPORTED = { | |
160 | .key = ILLEGAL_REQUEST, .asc = 0x39, .ascq = 0x00 | |
161 | }; | |
162 | ||
163 | /* Illegal request, Incompatible medium installed */ | |
164 | const struct SCSISense sense_code_INCOMPATIBLE_FORMAT = { | |
165 | .key = ILLEGAL_REQUEST, .asc = 0x30, .ascq = 0x00 | |
166 | }; | |
167 | ||
168 | /* Illegal request, medium removal prevented */ | |
169 | const struct SCSISense sense_code_ILLEGAL_REQ_REMOVAL_PREVENTED = { | |
170 | .key = ILLEGAL_REQUEST, .asc = 0x53, .ascq = 0x02 | |
171 | }; | |
172 | ||
173 | /* Illegal request, Invalid Transfer Tag */ | |
174 | const struct SCSISense sense_code_INVALID_TAG = { | |
175 | .key = ILLEGAL_REQUEST, .asc = 0x4b, .ascq = 0x01 | |
176 | }; | |
177 | ||
178 | /* Command aborted, I/O process terminated */ | |
179 | const struct SCSISense sense_code_IO_ERROR = { | |
180 | .key = ABORTED_COMMAND, .asc = 0x00, .ascq = 0x06 | |
181 | }; | |
182 | ||
183 | /* Command aborted, I_T Nexus loss occurred */ | |
184 | const struct SCSISense sense_code_I_T_NEXUS_LOSS = { | |
185 | .key = ABORTED_COMMAND, .asc = 0x29, .ascq = 0x07 | |
186 | }; | |
187 | ||
188 | /* Command aborted, Logical Unit failure */ | |
189 | const struct SCSISense sense_code_LUN_FAILURE = { | |
190 | .key = ABORTED_COMMAND, .asc = 0x3e, .ascq = 0x01 | |
191 | }; | |
192 | ||
193 | /* Command aborted, Overlapped Commands Attempted */ | |
194 | const struct SCSISense sense_code_OVERLAPPED_COMMANDS = { | |
195 | .key = ABORTED_COMMAND, .asc = 0x4e, .ascq = 0x00 | |
196 | }; | |
197 | ||
198 | /* Unit attention, Capacity data has changed */ | |
199 | const struct SCSISense sense_code_CAPACITY_CHANGED = { | |
200 | .key = UNIT_ATTENTION, .asc = 0x2a, .ascq = 0x09 | |
201 | }; | |
202 | ||
203 | /* Unit attention, Power on, reset or bus device reset occurred */ | |
204 | const struct SCSISense sense_code_RESET = { | |
205 | .key = UNIT_ATTENTION, .asc = 0x29, .ascq = 0x00 | |
206 | }; | |
207 | ||
208 | /* Unit attention, No medium */ | |
209 | const struct SCSISense sense_code_UNIT_ATTENTION_NO_MEDIUM = { | |
210 | .key = UNIT_ATTENTION, .asc = 0x3a, .ascq = 0x00 | |
211 | }; | |
212 | ||
213 | /* Unit attention, Medium may have changed */ | |
214 | const struct SCSISense sense_code_MEDIUM_CHANGED = { | |
215 | .key = UNIT_ATTENTION, .asc = 0x28, .ascq = 0x00 | |
216 | }; | |
217 | ||
218 | /* Unit attention, Reported LUNs data has changed */ | |
219 | const struct SCSISense sense_code_REPORTED_LUNS_CHANGED = { | |
220 | .key = UNIT_ATTENTION, .asc = 0x3f, .ascq = 0x0e | |
221 | }; | |
222 | ||
223 | /* Unit attention, Device internal reset */ | |
224 | const struct SCSISense sense_code_DEVICE_INTERNAL_RESET = { | |
225 | .key = UNIT_ATTENTION, .asc = 0x29, .ascq = 0x04 | |
226 | }; | |
227 | ||
228 | /* Data Protection, Write Protected */ | |
229 | const struct SCSISense sense_code_WRITE_PROTECTED = { | |
230 | .key = DATA_PROTECT, .asc = 0x27, .ascq = 0x00 | |
231 | }; | |
232 | ||
233 | /* Data Protection, Space Allocation Failed Write Protect */ | |
234 | const struct SCSISense sense_code_SPACE_ALLOC_FAILED = { | |
235 | .key = DATA_PROTECT, .asc = 0x27, .ascq = 0x07 | |
236 | }; | |
237 | ||
238 | /* | |
239 | * scsi_convert_sense | |
240 | * | |
241 | * Convert between fixed and descriptor sense buffers | |
242 | */ | |
243 | int scsi_convert_sense(uint8_t *in_buf, int in_len, | |
244 | uint8_t *buf, int len, bool fixed) | |
245 | { | |
246 | bool fixed_in; | |
247 | SCSISense sense; | |
248 | if (!fixed && len < 8) { | |
249 | return 0; | |
250 | } | |
251 | ||
252 | if (in_len == 0) { | |
253 | sense.key = NO_SENSE; | |
254 | sense.asc = 0; | |
255 | sense.ascq = 0; | |
256 | } else { | |
257 | fixed_in = (in_buf[0] & 2) == 0; | |
258 | ||
259 | if (fixed == fixed_in) { | |
260 | memcpy(buf, in_buf, MIN(len, in_len)); | |
261 | return MIN(len, in_len); | |
262 | } | |
263 | ||
264 | if (fixed_in) { | |
265 | sense.key = in_buf[2]; | |
266 | sense.asc = in_buf[12]; | |
267 | sense.ascq = in_buf[13]; | |
268 | } else { | |
269 | sense.key = in_buf[1]; | |
270 | sense.asc = in_buf[2]; | |
271 | sense.ascq = in_buf[3]; | |
272 | } | |
273 | } | |
274 | ||
275 | memset(buf, 0, len); | |
276 | if (fixed) { | |
277 | /* Return fixed format sense buffer */ | |
278 | buf[0] = 0x70; | |
279 | buf[2] = sense.key; | |
280 | buf[7] = 10; | |
281 | buf[12] = sense.asc; | |
282 | buf[13] = sense.ascq; | |
283 | return MIN(len, SCSI_SENSE_LEN); | |
284 | } else { | |
285 | /* Return descriptor format sense buffer */ | |
286 | buf[0] = 0x72; | |
287 | buf[1] = sense.key; | |
288 | buf[2] = sense.asc; | |
289 | buf[3] = sense.ascq; | |
290 | return 8; | |
291 | } | |
292 | } | |
293 | ||
294 | int scsi_sense_to_errno(int key, int asc, int ascq) | |
295 | { | |
296 | switch (key) { | |
297 | case 0x00: /* NO SENSE */ | |
298 | case 0x01: /* RECOVERED ERROR */ | |
299 | case 0x06: /* UNIT ATTENTION */ | |
300 | /* These sense keys are not errors */ | |
301 | return 0; | |
302 | case 0x0b: /* COMMAND ABORTED */ | |
303 | return ECANCELED; | |
304 | case 0x02: /* NOT READY */ | |
305 | case 0x05: /* ILLEGAL REQUEST */ | |
306 | case 0x07: /* DATA PROTECTION */ | |
307 | /* Parse ASCQ */ | |
308 | break; | |
309 | default: | |
310 | return EIO; | |
311 | } | |
312 | switch ((asc << 8) | ascq) { | |
313 | case 0x1a00: /* PARAMETER LIST LENGTH ERROR */ | |
314 | case 0x2000: /* INVALID OPERATION CODE */ | |
315 | case 0x2400: /* INVALID FIELD IN CDB */ | |
316 | case 0x2600: /* INVALID FIELD IN PARAMETER LIST */ | |
317 | return EINVAL; | |
318 | case 0x2100: /* LBA OUT OF RANGE */ | |
319 | case 0x2707: /* SPACE ALLOC FAILED */ | |
320 | return ENOSPC; | |
321 | case 0x2500: /* LOGICAL UNIT NOT SUPPORTED */ | |
322 | return ENOTSUP; | |
323 | case 0x3a00: /* MEDIUM NOT PRESENT */ | |
324 | case 0x3a01: /* MEDIUM NOT PRESENT TRAY CLOSED */ | |
325 | case 0x3a02: /* MEDIUM NOT PRESENT TRAY OPEN */ | |
326 | return ENOMEDIUM; | |
327 | case 0x2700: /* WRITE PROTECTED */ | |
328 | return EACCES; | |
329 | case 0x0401: /* NOT READY, IN PROGRESS OF BECOMING READY */ | |
330 | return EAGAIN; | |
331 | case 0x0402: /* NOT READY, INITIALIZING COMMAND REQUIRED */ | |
332 | return ENOTCONN; | |
333 | default: | |
334 | return EIO; | |
335 | } | |
336 | } | |
337 | ||
338 | int scsi_sense_buf_to_errno(const uint8_t *sense, size_t sense_size) | |
339 | { | |
340 | int key, asc, ascq; | |
341 | if (sense_size < 1) { | |
342 | return EIO; | |
343 | } | |
344 | switch (sense[0]) { | |
345 | case 0x70: /* Fixed format sense data. */ | |
346 | if (sense_size < 14) { | |
347 | return EIO; | |
348 | } | |
349 | key = sense[2] & 0xF; | |
350 | asc = sense[12]; | |
351 | ascq = sense[13]; | |
352 | break; | |
353 | case 0x72: /* Descriptor format sense data. */ | |
354 | if (sense_size < 4) { | |
355 | return EIO; | |
356 | } | |
357 | key = sense[1] & 0xF; | |
358 | asc = sense[2]; | |
359 | ascq = sense[3]; | |
360 | break; | |
361 | default: | |
362 | return EIO; | |
363 | break; | |
364 | } | |
365 | return scsi_sense_to_errno(key, asc, ascq); | |
366 | } | |
367 | ||
368 | const char *scsi_command_name(uint8_t cmd) | |
369 | { | |
370 | static const char *names[] = { | |
371 | [ TEST_UNIT_READY ] = "TEST_UNIT_READY", | |
372 | [ REWIND ] = "REWIND", | |
373 | [ REQUEST_SENSE ] = "REQUEST_SENSE", | |
374 | [ FORMAT_UNIT ] = "FORMAT_UNIT", | |
375 | [ READ_BLOCK_LIMITS ] = "READ_BLOCK_LIMITS", | |
376 | [ REASSIGN_BLOCKS ] = "REASSIGN_BLOCKS/INITIALIZE ELEMENT STATUS", | |
377 | /* LOAD_UNLOAD and INITIALIZE_ELEMENT_STATUS use the same operation code */ | |
378 | [ READ_6 ] = "READ_6", | |
379 | [ WRITE_6 ] = "WRITE_6", | |
380 | [ SET_CAPACITY ] = "SET_CAPACITY", | |
381 | [ READ_REVERSE ] = "READ_REVERSE", | |
382 | [ WRITE_FILEMARKS ] = "WRITE_FILEMARKS", | |
383 | [ SPACE ] = "SPACE", | |
384 | [ INQUIRY ] = "INQUIRY", | |
385 | [ RECOVER_BUFFERED_DATA ] = "RECOVER_BUFFERED_DATA", | |
386 | [ MAINTENANCE_IN ] = "MAINTENANCE_IN", | |
387 | [ MAINTENANCE_OUT ] = "MAINTENANCE_OUT", | |
388 | [ MODE_SELECT ] = "MODE_SELECT", | |
389 | [ RESERVE ] = "RESERVE", | |
390 | [ RELEASE ] = "RELEASE", | |
391 | [ COPY ] = "COPY", | |
392 | [ ERASE ] = "ERASE", | |
393 | [ MODE_SENSE ] = "MODE_SENSE", | |
394 | [ START_STOP ] = "START_STOP/LOAD_UNLOAD", | |
395 | /* LOAD_UNLOAD and START_STOP use the same operation code */ | |
396 | [ RECEIVE_DIAGNOSTIC ] = "RECEIVE_DIAGNOSTIC", | |
397 | [ SEND_DIAGNOSTIC ] = "SEND_DIAGNOSTIC", | |
398 | [ ALLOW_MEDIUM_REMOVAL ] = "ALLOW_MEDIUM_REMOVAL", | |
399 | [ READ_CAPACITY_10 ] = "READ_CAPACITY_10", | |
400 | [ READ_10 ] = "READ_10", | |
401 | [ WRITE_10 ] = "WRITE_10", | |
402 | [ SEEK_10 ] = "SEEK_10/POSITION_TO_ELEMENT", | |
403 | /* SEEK_10 and POSITION_TO_ELEMENT use the same operation code */ | |
404 | [ WRITE_VERIFY_10 ] = "WRITE_VERIFY_10", | |
405 | [ VERIFY_10 ] = "VERIFY_10", | |
406 | [ SEARCH_HIGH ] = "SEARCH_HIGH", | |
407 | [ SEARCH_EQUAL ] = "SEARCH_EQUAL", | |
408 | [ SEARCH_LOW ] = "SEARCH_LOW", | |
409 | [ SET_LIMITS ] = "SET_LIMITS", | |
410 | [ PRE_FETCH ] = "PRE_FETCH/READ_POSITION", | |
411 | /* READ_POSITION and PRE_FETCH use the same operation code */ | |
412 | [ SYNCHRONIZE_CACHE ] = "SYNCHRONIZE_CACHE", | |
413 | [ LOCK_UNLOCK_CACHE ] = "LOCK_UNLOCK_CACHE", | |
414 | [ READ_DEFECT_DATA ] = "READ_DEFECT_DATA/INITIALIZE_ELEMENT_STATUS_WITH_RANGE", | |
415 | /* READ_DEFECT_DATA and INITIALIZE_ELEMENT_STATUS_WITH_RANGE use the same operation code */ | |
416 | [ MEDIUM_SCAN ] = "MEDIUM_SCAN", | |
417 | [ COMPARE ] = "COMPARE", | |
418 | [ COPY_VERIFY ] = "COPY_VERIFY", | |
419 | [ WRITE_BUFFER ] = "WRITE_BUFFER", | |
420 | [ READ_BUFFER ] = "READ_BUFFER", | |
421 | [ UPDATE_BLOCK ] = "UPDATE_BLOCK", | |
422 | [ READ_LONG_10 ] = "READ_LONG_10", | |
423 | [ WRITE_LONG_10 ] = "WRITE_LONG_10", | |
424 | [ CHANGE_DEFINITION ] = "CHANGE_DEFINITION", | |
425 | [ WRITE_SAME_10 ] = "WRITE_SAME_10", | |
426 | [ UNMAP ] = "UNMAP", | |
427 | [ READ_TOC ] = "READ_TOC", | |
428 | [ REPORT_DENSITY_SUPPORT ] = "REPORT_DENSITY_SUPPORT", | |
429 | [ SANITIZE ] = "SANITIZE", | |
430 | [ GET_CONFIGURATION ] = "GET_CONFIGURATION", | |
431 | [ LOG_SELECT ] = "LOG_SELECT", | |
432 | [ LOG_SENSE ] = "LOG_SENSE", | |
433 | [ MODE_SELECT_10 ] = "MODE_SELECT_10", | |
434 | [ RESERVE_10 ] = "RESERVE_10", | |
435 | [ RELEASE_10 ] = "RELEASE_10", | |
436 | [ MODE_SENSE_10 ] = "MODE_SENSE_10", | |
437 | [ PERSISTENT_RESERVE_IN ] = "PERSISTENT_RESERVE_IN", | |
438 | [ PERSISTENT_RESERVE_OUT ] = "PERSISTENT_RESERVE_OUT", | |
439 | [ WRITE_FILEMARKS_16 ] = "WRITE_FILEMARKS_16", | |
440 | [ EXTENDED_COPY ] = "EXTENDED_COPY", | |
441 | [ ATA_PASSTHROUGH_16 ] = "ATA_PASSTHROUGH_16", | |
442 | [ ACCESS_CONTROL_IN ] = "ACCESS_CONTROL_IN", | |
443 | [ ACCESS_CONTROL_OUT ] = "ACCESS_CONTROL_OUT", | |
444 | [ READ_16 ] = "READ_16", | |
445 | [ COMPARE_AND_WRITE ] = "COMPARE_AND_WRITE", | |
446 | [ WRITE_16 ] = "WRITE_16", | |
447 | [ WRITE_VERIFY_16 ] = "WRITE_VERIFY_16", | |
448 | [ VERIFY_16 ] = "VERIFY_16", | |
449 | [ PRE_FETCH_16 ] = "PRE_FETCH_16", | |
450 | [ SYNCHRONIZE_CACHE_16 ] = "SPACE_16/SYNCHRONIZE_CACHE_16", | |
451 | /* SPACE_16 and SYNCHRONIZE_CACHE_16 use the same operation code */ | |
452 | [ LOCATE_16 ] = "LOCATE_16", | |
453 | [ WRITE_SAME_16 ] = "ERASE_16/WRITE_SAME_16", | |
454 | /* ERASE_16 and WRITE_SAME_16 use the same operation code */ | |
455 | [ SERVICE_ACTION_IN_16 ] = "SERVICE_ACTION_IN_16", | |
456 | [ WRITE_LONG_16 ] = "WRITE_LONG_16", | |
457 | [ REPORT_LUNS ] = "REPORT_LUNS", | |
458 | [ ATA_PASSTHROUGH_12 ] = "BLANK/ATA_PASSTHROUGH_12", | |
459 | [ MOVE_MEDIUM ] = "MOVE_MEDIUM", | |
460 | [ EXCHANGE_MEDIUM ] = "EXCHANGE MEDIUM", | |
461 | [ READ_12 ] = "READ_12", | |
462 | [ WRITE_12 ] = "WRITE_12", | |
463 | [ ERASE_12 ] = "ERASE_12/GET_PERFORMANCE", | |
464 | /* ERASE_12 and GET_PERFORMANCE use the same operation code */ | |
465 | [ SERVICE_ACTION_IN_12 ] = "SERVICE_ACTION_IN_12", | |
466 | [ WRITE_VERIFY_12 ] = "WRITE_VERIFY_12", | |
467 | [ VERIFY_12 ] = "VERIFY_12", | |
468 | [ SEARCH_HIGH_12 ] = "SEARCH_HIGH_12", | |
469 | [ SEARCH_EQUAL_12 ] = "SEARCH_EQUAL_12", | |
470 | [ SEARCH_LOW_12 ] = "SEARCH_LOW_12", | |
471 | [ READ_ELEMENT_STATUS ] = "READ_ELEMENT_STATUS", | |
472 | [ SEND_VOLUME_TAG ] = "SEND_VOLUME_TAG/SET_STREAMING", | |
473 | /* SEND_VOLUME_TAG and SET_STREAMING use the same operation code */ | |
474 | [ READ_CD ] = "READ_CD", | |
475 | [ READ_DEFECT_DATA_12 ] = "READ_DEFECT_DATA_12", | |
476 | [ READ_DVD_STRUCTURE ] = "READ_DVD_STRUCTURE", | |
477 | [ RESERVE_TRACK ] = "RESERVE_TRACK", | |
478 | [ SEND_CUE_SHEET ] = "SEND_CUE_SHEET", | |
479 | [ SEND_DVD_STRUCTURE ] = "SEND_DVD_STRUCTURE", | |
480 | [ SET_CD_SPEED ] = "SET_CD_SPEED", | |
481 | [ SET_READ_AHEAD ] = "SET_READ_AHEAD", | |
482 | [ ALLOW_OVERWRITE ] = "ALLOW_OVERWRITE", | |
483 | [ MECHANISM_STATUS ] = "MECHANISM_STATUS", | |
484 | [ GET_EVENT_STATUS_NOTIFICATION ] = "GET_EVENT_STATUS_NOTIFICATION", | |
485 | [ READ_DISC_INFORMATION ] = "READ_DISC_INFORMATION", | |
486 | }; | |
487 | ||
488 | if (cmd >= ARRAY_SIZE(names) || names[cmd] == NULL) { | |
489 | return "*UNKNOWN*"; | |
490 | } | |
491 | return names[cmd]; | |
492 | } |