1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 
27 /*LINTLIBRARY*/
28 
29 /*
30  *	This module provides error messages to the
31  *	a5k and g_fc libraries.
32  */
33 
34 /*
35  * I18N message number ranges
36  *  This file: 10000 - 10499
37  *  Shared common messages: 1 - 1999
38  */
39 
40 /* #define	_POSIX_SOURCE 1 */
41 
42 
43 /*	Includes	*/
44 #include	<stdlib.h>
45 #include	<stdio.h>
46 #include	<fcntl.h>
47 #include	<nl_types.h>
48 #include	<sys/scsi/scsi.h>
49 #include	<stgcom.h>
50 #include	<l_error.h>	/* error msg defines. */
51 #include	<l_common.h>	/* I18N	message define */
52 #include	<g_state.h>
53 
54 #include	<string.h> /* For strerror */
55 #include	<errno.h>
56 
57 
58 /*	Defines		*/
59 #define	MAXLEN	1000
60 
61 
62 
63 /*
64  * Decodes the SCSI sense byte to a string.
65  *
66  * RETURNS:
67  *	character string
68  */
69 static char *
decode_sense_byte(uchar_t status)70 decode_sense_byte(uchar_t status)
71 {
72 	switch (status & STATUS_MASK) {
73 		case STATUS_GOOD:
74 			return (MSGSTR(10000, "Good status"));
75 
76 		case STATUS_CHECK:
77 			return (MSGSTR(128, "Check condition"));
78 
79 		case STATUS_MET:
80 			return (MSGSTR(124, "Condition met"));
81 
82 		case STATUS_BUSY:
83 			return (MSGSTR(37, "Busy"));
84 
85 		case STATUS_INTERMEDIATE:
86 			return (MSGSTR(10001, "Intermediate"));
87 
88 		case STATUS_INTERMEDIATE_MET:
89 			return (MSGSTR(10002, "Intermediate - condition met"));
90 
91 		case STATUS_RESERVATION_CONFLICT:
92 			return (MSGSTR(10003, "Reservation_conflict"));
93 
94 		case STATUS_TERMINATED:
95 			return (MSGSTR(126, "Command terminated"));
96 
97 		case STATUS_QFULL:
98 			return (MSGSTR(83, "Queue full"));
99 
100 		default:
101 			return (MSGSTR(4, "Unknown status"));
102 	}
103 }
104 
105 
106 /*
107  * This function finds a predefined error string to a given
108  * error number (errornum), allocates memory for the string
109  * and returns the corresponding error message to the caller.
110  *
111  * RETURNS
112  *	error string	if O.K.
113  *	NULL		otherwise
114  */
115 char
g_get_errString(int errornum)116 *g_get_errString(int errornum)
117 {
118 char	err_msg[MAXLEN], *errStrg;
119 
120 	err_msg[0] = '\0'; /* Just in case */
121 	if (errornum < L_BASE) {
122 			/* Some sort of random system error most likely */
123 			errStrg = strerror(errno);
124 			if (errStrg != NULL) {
125 				(void) strcpy(err_msg, errStrg);
126 			} else { /* Something's _really_ messed up */
127 				(void) sprintf(err_msg,
128 					MSGSTR(10081,
129 					" Error: could not decode the"
130 					" error message.\n"
131 					" The given error message is not"
132 					" defined in the library.\n"
133 					" Message number: %d.\n"), errornum);
134 			}
135 
136 	/* Make sure ALL CASES set err_msg to something */
137 	} else switch (errornum) {
138 		case L_SCSI_ERROR:
139 			(void) sprintf(err_msg,
140 				MSGSTR(10096,
141 				" Error: SCSI failure."));
142 			break;
143 
144 		case L_PR_INVLD_TRNSFR_LEN:
145 			(void) sprintf(err_msg,
146 				MSGSTR(10005,
147 				" Error: Persistant Reserve command"
148 				" transfer length not word aligned."));
149 			break;
150 
151 		case L_RD_NO_DISK_ELEM:
152 			(void) sprintf(err_msg,
153 				MSGSTR(10006,
154 				" Error: Could not find the disk elements"
155 				" in the Receive Diagnostic pages."));
156 			break;
157 
158 		case L_RD_INVLD_TRNSFR_LEN:
159 			(void) sprintf(err_msg,
160 				MSGSTR(10007,
161 				" Error: Receive Diagnostic command"
162 				" transfer length not word aligned."));
163 			break;
164 
165 		case L_ILLEGAL_MODE_SENSE_PAGE:
166 			(void) sprintf(err_msg,
167 				MSGSTR(10008,
168 				" Error: Programming error - "
169 				"illegal Mode Sense parameter."));
170 			break;
171 
172 		case L_INVALID_NO_OF_ENVSEN_PAGES:
173 			(void) sprintf(err_msg,
174 				MSGSTR(10009,
175 				" Error: Invalid no. of sense pages.\n"
176 				" Could not get valid sense page"
177 				" information from the device."));
178 			break;
179 
180 		case L_INVALID_BUF_LEN:
181 			(void) sprintf(err_msg,
182 				MSGSTR(10010,
183 				" Error: Invalid buffer length.\n"
184 				" Could not get diagnostic "
185 				" information from the device."));
186 			break;
187 
188 		case L_INVALID_PATH:
189 			(void) sprintf(err_msg,
190 				MSGSTR(113,
191 				" Error: Invalid pathname"));
192 			break;
193 
194 		case L_NO_PHYS_PATH:
195 			(void) sprintf(err_msg,
196 				MSGSTR(10011,
197 				" Error: Could not get"
198 				" physical path to the device."));
199 			break;
200 
201 		case L_NO_SES_PATH:
202 			(void) sprintf(err_msg,
203 				MSGSTR(10098,
204 				" Error: No SES found"
205 				" for the device path."));
206 			break;
207 
208 		case L_INVLD_PATH_NO_SLASH_FND:
209 			(void) sprintf(err_msg,
210 				MSGSTR(10012,
211 				"Error in the device physical path."));
212 			break;
213 
214 		case L_INVLD_PATH_NO_ATSIGN_FND:
215 			(void) sprintf(err_msg,
216 				MSGSTR(10013,
217 				" Error in the device physical path:"
218 				" no @ found."));
219 			break;
220 
221 		case L_INVALID_SLOT:
222 			(void) sprintf(err_msg,
223 				MSGSTR(10014,
224 				" Error: Invalid path format."
225 				" Invalid slot."));
226 			break;
227 
228 		case L_INVALID_LED_RQST:
229 			(void) sprintf(err_msg,
230 				MSGSTR(10015,
231 				" Error: Invalid LED request."));
232 			break;
233 
234 		case L_INVALID_PATH_FORMAT:
235 			(void) sprintf(err_msg,
236 				MSGSTR(10016,
237 				" Error: Invalid path format."));
238 			break;
239 
240 		case L_OPEN_PATH_FAIL:
241 			(void) sprintf(err_msg,
242 				MSGSTR(10017,
243 				" Error opening the path."));
244 			break;
245 
246 		case L_INVALID_PASSWORD_LEN:
247 			(void) sprintf(err_msg,
248 				MSGSTR(10018,
249 				"Error: Invalid password length."));
250 			break;
251 
252 		case L_INVLD_PHYS_PATH_TO_DISK:
253 			(void) sprintf(err_msg,
254 				MSGSTR(10019,
255 				" Error: Physical path not of a disk."));
256 			break;
257 
258 		case L_INVLD_ID_FOUND:
259 			(void) sprintf(err_msg,
260 				MSGSTR(10020,
261 				" Error in the device physical path:"
262 				" Invalid ID found in the path."));
263 			break;
264 
265 		case L_INVLD_WWN_FORMAT:
266 			(void) sprintf(err_msg,
267 				MSGSTR(10021,
268 				" Error in the device physical path:"
269 				" Invalid wwn format."));
270 
271 			break;
272 
273 		case L_NO_VALID_PATH:
274 			(void) sprintf(err_msg,
275 				MSGSTR(10022,
276 				" Error: Could not find valid path to"
277 				" the device."));
278 			break;
279 
280 		case L_NO_WWN_FOUND_IN_PATH:
281 			(void) sprintf(err_msg,
282 				MSGSTR(10023,
283 				" Error in the device physical path:"
284 				" No WWN found."));
285 
286 			break;
287 
288 		case L_NO_NODE_WWN_IN_WWNLIST:
289 			(void) sprintf(err_msg,
290 				MSGSTR(10024,
291 				" Error: Device's Node WWN is not"
292 				" found in the WWN list.\n"));
293 			break;
294 
295 		case L_NO_NODE_WWN_IN_BOXLIST:
296 			(void) sprintf(err_msg,
297 				MSGSTR(10025,
298 				" Error: Device's Node WWN is not"
299 				" found in the Box list.\n"));
300 			break;
301 
302 		case L_NULL_WWN_LIST:
303 			(void) sprintf(err_msg,
304 				MSGSTR(10026,
305 				" Error: Null WWN list found."));
306 			break;
307 
308 		case L_NO_LOOP_ADDRS_FOUND:
309 			(void) sprintf(err_msg,
310 				MSGSTR(10027,
311 				" Error: Could not find the loop address for "
312 				" the device at physical path."));
313 
314 			break;
315 
316 		case L_INVLD_PORT_IN_PATH:
317 			(void) sprintf(err_msg,
318 				MSGSTR(10028,
319 				"Error in the device physical path:"
320 				" Invalid port number found."
321 				" (Should be 0 or 1)."));
322 
323 			break;
324 
325 		case L_INVALID_LOOP_MAP:
326 			(void) sprintf(err_msg,
327 				MSGSTR(10029,
328 				"Error: Invalid loop map found."));
329 			break;
330 
331 		case L_SFIOCGMAP_IOCTL_FAIL:
332 			(void) sprintf(err_msg,
333 				MSGSTR(10030,
334 				" Error: SFIOCGMAP ioctl failed."
335 				" Cannot read loop map."));
336 			break;
337 
338 		case L_FCIO_GETMAP_IOCTL_FAIL:
339 			(void) sprintf(err_msg,
340 				MSGSTR(10031,
341 				" Error: FCIO_GETMAP ioctl failed."
342 				" Cannot read loop map."));
343 			break;
344 
345 		case L_FCIO_LINKSTATUS_FAILED:
346 			(void) sprintf(err_msg,
347 				MSGSTR(10032,
348 				" Error: FCIO_LINKSTATUS ioctl failed."
349 				" Cannot read loop map."));
350 			break;
351 
352 		case L_FCIOGETMAP_INVLD_LEN:
353 			(void) sprintf(err_msg,
354 				MSGSTR(10033,
355 				" Error: FCIO_GETMAP ioctl returned"
356 				" an invalid parameter:"
357 				" # entries to large."));
358 			break;
359 
360 		case L_FCIO_FORCE_LIP_FAIL:
361 			(void) sprintf(err_msg,
362 				MSGSTR(10034,
363 				" Error: FCIO_FORCE_LIP ioctl failed."));
364 			break;
365 
366 		case L_FCIO_FORCE_LIP_PARTIAL_FAIL:
367 			(void) sprintf(err_msg,
368 				MSGSTR(10115,
369 				" Error: FCIO_FORCE_LIP ioctl failed on one"
370 				" or more (but not all) of the paths."));
371 			break;
372 
373 		case L_DWNLD_CHKSUM_FAILED:
374 			(void) sprintf(err_msg,
375 				MSGSTR(10035,
376 				"Error: Download file checksum failed."));
377 
378 			break;
379 
380 		case L_DWNLD_READ_HEADER_FAIL:
381 			(void) sprintf(err_msg,
382 				MSGSTR(10036,
383 				" Error: Reading download file exec"
384 				" header failed."));
385 			break;
386 
387 		case L_DWNLD_READ_INCORRECT_BYTES:
388 			(void) sprintf(err_msg,
389 				MSGSTR(10037,
390 				" Error: Incorrect number of bytes read."));
391 			break;
392 
393 		case L_DWNLD_INVALID_TEXT_SIZE:
394 			(void) sprintf(err_msg,
395 				MSGSTR(10038,
396 				" Error: Reading text segment: "
397 				" Found wrong size."));
398 			break;
399 
400 		case L_DWNLD_READ_ERROR:
401 			(void) sprintf(err_msg,
402 				MSGSTR(10039,
403 				" Error: Failed to read download file."));
404 			break;
405 
406 		case L_DWNLD_BAD_FRMWARE:
407 			(void) sprintf(err_msg,
408 				MSGSTR(10040,
409 				" Error: Bad Firmware MAGIC."));
410 			break;
411 
412 		case L_DWNLD_TIMED_OUT:
413 			(void) sprintf(err_msg,
414 				MSGSTR(10041,
415 				" Error: Timed out in 5 minutes"
416 				" waiting for the"
417 				" IB to become available."));
418 			break;
419 
420 		case L_REC_DIAG_PG1:
421 			(void) sprintf(err_msg,
422 				MSGSTR(10042,
423 				" Error parsing the Receive"
424 				" diagnostic page."));
425 			break;
426 
427 		case L_TRANSFER_LEN:
428 			(void) sprintf(err_msg,
429 				MSGSTR(10043, "  "));
430 			break;
431 
432 		case L_REQUIRE_FILE:
433 			(void) sprintf(err_msg,
434 				MSGSTR(10109,
435 				" Error: No default file.  You must specify"
436 				" the filename path."));
437 			break;
438 
439 		case L_MALLOC_FAILED:
440 			(void) sprintf(err_msg,
441 				MSGSTR(10,
442 				" Error: Unable to allocate memory."));
443 			break;
444 
445 		case L_LOCALTIME_ERROR:
446 			(void) sprintf(err_msg,
447 				MSGSTR(10044,
448 				" Error: Could not convert time"
449 				" to broken-down time: Hrs/Mins/Secs."));
450 			break;
451 
452 		case L_SELECT_ERROR:
453 			(void) sprintf(err_msg,
454 				MSGSTR(10045,
455 				" select() error during retry:"
456 				" Could not wait for"
457 				" specified time."));
458 			break;
459 
460 		case L_NO_DISK_DEV_FOUND:
461 			(void) sprintf(err_msg,
462 				MSGSTR(10046,
463 				" Error: No disk devices found"
464 				" in the /dev/rdsk"
465 				" directory."));
466 			break;
467 
468 		case L_NO_TAPE_DEV_FOUND:
469 			(void) sprintf(err_msg,
470 				MSGSTR(10047,
471 				" Error: No tape devices found"
472 				" in the /dev/rmt"
473 				" directory."));
474 			break;
475 
476 		case L_LSTAT_ERROR:
477 			(void) sprintf(err_msg,
478 				MSGSTR(10048,
479 				" lstat() error: Cannot obtain status"
480 				" for the device."));
481 			break;
482 
483 		case L_SYMLINK_ERROR:
484 			(void) sprintf(err_msg,
485 				MSGSTR(10049,
486 				" Error: Could not read the symbolic link."));
487 			break;
488 
489 		case L_UNAME_FAILED:
490 			(void) sprintf(err_msg,
491 				MSGSTR(10050,
492 				" uname() error: Could not obtain the"
493 				" architeture of the host machine."));
494 			break;
495 
496 		case L_DRVCONFIG_ERROR:
497 			(void) sprintf(err_msg,
498 				MSGSTR(10051,
499 				" Error: Could not run drvconfig."));
500 			break;
501 
502 		case L_DISKS_ERROR:
503 			(void) sprintf(err_msg,
504 				MSGSTR(10052,
505 				" Error: Could not run disks."));
506 			break;
507 
508 		case L_DEVLINKS_ERROR:
509 			(void) sprintf(err_msg,
510 				MSGSTR(10053,
511 				" Error: Could not run devlinks."));
512 			break;
513 
514 		case L_READ_DEV_DIR_ERROR:
515 			(void) sprintf(err_msg,
516 				MSGSTR(10054,
517 				" Error: Could not read /dev/rdsk"
518 				" directory."));
519 			break;
520 
521 		case L_OPEN_ES_DIR_FAILED:
522 			(void) sprintf(err_msg,
523 				MSGSTR(10055,
524 				" Error: Could not open /dev/es"
525 				" directory."));
526 			break;
527 
528 		case L_LSTAT_ES_DIR_ERROR:
529 			(void) sprintf(err_msg,
530 				MSGSTR(10056,
531 				" lstat() error: Could not get status"
532 				" for /dev/es directory."));
533 			break;
534 
535 		case L_DEV_BUSY:
536 			(void) sprintf(err_msg,
537 				MSGSTR(10057,
538 				" Error: Could not offline the device\n"
539 				" May be Busy."));
540 			break;
541 
542 		case L_EXCL_OPEN_FAILED:
543 			(void) sprintf(err_msg,
544 				MSGSTR(10058,
545 				" Error: Could not open device in"
546 				" exclusive mode."
547 				"  May already be open."));
548 			break;
549 
550 		case L_DEVICE_RESERVED:
551 			(void) sprintf(err_msg,
552 				MSGSTR(10059,
553 				" Error: Disk is reserved."));
554 			break;
555 
556 		case L_DISKS_RESERVED:
557 			(void) sprintf(err_msg,
558 				MSGSTR(10060,
559 				" Error: One or more disks in"
560 				" SENA are reserved."));
561 			break;
562 
563 		case L_SLOT_EMPTY:
564 			(void) sprintf(err_msg,
565 				MSGSTR(10061,
566 				" Error: Slot is empty."));
567 			break;
568 
569 		case L_ACQUIRE_FAIL:
570 			(void) sprintf(err_msg,
571 				MSGSTR(10062,
572 				" Error: Could not acquire"
573 				" the device."));
574 			break;
575 
576 		case L_POWER_OFF_FAIL_BUSY:
577 			(void) sprintf(err_msg,
578 				MSGSTR(10063,
579 				" Error: Could not power off the device.\n"
580 				" May be Busy."));
581 			break;
582 
583 		case L_ENCL_NAME_CHANGE_FAIL:
584 			(void) sprintf(err_msg,
585 				MSGSTR(10064,
586 				" Error: The Enclosure name change failed."));
587 			break;
588 
589 		case L_DUPLICATE_ENCLOSURES:
590 			(void) sprintf(err_msg,
591 				MSGSTR(10065,
592 				" Error: There are two or more enclosures"
593 				" with the same name."
594 				" Please use a logical or physical"
595 				" pathname."));
596 			break;
597 
598 		case L_INVALID_NUM_DISKS_ENCL:
599 			(void) sprintf(err_msg,
600 				MSGSTR(10066,
601 				" Error: The number of disks in the"
602 				" front & rear of the enclosure are"
603 				" different."
604 				" This is not a supported configuration."));
605 			break;
606 
607 		case L_ENCL_INVALID_PATH:
608 			(void) sprintf(err_msg,
609 				MSGSTR(10067,
610 				" Error: Invalid path."
611 				" Device is not a SENA subsystem."));
612 			break;
613 
614 		case L_NO_ENCL_LIST_FOUND:
615 			(void) sprintf(err_msg,
616 				MSGSTR(10068,
617 				" Error: Cannot get the Box list."));
618 			break;
619 
620 		case L_IB_NO_ELEM_FOUND:
621 			(void) sprintf(err_msg,
622 				MSGSTR(10069,
623 				" Error: No elements returned from"
624 				" enclosure (IB)."));
625 			break;
626 
627 		case L_GET_STATUS_FAILED:
628 			(void) sprintf(err_msg,
629 				MSGSTR(10070,
630 				" Error: Get status failed."));
631 			break;
632 
633 		case L_RD_PG_MIN_BUFF:
634 			(void) sprintf(err_msg,
635 				MSGSTR(10071,
636 				" Error: Reading page from IB.\n"
637 				" Buffer size too small."));
638 			break;
639 
640 		case L_RD_PG_INVLD_CODE:
641 			(void) sprintf(err_msg,
642 				MSGSTR(10072,
643 				" Error: Reading page from IB\n"
644 				" Invalid page code or page len found."));
645 			break;
646 
647 		case L_BP_BUSY_RESERVED:
648 			(void) sprintf(err_msg,
649 				MSGSTR(10073,
650 				" Error: There is a busy or reserved disk"
651 				" attached to this backplane.\n"
652 				" You must close the disk,\n"
653 				" or release the disk,\n"
654 				" or resubmit the command using"
655 				" the Force option."));
656 			break;
657 
658 		case L_BP_BUSY:
659 			(void) sprintf(err_msg,
660 				MSGSTR(10074,
661 				" Error: There is a busy disk"
662 				" attached to this backplane.\n"
663 				" You must close the disk,\n"
664 				" or resubmit the command using"
665 				" the Force option."));
666 			break;
667 
668 		case L_BP_RESERVED:
669 			(void) sprintf(err_msg,
670 				MSGSTR(10075,
671 				" Error: There is a reserved disk"
672 				" attached to this backplane.\n"
673 				" You must release the disk,\n"
674 				" or resubmit the subcommand using"
675 				" the Force option."));
676 			break;
677 
678 		case L_NO_BP_ELEM_FOUND:
679 			(void) sprintf(err_msg,
680 				MSGSTR(10076,
681 				" Error: No Back plane elements found"
682 				" in the enclosure."));
683 			break;
684 
685 		case L_SSA_CONFLICT:
686 			(void) sprintf(err_msg,
687 				MSGSTR(10077,
688 				" There is a conflict between the "
689 				"enclosure name and an SSA name of "
690 				"same form, cN.\n"
691 				" Please use a logical or physical "
692 				"pathname."));
693 			break;
694 
695 		case L_WARNING:
696 			(void) sprintf(err_msg,
697 				MSGSTR(10078, " Warning:"));
698 
699 			break;
700 
701 		case L_TH_JOIN:
702 			(void) sprintf(err_msg,
703 				MSGSTR(10079,
704 				" Error: Thread join failed."));
705 			break;
706 
707 		case L_FCIO_RESET_LINK_FAIL:
708 			(void) sprintf(err_msg,
709 				MSGSTR(10082,
710 				" Error: FCIO_RESET_LINK ioctl failed.\n"
711 				" Could not reset the loop."));
712 			break;
713 
714 		case L_FCIO_GET_FCODE_REV_FAIL:
715 			(void) sprintf(err_msg,
716 				MSGSTR(10083,
717 				" Error: FCIO_GET_FCODE_REV ioctl failed.\n"
718 				" Could not get the fcode version."));
719 			break;
720 
721 		case L_FCIO_GET_FW_REV_FAIL:
722 			(void) sprintf(err_msg,
723 				MSGSTR(10084,
724 				" Error: FCIO_GET_FW_REV ioctl failed.\n"
725 				" Could not get the firmware revision."));
726 			break;
727 
728 		case L_NO_DEVICES_FOUND:
729 			(void) sprintf(err_msg,
730 				MSGSTR(10085,
731 				" No FC devices found."));
732 			break;
733 
734 		case L_INVALID_DEVICE_COUNT:
735 			(void) sprintf(err_msg,
736 				MSGSTR(10086,
737 				" Error: FCIO_GET_DEV_LIST ioctl returned"
738 				" an invalid device count."));
739 			break;
740 
741 		case L_FCIO_GET_NUM_DEVS_FAIL:
742 			(void) sprintf(err_msg,
743 				MSGSTR(10087,
744 				" Error: FCIO_GET_NUM_DEVS ioctl failed.\n"
745 				" Could not get the number of devices."));
746 			break;
747 
748 		case L_FCIO_GET_DEV_LIST_FAIL:
749 			(void) sprintf(err_msg,
750 				MSGSTR(10088,
751 				" Error: FCIO_GET_DEV_LIST ioctl failed.\n"
752 				" Could not get the device list."));
753 			break;
754 
755 		case L_FCIO_GET_LINK_STATUS_FAIL:
756 			(void) sprintf(err_msg,
757 				MSGSTR(10089,
758 				" Error: FCIO_GET_LINK_STATUS ioctl failed.\n"
759 				" Could not get the link status."));
760 			break;
761 
762 		case L_PORT_OFFLINE_FAIL:
763 			(void) sprintf(err_msg,
764 				MSGSTR(10090,
765 				" Error: ioctl to offline the port failed."));
766 			break;
767 
768 		case L_PORT_OFFLINE_UNSUPPORTED:
769 			(void) sprintf(err_msg,
770 				MSGSTR(10091,
771 				" Error: The driver does not support ioctl to"
772 				" disable the FCA port."));
773 			break;
774 
775 		case L_PORT_ONLINE_FAIL:
776 			(void) sprintf(err_msg,
777 				MSGSTR(10092,
778 				" Error: ioctl to online the port failed."));
779 			break;
780 
781 		case L_PORT_ONLINE_UNSUPPORTED:
782 			(void) sprintf(err_msg,
783 				MSGSTR(10093,
784 				" Error: The driver does not support ioctl to"
785 				" enable the FCA port."));
786 			break;
787 
788 		case L_FCP_TGT_INQUIRY_FAIL:
789 			(void) sprintf(err_msg,
790 				MSGSTR(10094,
791 				" Error: FCP_TGT_INQUIRY ioctl failed.\n"
792 				" Could not get the target inquiry data"
793 				" from FCP."));
794 			break;
795 
796 		case L_FSTAT_ERROR:
797 			(void) sprintf(err_msg,
798 				MSGSTR(10095,
799 				" fstat() error: Cannot obtain status"
800 				" for the device."));
801 			break;
802 
803 		case L_FCIO_GET_HOST_PARAMS_FAIL:
804 			(void) sprintf(err_msg,
805 				MSGSTR(10097,
806 				" Error: FCIO_GET_HOST_PARAMS ioctl failed.\n"
807 				" Could not get the host parameters."));
808 			break;
809 
810 		case L_STAT_ERROR:
811 			(void) sprintf(err_msg,
812 				MSGSTR(10099,
813 				" stat() error: Cannot obtain status"
814 				" for the device."));
815 			break;
816 
817 		case L_DEV_SNAPSHOT_FAILED:
818 			(void) sprintf(err_msg,
819 				MSGSTR(10100,
820 				" Error: Could not retrieve device tree"
821 				" snapshot."));
822 			break;
823 
824 		case L_LOOPBACK_UNSUPPORTED:
825 			(void) sprintf(err_msg,
826 				MSGSTR(10101,
827 				" Error: Loopback mode is unsupported for this"
828 				" device."));
829 			break;
830 
831 		case L_LOOPBACK_FAILED:
832 			(void) sprintf(err_msg,
833 				MSGSTR(10102,
834 				" Error: Error occurred during loopback mode"
835 				" set."));
836 			break;
837 
838 		case L_FCIO_GET_TOPOLOGY_FAIL:
839 			(void) sprintf(err_msg,
840 				MSGSTR(10103,
841 				" Error: FCIO_GET_TOPOLOGY ioctl failed.\n"
842 				" Could not get the fca port topology."));
843 			break;
844 
845 		case L_UNEXPECTED_FC_TOPOLOGY:
846 			(void) sprintf(err_msg,
847 				MSGSTR(10104,
848 				" Error: Unexpected Fibre Channel topology"
849 				" found."));
850 			break;
851 
852 		case L_INVALID_PRIVATE_LOOP_ADDRESS:
853 			(void) sprintf(err_msg,
854 				MSGSTR(10105,
855 				" Error: AL_PA is not a valid private loop"
856 				" address."));
857 			break;
858 
859 		case L_NO_FABRIC_ADDR_FOUND:
860 			(void) sprintf(err_msg,
861 				MSGSTR(10106,
862 				" Error: Could not find the fabric address"
863 				" for the device at physical path."));
864 			break;
865 
866 		case L_INVALID_FABRIC_ADDRESS:
867 			(void) sprintf(err_msg,
868 				MSGSTR(10107,
869 				" Error: Device port address on the Fabric"
870 				" topology is not valid."));
871 			break;
872 
873 		case L_PT_PT_FC_TOP_NOT_SUPPORTED:
874 			(void) sprintf(err_msg,
875 				MSGSTR(10108,
876 				" Error: Point to Point Fibre Channel "
877 				"topology is currently not supported."));
878 			break;
879 
880 		case L_FCIO_DEV_LOGIN_FAIL:
881 			(void) sprintf(err_msg,
882 				MSGSTR(10310,
883 				" Error: FCIO_DEV_LOGIN ioctl failed."));
884 			break;
885 
886 		case L_FCIO_DEV_LOGOUT_FAIL:
887 			(void) sprintf(err_msg,
888 				MSGSTR(10311,
889 				" Error: FCIO_DEV_LOGOUT ioctl failed."));
890 			break;
891 
892 		case L_OPNOSUPP_ON_TOPOLOGY:
893 			(void) sprintf(err_msg,
894 				MSGSTR(10312,
895 				" Error: operation not supported "
896 				"on connected topology."));
897 			break;
898 
899 		case L_INVALID_PATH_TYPE:
900 			(void) sprintf(err_msg,
901 				MSGSTR(10313,
902 				" Error: operation not supported "
903 				"on the path."));
904 			break;
905 
906 		case L_FCIO_GET_STATE_FAIL:
907 			(void) sprintf(err_msg,
908 				MSGSTR(10314,
909 				" Error: FCIO_GET_STATE ioctl failed."));
910 			break;
911 
912 		case L_WWN_NOT_FOUND_IN_DEV_LIST:
913 			(void) sprintf(err_msg,
914 				MSGSTR(10315,
915 				" Error: device WWN not found in "
916 				"device list."));
917 			break;
918 
919 		case L_STAT_RMT_DIR_ERROR:
920 			(void) sprintf(err_msg,
921 				MSGSTR(10110,
922 				" stat() error: Could not get status"
923 				" for /dev/rmt directory."));
924 			break;
925 
926 		case L_STAT_DEV_DIR_ERROR:
927 			(void) sprintf(err_msg,
928 				MSGSTR(10111,
929 				" stat() error: Could not get status"
930 				" for /dev/dsk directory."));
931 			break;
932 
933 		case L_PROM_INIT_FAILED:
934 			(void) sprintf(err_msg,
935 				MSGSTR(10234,
936 				" Error: di_prom_init failure"));
937 			break;
938 
939 		case L_PORT_DRIVER_NOT_FOUND:
940 			(void) sprintf(err_msg,
941 				MSGSTR(10113,
942 				" Error: requested port driver"
943 				" does not exist"));
944 			break;
945 
946 		case L_PHYS_PATH_NOT_FOUND:
947 			(void) sprintf(err_msg,
948 				MSGSTR(10114,
949 				" Error: requested phys path does not exist"));
950 			break;
951 
952 		case L_GET_DEV_LIST_ULP_FAILURE:
953 			(void) sprintf(err_msg,
954 				MSGSTR(10150,
955 				" Error: g_get_dev_list failed on ULP "
956 				"processing of target device(s)"));
957 			break;
958 
959 		case L_SCSI_VHCI_ERROR:
960 			(void) sprintf(err_msg,
961 				MSGSTR(10230,
962 				" Error: Unable to perform failover"));
963 			break;
964 
965 		case L_SCSI_VHCI_ALREADY_ACTIVE:
966 			(void) sprintf(err_msg,
967 				MSGSTR(10231,
968 				" Error: Pathclass already active"));
969 			break;
970 
971 		case L_NO_DEVID:
972 			(void) sprintf(err_msg,
973 				MSGSTR(10232,
974 				" Error: No device identifier found"));
975 			break;
976 
977 		case L_DRIVER_NOTSUPP:
978 			(void) sprintf(err_msg,
979 				MSGSTR(10233,
980 				" Error: Driver not supported"));
981 			break;
982 
983 		case L_PROC_WWN_ARG_ERROR:
984 			(void) sprintf(err_msg,
985 				MSGSTR(10235,
986 				" Error: process WWN argument"));
987 			break;
988 
989 		case L_NO_WWN_PROP_FOUND:
990 			(void) sprintf(err_msg,
991 				MSGSTR(10236,
992 				" Error: WWN prop not found"));
993 			break;
994 
995 		case L_NO_DRIVER_NODES_FOUND:
996 			(void) sprintf(err_msg,
997 				MSGSTR(10237,
998 				" Error: Requested driver nodes not found"));
999 			break;
1000 
1001 		case L_INVALID_MAP_DEV_ADDR:
1002 			(void) sprintf(err_msg,
1003 				MSGSTR(10330,
1004 				" Error: Invalid map device handle found"));
1005 			break;
1006 
1007 		case L_INVALID_MAP_DEV_PROP_TYPE:
1008 			(void) sprintf(err_msg,
1009 				MSGSTR(10331,
1010 				" Error: Invalid device property type found"));
1011 			break;
1012 
1013 		case L_INVALID_MAP_DEV_PROP_NAME:
1014 			(void) sprintf(err_msg,
1015 				MSGSTR(10332,
1016 				" Error: Invalid device property name found"));
1017 			break;
1018 
1019 		case L_INVALID_MAP_DEV_PROP:
1020 			(void) sprintf(err_msg,
1021 				MSGSTR(10333,
1022 				" Error: Invalid device property handle "
1023 				"found"));
1024 			break;
1025 
1026 		case L_SCSI_VHCI_NO_STANDBY:
1027 			(void) sprintf(err_msg,
1028 				MSGSTR(10334,
1029 				" Error: Unable to perform failover, "
1030 				"standby path unavailable"));
1031 			break;
1032 
1033 		case L_SCSI_VHCI_FAILOVER_NOTSUP:
1034 			(void) sprintf(err_msg,
1035 				MSGSTR(10335,
1036 				" Error: Device does not support failover"));
1037 			break;
1038 
1039 		case L_SCSI_VHCI_FAILOVER_BUSY:
1040 			(void) sprintf(err_msg,
1041 				MSGSTR(10336,
1042 				" Error: Failover currently in progress"));
1043 			break;
1044 
1045 		case L_NO_SUCH_DEV_FOUND:
1046 			(void) sprintf(err_msg,
1047 				MSGSTR(10337,
1048 				" Error: No such device found"));
1049 			break;
1050 
1051 		case L_NO_SUCH_PROP_FOUND:
1052 			(void) sprintf(err_msg,
1053 				MSGSTR(10338,
1054 				" Error: No such property found"));
1055 			break;
1056 
1057 		case L_INVALID_ARG:
1058 			(void) sprintf(err_msg,
1059 				MSGSTR(10339,
1060 				" Error: Invalid argument found"));
1061 			break;
1062 
1063 		default:
1064 
1065 			if (((L_SCSI_ERROR ^ errornum) == STATUS_GOOD) ||
1066 			((L_SCSI_ERROR ^ errornum) == STATUS_BUSY) ||
1067 			((L_SCSI_ERROR ^ errornum) == STATUS_CHECK) ||
1068 			((L_SCSI_ERROR ^ errornum) == STATUS_MET) ||
1069 			((L_SCSI_ERROR ^ errornum) == STATUS_INTERMEDIATE) ||
1070 		((L_SCSI_ERROR ^ errornum) == STATUS_INTERMEDIATE_MET) ||
1071 		((L_SCSI_ERROR ^ errornum) == STATUS_RESERVATION_CONFLICT) ||
1072 			((L_SCSI_ERROR ^ errornum) == STATUS_TERMINATED) ||
1073 			((L_SCSI_ERROR ^ errornum) == STATUS_QFULL)) {
1074 				(void) sprintf(err_msg,
1075 					MSGSTR(10080,
1076 					" SCSI Error - Sense Byte:(0x%x) %s \n"
1077 					" Error: Retry failed."),
1078 				(L_SCSI_ERROR ^ errornum) & STATUS_MASK,
1079 			decode_sense_byte((uchar_t)L_SCSI_ERROR ^ errornum));
1080 			} else {
1081 				(void) sprintf(err_msg,
1082 					MSGSTR(10081,
1083 					" Error: could not decode the"
1084 					" error message.\n"
1085 					" The given error message is not"
1086 					" defined in the library.\n"
1087 					" Message number: %d.\n"), errornum);
1088 			}
1089 
1090 	} /* end of switch */
1091 
1092 	errStrg = g_alloc_string(err_msg);
1093 
1094 	return (errStrg);
1095 }
1096