Home | History | Annotate | Download | only in iscsitgtd
      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 /*
     23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 
     27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     28 
     29 #include <libintl.h>
     30 #include "errcode.h"
     31 
     32 char *
     33 errcode_to_str(err_code_t err_code)
     34 {
     35 	switch (err_code) {
     36 	case ERR_SUCCESS:
     37 		return ((char *)gettext("Operation completed successfully"));
     38 	case ERR_NULL_XML_MESSAGE:
     39 		return ((char *)gettext("Null XML message"));
     40 	case ERR_SYNTAX_EMPTY:
     41 		return ((char *)gettext("Syntax error: "
     42 		    "Empty XML message or syntax error"));
     43 	case ERR_SYNTAX_MISSING_ALL:
     44 		return ((char *)gettext("Syntax error: Missing --all"));
     45 	case ERR_SYNTAX_MISSING_BACKING_STORE:
     46 		return ((char *)gettext("Syntax error: Missing backing-store"));
     47 	case ERR_SYNTAX_MISSING_INAME:
     48 		return ((char *)gettext("Syntax error: Missing iscsi name"));
     49 	case ERR_SYNTAX_MISSING_IPADDR:
     50 		return ((char *)gettext("Syntax error: Missing IP address"));
     51 	case ERR_SYNTAX_MISSING_NAME:
     52 		return ((char *)gettext("Syntax error: Missing name"));
     53 	case ERR_SYNTAX_MISSING_OBJECT:
     54 		return ((char *)gettext("Syntax error: Missing object"));
     55 	case ERR_SYNTAX_MISSING_OPERAND:
     56 		return ((char *)gettext("Syntax error: Missing operand"));
     57 	case ERR_SYNTAX_MISSING_SIZE:
     58 		return ((char *)gettext("Syntax error: Missing size"));
     59 	case ERR_SYNTAX_MISSING_TYPE:
     60 		return ((char *)gettext("Syntax error: Missing type"));
     61 	case ERR_SYNTAX_EMPTY_ACL:
     62 		return ((char *)gettext("Syntax error: empty ACL"));
     63 	case ERR_SYNTAX_EMPTY_ALIAS:
     64 		return ((char *)gettext("Syntax error: empty alias"));
     65 	case ERR_SYNTAX_EMPTY_CHAPNAME:
     66 		return ((char *)gettext("Empty chap-name"));
     67 	case ERR_SYNTAX_EMPTY_CHAPSECRET:
     68 		return ((char *)gettext("Empty 'chap-secret' element"));
     69 	case ERR_SYNTAX_EMPTY_IPADDR:
     70 		return ((char *)gettext("Syntax error: empty IP address"));
     71 	case ERR_SYNTAX_EMPTY_MAXRECV:
     72 		return ((char *)gettext("Syntax error: empty maxrecv"));
     73 	case ERR_SYNTAX_EMPTY_TPGT:
     74 		return ((char *)gettext("Syntax error: empty TPGT"));
     75 	case ERR_SYNTAX_INVALID_NAME:
     76 		return ((char *)gettext("Syntax error: name may contain only "
     77 		    "a..z, A..Z, 0-9, dot(.), dash(-), colon(:) characters"));
     78 	case ERR_INVALID_COMMAND:
     79 		return ((char *)gettext("Invalid command"));
     80 	case ERR_INVALID_OBJECT:
     81 		return ((char *)gettext("Invalid object"));
     82 	case ERR_INVALID_BASEDIR:
     83 		return ((char *)gettext("Invalid base directory"));
     84 	case ERR_INVALID_IP:
     85 		return ((char *)gettext("Invalid IP address"));
     86 	case ERR_INVALID_TPGT:
     87 		return ((char *)gettext("Invalid TPGT"));
     88 	case ERR_INVALID_MAXRECV:
     89 		return ((char *)gettext("Invalid MaxRecvDataSegmentLength"));
     90 	case ERR_INVALID_RADSRV:
     91 		return ((char *)gettext("Invalid RADIUS server name"));
     92 	case ERR_INVALID_SIZE:
     93 		return ((char *)gettext("Invalid size parameter"));
     94 	case ERR_INIT_EXISTS:
     95 		return ((char *)gettext("Initiator already exists"));
     96 	case ERR_LUN_EXISTS:
     97 		return ((char *)gettext("LUN already exists"));
     98 	case ERR_LUN_INVALID_RANGE:
     99 		return ((char *)gettext("LUN must be between 0 and 16383"));
    100 	case ERR_TPGT_EXISTS:
    101 		return ((char *)gettext("TPGT already exists"));
    102 	case ERR_ACL_NOT_FOUND:
    103 		return ((char *)gettext("ACL list not found"));
    104 	case ERR_INIT_NOT_FOUND:
    105 		return ((char *)gettext("Initiator not found"));
    106 	case ERR_TARG_NOT_FOUND:
    107 		return ((char *)gettext("Target not found"));
    108 	case ERR_LUN_NOT_FOUND:
    109 		return ((char *)gettext("LUN not found"));
    110 	case ERR_TPGT_NOT_FOUND:
    111 		return ((char *)gettext("TPGT not found"));
    112 	case ERR_ACCESS_RAW_DEVICE_FAILED:
    113 		return ((char *)gettext("Failed to "
    114 		    "access a direct access device"));
    115 	case ERR_CREATE_METADATA_FAILED:
    116 		return ((char *)gettext("Failed to "
    117 		    "create meta data for tape device"));
    118 	case ERR_CREATE_SYMLINK_FAILED:
    119 		return ((char *)gettext("Failed to "
    120 		    "create a symbolic link to the backing store"));
    121 	case ERR_CREATE_NAME_TOO_LONG:
    122 		return ((char *)gettext("Name must be less than 166 "
    123 		    "characters"));
    124 	case ERR_NAME_TOO_LONG:
    125 		return ((char *)gettext("Name too long, must be less than 223 "
    126 		    "characters"));
    127 	case ERR_DISK_BACKING_SIZE_OR_FILE:
    128 		return ((char *)gettext("Size must be 0 if backing store "
    129 		    "exists"));
    130 	case ERR_DISK_BACKING_MUST_BE_REGULAR_FILE:
    131 		return ((char *)gettext("For type "
    132 		    "'disk' backing must be a regular file"));
    133 	case ERR_DISK_BACKING_NOT_VALID_RAW:
    134 		return ((char *)gettext("Backing store is not a valid raw "
    135 		    "device"));
    136 	case ERR_STAT_BACKING_FAILED:
    137 		return ((char *)gettext("Failed to "
    138 		    "stat(2) backing for 'disk'"));
    139 	case ERR_RAW_PART_NOT_CAP:
    140 		return ((char *)gettext("Partition size does not match capacity"
    141 		    " of device. Use p0 or ctd name"));
    142 	case ERR_CREATE_TARGET_DIR_FAILED:
    143 		return ((char *)gettext("Failed to "
    144 		    "create target directory"));
    145 	case ERR_ENCODE_GUID_FAILED:
    146 		return ((char *)gettext("Failed to encode GUID value"));
    147 	case ERR_INIT_XML_READER_FAILED:
    148 		return ((char *)gettext("Failed to initialize XML reader"));
    149 	case ERR_INVALID_XML_REQUEST:
    150 		return ((char *)gettext("Invalid characters in XML request"));
    151 	case ERR_OPEN_PARAM_FILE_FAILED:
    152 		return ((char *)gettext("Failed to open parameter file"));
    153 	case ERR_UPDATE_MAINCFG_FAILED:
    154 		return ((char *)gettext("Failed to "
    155 		    "update main configuration file"));
    156 	case ERR_UPDATE_TARGCFG_FAILED:
    157 		return ((char *)gettext("Failed to "
    158 		    "update target configuration file"));
    159 	case ERR_VALID_TARG_EXIST:
    160 		return ((char *)gettext("Valid targets "
    161 		    "exist under current base directory"));
    162 	case ERR_TARGCFG_MISSING_INAME:
    163 		return ((char *)gettext("Missing "
    164 		    "iscsi name in target configuration"));
    165 	case ERR_NO_MATCH:
    166 		return ((char *)gettext("No match"));
    167 	case ERR_NO_MEM:
    168 		return ((char *)gettext("Internal error: Out of memory"));
    169 	case ERR_LUN_ZERO_NOT_LAST:
    170 		return ((char *)gettext("LUN 0 must be the last one deleted"));
    171 	case ERR_LUN_ZERO_NOT_FIRST:
    172 		return ((char *)gettext("LUN 0 must exist before creating "
    173 		    "other LUNs"));
    174 	case ERR_SIZE_MOD_BLOCK:
    175 		return ((char *)gettext("Size must be multiple of 512"));
    176 	case ERR_CANT_SHRINK_LU:
    177 		return ((char *)gettext("Shrinking of LU is not supported"));
    178 	case ERR_RESIZE_WRONG_TYPE:
    179 		return ((char *)gettext("Backing store must be regular file"));
    180 	case ERR_RESIZE_WRONG_DTYPE:
    181 		return ((char *)gettext("Cannot resize 'raw' targets"));
    182 	case ERR_LUN_NOT_GROWN:
    183 		return ((char *)gettext("Failed to grow LU"));
    184 	case ERR_FILE_TOO_BIG:
    185 		return ((char *)gettext("Requested size is too large for "
    186 		    "system"));
    187 	case ERR_FAILED_TO_CREATE_LU:
    188 		return ((char *)gettext("Failed to create backing store"));
    189 	case ERR_INTERNAL_ERROR:
    190 		return ((char *)gettext("Internal error"));
    191 	case ERR_TAPE_NOT_SUPPORTED_IN_32BIT:
    192 		return ((char *)gettext("Tape emulation not supported in "
    193 		    "32-bit mode"));
    194 	case ERR_BAD_CREDS:
    195 		return ((char *)gettext("No credentials available from door"));
    196 	case ERR_NO_PERMISSION:
    197 		return ((char *)gettext("Permission denied"));
    198 	case ERR_INVALID_ISNS_SRV:
    199 		return ((char *)gettext("Invalid ISNS Server name"));
    200 	case ERR_ISNS_ERROR:
    201 		return ((char *)gettext("ISNS error"));
    202 	case ERR_TPGT_NO_IPADDR:
    203 		return ((char *)gettext("TPGT has no ip-addr"));
    204 	case ERR_TPGT_IN_USE:
    205 		return ((char *)gettext("Specified TPGT is in-use"));
    206 	case ERR_ZFS_ISCSISHARE_OFF:
    207 		return ((char *)gettext("ZFS shareiscsi property is off"));
    208 	default:
    209 		return ((char *)gettext("Internal error: unknown message"));
    210 	}
    211 }
    212