Print this page
1845 allow disable of UNMAP via stmfadm(1M).


  63 static int offlineLuFunc(int, char **, cmdOptions_t *, void *);
  64 static int onlineTargetFunc(int, char **, cmdOptions_t *, void *);
  65 static int onlineLuFunc(int, char **, cmdOptions_t *, void *);
  66 static int onlineOfflineTarget(char *, int);
  67 static int onlineOfflineLu(char *, int);
  68 static int removeHostGroupMemberFunc(int, char **, cmdOptions_t *, void *);
  69 static int removeTargetGroupMemberFunc(int, char **, cmdOptions_t *, void *);
  70 static int callModify(char *, stmfGuid *, uint32_t, const char *, const char *);
  71 static int removeViewFunc(int, char **, cmdOptions_t *, void *);
  72 static char *getExecBasename(char *);
  73 static int parseDevid(char *input, stmfDevid *devid);
  74 static void printGroupProps(stmfGroupProperties *groupProps);
  75 static int checkScsiNameString(wchar_t *, stmfDevid *);
  76 static int checkHexUpper(char *);
  77 static int checkIscsiName(wchar_t *);
  78 static void printLuProps(stmfLogicalUnitProperties *luProps);
  79 static int printExtLuProps(stmfGuid *guid);
  80 static void printGuid(stmfGuid *guid, FILE *printWhere);
  81 static void printTargetProps(stmfTargetProperties *);
  82 static void printSessionProps(stmfSessionList *);
  83 static int setLuPropFromInput(luResource, char *);
  84 static int convertCharToPropId(char *, uint32_t *);
  85 
  86 
  87 
  88 /*
  89  *  MAJOR - This should only change when there is an incompatible change made
  90  *  to the interfaces or the output.
  91  *
  92  *  MINOR - This should change whenever there is a new command or new feature
  93  *  with no incompatible change.
  94  */
  95 #define VERSION_STRING_MAJOR        "1"
  96 #define VERSION_STRING_MINOR        "0"
  97 #define MAX_DEVID_INPUT             256
  98 #define GUID_INPUT                  32
  99 #define MAX_LU_NBR                  16383
 100 #define ONLINE_LU                   0
 101 #define OFFLINE_LU                  1
 102 #define ONLINE_TARGET               2
 103 #define OFFLINE_TARGET              3


 113 #define SNS_EUI_24                  24
 114 #define SNS_EUI_32                  32
 115 #define SNS_NAA_16                  16
 116 #define SNS_NAA_32                  32
 117 #define SNS_WWN_16                  16
 118 #define SNS_IQN_223                 223
 119 
 120 /* LU Property strings */
 121 #define GUID                        "GUID"
 122 #define ALIAS                       "ALIAS"
 123 #define VID                         "VID"
 124 #define PID                         "PID"
 125 #define META_FILE                   "META"
 126 #define WRITE_PROTECT               "WP"
 127 #define WRITEBACK_CACHE_DISABLE     "WCD"
 128 #define COMPANY_ID                  "OUI"
 129 #define BLOCK_SIZE                  "BLK"
 130 #define SERIAL_NUMBER               "SERIAL"
 131 #define MGMT_URL                    "MGMT-URL"
 132 #define HOST_ID                     "HOST-ID"

 133 
 134 #define STMFADM_SUCCESS             0
 135 #define STMFADM_FAILURE             1
 136 
 137 #define MODIFY_HELP "\n"\
 138 "Description: Modify properties of a logical unit. \n" \
 139 "Valid properties for -p, --lu-prop are: \n" \
 140 "     alias    - alias for logical unit (up to 255 chars)\n" \
 141 "     mgmt-url - Management URL address\n" \

 142 "     wcd      - write cache disabled (true, false)\n" \
 143 "     wp       - write protect (true, false)\n\n" \
 144 "-f alters the meaning of the operand to be a file name\n" \
 145 "rather than a LU name. This allows for modification\n" \
 146 "of a logical unit that is not yet imported into stmf\n"
 147 
 148 #define CREATE_HELP "\n"\
 149 "Description: Create a logical unit. \n" \
 150 "Valid properties for -p, --lu-prop are: \n" \
 151 "     alias    - alias for logical unit (up to 255 chars)\n" \
 152 "     blk      - block size in bytes in 2^n\n" \
 153 "     guid     - 32 ascii hex characters in NAA format \n" \
 154 "     host-id  - host identifier to be used for GUID generation \n" \
 155 "                8 ascii hex characters\n" \
 156 "     meta     - separate meta data file name\n" \
 157 "     mgmt-url - Management URL address\n" \
 158 "     oui      - organizational unique identifier\n" \
 159 "                6 ascii hex characters of valid format\n" \
 160 "     pid      - product identifier (up to 16 chars)\n" \
 161 "     serial   - serial number (up to 252 chars)\n" \

 162 "     vid      - vendor identifier (up to 8 chars)\n" \
 163 "     wcd      - write cache disabled (true, false)\n" \
 164 "     wp       - write protect (true, false)\n"
 165 #define ADD_VIEW_HELP "\n"\
 166 "Description: Add a view entry to a logical unit. \n" \
 167 "A view entry is comprised of three elements; the \n" \
 168 "logical unit number, the target group name and the\n" \
 169 "host group name. These three elements combine together\n" \
 170 "to form a view for a given COMSTAR logical unit.\n" \
 171 "This view is realized by a client, a SCSI initiator,\n" \
 172 "via a REPORT LUNS command. \n"
 173 
 174 
 175 
 176 /* tables set up based on cmdparse instructions */
 177 
 178 /* add new options here */
 179 optionTbl_t longOptions[] = {
 180         {"all", no_arg, 'a', NULL},
 181         {"group-name", required_arg, 'g', "group-name"},


 797 
 798         return (ret);
 799 }
 800 
 801 /*
 802  * createLuFunc
 803  *
 804  * Create a logical unit
 805  *
 806  */
 807 /*ARGSUSED*/
 808 static int
 809 createLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
 810     void *args)
 811 {
 812         luResource hdl = NULL;
 813         int ret = 0;
 814         int stmfRet = 0;
 815         char guidAsciiBuf[33];
 816         stmfGuid createdGuid;


 817 
 818         stmfRet = stmfCreateLuResource(STMF_DISK, &hdl);
 819 
 820         if (stmfRet != STMF_STATUS_SUCCESS) {
 821                 (void) fprintf(stderr, "%s: %s\n",
 822                     cmdName, gettext("Failure to create lu resource\n"));
 823                 return (1);
 824         }
 825 
 826         for (; options->optval; options++) {
 827                 switch (options->optval) {
 828                         case 'p':
 829                                 ret = setLuPropFromInput(hdl, options->optarg);



 830                                 if (ret != 0) {
 831                                         (void) stmfFreeLuResource(hdl);
 832                                         return (1);
 833                                 }
 834                                 break;
 835                         case 's':
 836                                 stmfRet = stmfSetLuProp(hdl, STMF_LU_PROP_SIZE,
 837                                     options->optarg);
 838                                 if (stmfRet != STMF_STATUS_SUCCESS) {
 839                                         (void) fprintf(stderr, "%s: %c: %s\n",
 840                                             cmdName, options->optval,
 841                                             gettext("size param invalid"));
 842                                         (void) stmfFreeLuResource(hdl);
 843                                         return (1);
 844                                 }
 845                                 break;
 846                         default:
 847                                 (void) fprintf(stderr, "%s: %c: %s\n",
 848                                     cmdName, options->optval,
 849                                     gettext("unknown option"));
 850                                 return (1);
 851                 }
 852         }
 853 













 854         stmfRet = stmfSetLuProp(hdl, STMF_LU_PROP_FILENAME, operands[0]);
 855 
 856         if (stmfRet != STMF_STATUS_SUCCESS) {
 857                 (void) fprintf(stderr, "%s: %s\n",
 858                     cmdName, gettext("could not set filename"));
 859                 return (1);
 860         }
 861 
 862         stmfRet = stmfCreateLu(hdl, &createdGuid);
 863         switch (stmfRet) {
 864                 case STMF_STATUS_SUCCESS:
 865                         break;
 866                 case STMF_ERROR_BUSY:
 867                 case STMF_ERROR_LU_BUSY:
 868                         (void) fprintf(stderr, "%s: %s\n", cmdName,
 869                             gettext("resource busy"));
 870                         ret++;
 871                         break;
 872                 case STMF_ERROR_PERM:
 873                         (void) fprintf(stderr, "%s: %s\n", cmdName,


1216         if (ret != STMF_STATUS_SUCCESS) {
1217                 goto done;
1218         }
1219 
1220         (void) snprintf(guidAsciiBuf, sizeof (guidAsciiBuf),
1221             "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
1222             "%02X%02X%02X%02X%02X%02X",
1223             createdGuid.guid[0], createdGuid.guid[1], createdGuid.guid[2],
1224             createdGuid.guid[3], createdGuid.guid[4], createdGuid.guid[5],
1225             createdGuid.guid[6], createdGuid.guid[7], createdGuid.guid[8],
1226             createdGuid.guid[9], createdGuid.guid[10], createdGuid.guid[11],
1227             createdGuid.guid[12], createdGuid.guid[13], createdGuid.guid[14],
1228             createdGuid.guid[15]);
1229         (void) printf("Logical unit imported: %s\n", guidAsciiBuf);
1230 
1231 done:
1232         return (ret);
1233 }
1234 
1235 static int
1236 setLuPropFromInput(luResource hdl, char *optarg)
1237 {
1238         char *prop = NULL;
1239         char *propVal = NULL;
1240         char *lasts = NULL;
1241         uint32_t propId;
1242         int ret = 0;
1243 
1244         prop = strtok_r(optarg, "=", &lasts);
1245         if ((propVal = strtok_r(NULL, "=", &lasts)) == NULL) {
1246                 (void) fprintf(stderr, "%s: %s: %s\n",
1247                     cmdName, optarg,
1248                     gettext("invalid property specifier - prop=val\n"));
1249                 return (1);
1250         }
1251 
1252         ret = convertCharToPropId(prop, &propId);
1253         if (ret != 0) {
1254                 (void) fprintf(stderr, "%s: %s: %s\n",
1255                     cmdName, gettext("invalid property specified"), prop);
1256                 return (1);
1257         }
1258 
1259         ret = stmfSetLuProp(hdl, propId, propVal);
1260         if (ret != STMF_STATUS_SUCCESS) {
1261                 (void) fprintf(stderr, "%s: %s %s: ",
1262                     cmdName, gettext("unable to set"), prop);
1263                 switch (ret) {
1264                         case STMF_ERROR_INVALID_PROPSIZE:
1265                                 (void) fprintf(stderr, "invalid length\n");
1266                                 break;
1267                         case STMF_ERROR_INVALID_ARG:
1268                                 (void) fprintf(stderr, "bad format\n");
1269                                 break;
1270                         default:
1271                                 (void) fprintf(stderr, "\n");
1272                                 break;
1273                 }
1274                 return (1);
1275         }
1276 
1277         return (0);
1278 }
1279 


1287         } else if (strcasecmp(prop, VID) == 0) {
1288                 *propId = STMF_LU_PROP_VID;
1289         } else if (strcasecmp(prop, PID) == 0) {
1290                 *propId = STMF_LU_PROP_PID;
1291         } else if (strcasecmp(prop, WRITE_PROTECT) == 0) {
1292                 *propId = STMF_LU_PROP_WRITE_PROTECT;
1293         } else if (strcasecmp(prop, WRITEBACK_CACHE_DISABLE) == 0) {
1294                 *propId = STMF_LU_PROP_WRITE_CACHE_DISABLE;
1295         } else if (strcasecmp(prop, BLOCK_SIZE) == 0) {
1296                 *propId = STMF_LU_PROP_BLOCK_SIZE;
1297         } else if (strcasecmp(prop, SERIAL_NUMBER) == 0) {
1298                 *propId = STMF_LU_PROP_SERIAL_NUM;
1299         } else if (strcasecmp(prop, COMPANY_ID) == 0) {
1300                 *propId = STMF_LU_PROP_COMPANY_ID;
1301         } else if (strcasecmp(prop, META_FILE) == 0) {
1302                 *propId = STMF_LU_PROP_META_FILENAME;
1303         } else if (strcasecmp(prop, MGMT_URL) == 0) {
1304                 *propId = STMF_LU_PROP_MGMT_URL;
1305         } else if (strcasecmp(prop, HOST_ID) == 0) {
1306                 *propId = STMF_LU_PROP_HOST_ID;


1307         } else {
1308                 return (1);
1309         }
1310         return (0);
1311 }
1312 
1313 /*
1314  * deleteLuFunc
1315  *
1316  * Delete a logical unit
1317  *
1318  */
1319 /*ARGSUSED*/
1320 static int
1321 deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
1322     void *args)
1323 {
1324         int i, j;
1325         int ret = 0;
1326         int stmfRet;


2201         if (stmfRet == STMF_STATUS_SUCCESS) {
2202                 (void) printf("%s\n",
2203                     strcasecmp(propVal, "true") ? "Disabled" : "Enabled");
2204         } else if (stmfRet == STMF_ERROR_NO_PROP) {
2205                 (void) printf("not set\n");
2206         } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
2207                 (void) printf("prop unavailable in standby\n");
2208         } else {
2209                 (void) printf("<error retrieving property>\n");
2210                 ret++;
2211         }
2212 
2213         stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_WRITE_CACHE_DISABLE, propVal,
2214             &propValSize);
2215         (void) printf(PROPS_FORMAT, "Writeback Cache");
2216         if (stmfRet == STMF_STATUS_SUCCESS) {
2217                 (void) printf("%s\n",
2218                     strcasecmp(propVal, "true") ? "Enabled" : "Disabled");
2219         } else if (stmfRet == STMF_ERROR_NO_PROP) {
2220                 (void) printf("not set\n");















2221         } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
2222                 (void) printf("prop unavailable in standby\n");
2223         } else {
2224                 (void) printf("<error retrieving property>\n");
2225                 ret++;
2226         }
2227 
2228         stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_ACCESS_STATE, propVal,
2229             &propValSize);
2230         (void) printf(PROPS_FORMAT, "Access State");
2231         if (stmfRet == STMF_STATUS_SUCCESS) {
2232                 if (strcmp(propVal, STMF_ACCESS_ACTIVE) == 0) {
2233                         (void) printf("%s\n", "Active");
2234                 } else if (strcmp(propVal,
2235                     STMF_ACCESS_ACTIVE_TO_STANDBY) == 0) {
2236                         (void) printf("%s\n", "Active->Standby");
2237                 } else if (strcmp(propVal, STMF_ACCESS_STANDBY) == 0) {
2238                         (void) printf("%s\n", "Standby");
2239                 } else if (strcmp(propVal,
2240                     STMF_ACCESS_STANDBY_TO_ACTIVE) == 0) {




  63 static int offlineLuFunc(int, char **, cmdOptions_t *, void *);
  64 static int onlineTargetFunc(int, char **, cmdOptions_t *, void *);
  65 static int onlineLuFunc(int, char **, cmdOptions_t *, void *);
  66 static int onlineOfflineTarget(char *, int);
  67 static int onlineOfflineLu(char *, int);
  68 static int removeHostGroupMemberFunc(int, char **, cmdOptions_t *, void *);
  69 static int removeTargetGroupMemberFunc(int, char **, cmdOptions_t *, void *);
  70 static int callModify(char *, stmfGuid *, uint32_t, const char *, const char *);
  71 static int removeViewFunc(int, char **, cmdOptions_t *, void *);
  72 static char *getExecBasename(char *);
  73 static int parseDevid(char *input, stmfDevid *devid);
  74 static void printGroupProps(stmfGroupProperties *groupProps);
  75 static int checkScsiNameString(wchar_t *, stmfDevid *);
  76 static int checkHexUpper(char *);
  77 static int checkIscsiName(wchar_t *);
  78 static void printLuProps(stmfLogicalUnitProperties *luProps);
  79 static int printExtLuProps(stmfGuid *guid);
  80 static void printGuid(stmfGuid *guid, FILE *printWhere);
  81 static void printTargetProps(stmfTargetProperties *);
  82 static void printSessionProps(stmfSessionList *);
  83 static int setLuPropFromInput(luResource, char *, uint32_t *);
  84 static int convertCharToPropId(char *, uint32_t *);
  85 
  86 
  87 
  88 /*
  89  *  MAJOR - This should only change when there is an incompatible change made
  90  *  to the interfaces or the output.
  91  *
  92  *  MINOR - This should change whenever there is a new command or new feature
  93  *  with no incompatible change.
  94  */
  95 #define VERSION_STRING_MAJOR        "1"
  96 #define VERSION_STRING_MINOR        "0"
  97 #define MAX_DEVID_INPUT             256
  98 #define GUID_INPUT                  32
  99 #define MAX_LU_NBR                  16383
 100 #define ONLINE_LU                   0
 101 #define OFFLINE_LU                  1
 102 #define ONLINE_TARGET               2
 103 #define OFFLINE_TARGET              3


 113 #define SNS_EUI_24                  24
 114 #define SNS_EUI_32                  32
 115 #define SNS_NAA_16                  16
 116 #define SNS_NAA_32                  32
 117 #define SNS_WWN_16                  16
 118 #define SNS_IQN_223                 223
 119 
 120 /* LU Property strings */
 121 #define GUID                        "GUID"
 122 #define ALIAS                       "ALIAS"
 123 #define VID                         "VID"
 124 #define PID                         "PID"
 125 #define META_FILE                   "META"
 126 #define WRITE_PROTECT               "WP"
 127 #define WRITEBACK_CACHE_DISABLE     "WCD"
 128 #define COMPANY_ID                  "OUI"
 129 #define BLOCK_SIZE                  "BLK"
 130 #define SERIAL_NUMBER               "SERIAL"
 131 #define MGMT_URL                    "MGMT-URL"
 132 #define HOST_ID                     "HOST-ID"
 133 #define UNMAP                       "UNMAP"
 134 
 135 #define STMFADM_SUCCESS             0
 136 #define STMFADM_FAILURE             1
 137 
 138 #define MODIFY_HELP "\n"\
 139 "Description: Modify properties of a logical unit. \n" \
 140 "Valid properties for -p, --lu-prop are: \n" \
 141 "     alias    - alias for logical unit (up to 255 chars)\n" \
 142 "     mgmt-url - Management URL address\n" \
 143 "     unmap    - iSCSI UNMAP enabled (true, false)\n" \
 144 "     wcd      - write cache disabled (true, false)\n" \
 145 "     wp       - write protect (true, false)\n\n" \
 146 "-f alters the meaning of the operand to be a file name\n" \
 147 "rather than a LU name. This allows for modification\n" \
 148 "of a logical unit that is not yet imported into stmf\n"
 149 
 150 #define CREATE_HELP "\n"\
 151 "Description: Create a logical unit. \n" \
 152 "Valid properties for -p, --lu-prop are: \n" \
 153 "     alias    - alias for logical unit (up to 255 chars)\n" \
 154 "     blk      - block size in bytes in 2^n\n" \
 155 "     guid     - 32 ascii hex characters in NAA format \n" \
 156 "     host-id  - host identifier to be used for GUID generation \n" \
 157 "                8 ascii hex characters\n" \
 158 "     meta     - separate meta data file name\n" \
 159 "     mgmt-url - Management URL address\n" \
 160 "     oui      - organizational unique identifier\n" \
 161 "                6 ascii hex characters of valid format\n" \
 162 "     pid      - product identifier (up to 16 chars)\n" \
 163 "     serial   - serial number (up to 252 chars)\n" \
 164 "     unmap    - iSCSI UNMAP enabled (true, false)\n" \
 165 "     vid      - vendor identifier (up to 8 chars)\n" \
 166 "     wcd      - write cache disabled (true, false)\n" \
 167 "     wp       - write protect (true, false)\n"
 168 #define ADD_VIEW_HELP "\n"\
 169 "Description: Add a view entry to a logical unit. \n" \
 170 "A view entry is comprised of three elements; the \n" \
 171 "logical unit number, the target group name and the\n" \
 172 "host group name. These three elements combine together\n" \
 173 "to form a view for a given COMSTAR logical unit.\n" \
 174 "This view is realized by a client, a SCSI initiator,\n" \
 175 "via a REPORT LUNS command. \n"
 176 
 177 
 178 
 179 /* tables set up based on cmdparse instructions */
 180 
 181 /* add new options here */
 182 optionTbl_t longOptions[] = {
 183         {"all", no_arg, 'a', NULL},
 184         {"group-name", required_arg, 'g', "group-name"},


 800 
 801         return (ret);
 802 }
 803 
 804 /*
 805  * createLuFunc
 806  *
 807  * Create a logical unit
 808  *
 809  */
 810 /*ARGSUSED*/
 811 static int
 812 createLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
 813     void *args)
 814 {
 815         luResource hdl = NULL;
 816         int ret = 0;
 817         int stmfRet = 0;
 818         char guidAsciiBuf[33];
 819         stmfGuid createdGuid;
 820         uint32_t propid;
 821         boolean_t unmap_not_set = B_TRUE;
 822 
 823         stmfRet = stmfCreateLuResource(STMF_DISK, &hdl);
 824 
 825         if (stmfRet != STMF_STATUS_SUCCESS) {
 826                 (void) fprintf(stderr, "%s: %s\n",
 827                     cmdName, gettext("Failure to create lu resource\n"));
 828                 return (1);
 829         }
 830 
 831         for (; options->optval; options++) {
 832                 switch (options->optval) {
 833                         case 'p':
 834                                 ret = setLuPropFromInput(hdl, options->optarg,
 835                                     &propid);
 836                                 if (propid == STMF_LU_PROP_UNMAP)
 837                                         unmap_not_set = B_FALSE;
 838                                 if (ret != 0) {
 839                                         (void) stmfFreeLuResource(hdl);
 840                                         return (1);
 841                                 }
 842                                 break;
 843                         case 's':
 844                                 stmfRet = stmfSetLuProp(hdl, STMF_LU_PROP_SIZE,
 845                                     options->optarg);
 846                                 if (stmfRet != STMF_STATUS_SUCCESS) {
 847                                         (void) fprintf(stderr, "%s: %c: %s\n",
 848                                             cmdName, options->optval,
 849                                             gettext("size param invalid"));
 850                                         (void) stmfFreeLuResource(hdl);
 851                                         return (1);
 852                                 }
 853                                 break;
 854                         default:
 855                                 (void) fprintf(stderr, "%s: %c: %s\n",
 856                                     cmdName, options->optval,
 857                                     gettext("unknown option"));
 858                                 return (1);
 859                 }
 860         }
 861 
 862         if (unmap_not_set) {
 863                 /*
 864                  * We "enable" unmap by default, but STMF is hostile toward
 865                  * enable-by-default, so we enable it here if it hasn't
 866                  * already been set.
 867                  */
 868                 if (stmfSetLuProp(hdl, STMF_LU_PROP_UNMAP, "true") !=
 869                     STMF_STATUS_SUCCESS) {
 870                         fprintf(stderr, "%s: %s\n", cmdName,
 871                             gettext("Problems setting UNMAP default"));
 872                 }
 873         }
 874 
 875         stmfRet = stmfSetLuProp(hdl, STMF_LU_PROP_FILENAME, operands[0]);
 876 
 877         if (stmfRet != STMF_STATUS_SUCCESS) {
 878                 (void) fprintf(stderr, "%s: %s\n",
 879                     cmdName, gettext("could not set filename"));
 880                 return (1);
 881         }
 882 
 883         stmfRet = stmfCreateLu(hdl, &createdGuid);
 884         switch (stmfRet) {
 885                 case STMF_STATUS_SUCCESS:
 886                         break;
 887                 case STMF_ERROR_BUSY:
 888                 case STMF_ERROR_LU_BUSY:
 889                         (void) fprintf(stderr, "%s: %s\n", cmdName,
 890                             gettext("resource busy"));
 891                         ret++;
 892                         break;
 893                 case STMF_ERROR_PERM:
 894                         (void) fprintf(stderr, "%s: %s\n", cmdName,


1237         if (ret != STMF_STATUS_SUCCESS) {
1238                 goto done;
1239         }
1240 
1241         (void) snprintf(guidAsciiBuf, sizeof (guidAsciiBuf),
1242             "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
1243             "%02X%02X%02X%02X%02X%02X",
1244             createdGuid.guid[0], createdGuid.guid[1], createdGuid.guid[2],
1245             createdGuid.guid[3], createdGuid.guid[4], createdGuid.guid[5],
1246             createdGuid.guid[6], createdGuid.guid[7], createdGuid.guid[8],
1247             createdGuid.guid[9], createdGuid.guid[10], createdGuid.guid[11],
1248             createdGuid.guid[12], createdGuid.guid[13], createdGuid.guid[14],
1249             createdGuid.guid[15]);
1250         (void) printf("Logical unit imported: %s\n", guidAsciiBuf);
1251 
1252 done:
1253         return (ret);
1254 }
1255 
1256 static int
1257 setLuPropFromInput(luResource hdl, char *optarg, uint32_t *propId)
1258 {
1259         char *prop = NULL;
1260         char *propVal = NULL;
1261         char *lasts = NULL;

1262         int ret = 0;
1263 
1264         prop = strtok_r(optarg, "=", &lasts);
1265         if ((propVal = strtok_r(NULL, "=", &lasts)) == NULL) {
1266                 (void) fprintf(stderr, "%s: %s: %s\n",
1267                     cmdName, optarg,
1268                     gettext("invalid property specifier - prop=val\n"));
1269                 return (1);
1270         }
1271 
1272         ret = convertCharToPropId(prop, propId);
1273         if (ret != 0) {
1274                 (void) fprintf(stderr, "%s: %s: %s\n",
1275                     cmdName, gettext("invalid property specified"), prop);
1276                 return (1);
1277         }
1278 
1279         ret = stmfSetLuProp(hdl, *propId, propVal);
1280         if (ret != STMF_STATUS_SUCCESS) {
1281                 (void) fprintf(stderr, "%s: %s %s: ",
1282                     cmdName, gettext("unable to set"), prop);
1283                 switch (ret) {
1284                         case STMF_ERROR_INVALID_PROPSIZE:
1285                                 (void) fprintf(stderr, "invalid length\n");
1286                                 break;
1287                         case STMF_ERROR_INVALID_ARG:
1288                                 (void) fprintf(stderr, "bad format\n");
1289                                 break;
1290                         default:
1291                                 (void) fprintf(stderr, "\n");
1292                                 break;
1293                 }
1294                 return (1);
1295         }
1296 
1297         return (0);
1298 }
1299 


1307         } else if (strcasecmp(prop, VID) == 0) {
1308                 *propId = STMF_LU_PROP_VID;
1309         } else if (strcasecmp(prop, PID) == 0) {
1310                 *propId = STMF_LU_PROP_PID;
1311         } else if (strcasecmp(prop, WRITE_PROTECT) == 0) {
1312                 *propId = STMF_LU_PROP_WRITE_PROTECT;
1313         } else if (strcasecmp(prop, WRITEBACK_CACHE_DISABLE) == 0) {
1314                 *propId = STMF_LU_PROP_WRITE_CACHE_DISABLE;
1315         } else if (strcasecmp(prop, BLOCK_SIZE) == 0) {
1316                 *propId = STMF_LU_PROP_BLOCK_SIZE;
1317         } else if (strcasecmp(prop, SERIAL_NUMBER) == 0) {
1318                 *propId = STMF_LU_PROP_SERIAL_NUM;
1319         } else if (strcasecmp(prop, COMPANY_ID) == 0) {
1320                 *propId = STMF_LU_PROP_COMPANY_ID;
1321         } else if (strcasecmp(prop, META_FILE) == 0) {
1322                 *propId = STMF_LU_PROP_META_FILENAME;
1323         } else if (strcasecmp(prop, MGMT_URL) == 0) {
1324                 *propId = STMF_LU_PROP_MGMT_URL;
1325         } else if (strcasecmp(prop, HOST_ID) == 0) {
1326                 *propId = STMF_LU_PROP_HOST_ID;
1327         } else if (strcasecmp(prop, UNMAP) == 0) {
1328                 *propId = STMF_LU_PROP_UNMAP;
1329         } else {
1330                 return (1);
1331         }
1332         return (0);
1333 }
1334 
1335 /*
1336  * deleteLuFunc
1337  *
1338  * Delete a logical unit
1339  *
1340  */
1341 /*ARGSUSED*/
1342 static int
1343 deleteLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
1344     void *args)
1345 {
1346         int i, j;
1347         int ret = 0;
1348         int stmfRet;


2223         if (stmfRet == STMF_STATUS_SUCCESS) {
2224                 (void) printf("%s\n",
2225                     strcasecmp(propVal, "true") ? "Disabled" : "Enabled");
2226         } else if (stmfRet == STMF_ERROR_NO_PROP) {
2227                 (void) printf("not set\n");
2228         } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
2229                 (void) printf("prop unavailable in standby\n");
2230         } else {
2231                 (void) printf("<error retrieving property>\n");
2232                 ret++;
2233         }
2234 
2235         stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_WRITE_CACHE_DISABLE, propVal,
2236             &propValSize);
2237         (void) printf(PROPS_FORMAT, "Writeback Cache");
2238         if (stmfRet == STMF_STATUS_SUCCESS) {
2239                 (void) printf("%s\n",
2240                     strcasecmp(propVal, "true") ? "Enabled" : "Disabled");
2241         } else if (stmfRet == STMF_ERROR_NO_PROP) {
2242                 (void) printf("not set\n");
2243         } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
2244                 (void) printf("prop unavailable in standby\n");
2245         } else {
2246                 (void) printf("<error retrieving property>\n");
2247                 ret++;
2248         }
2249 
2250         stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_UNMAP, propVal,
2251             &propValSize);
2252         (void) printf(PROPS_FORMAT, "UNMAP support");
2253         if (stmfRet == STMF_STATUS_SUCCESS) {
2254                 (void) printf("%s\n", (strcasecmp(propVal, "true") == 0) ?
2255                     "Enabled" : "Disabled");
2256         } else if (stmfRet == STMF_ERROR_NO_PROP) {
2257                 (void) printf("not set\n");
2258         } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
2259                 (void) printf("prop unavailable in standby\n");
2260         } else {
2261                 (void) printf("<error retrieving property>\n");
2262                 ret++;
2263         }
2264 
2265         stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_ACCESS_STATE, propVal,
2266             &propValSize);
2267         (void) printf(PROPS_FORMAT, "Access State");
2268         if (stmfRet == STMF_STATUS_SUCCESS) {
2269                 if (strcmp(propVal, STMF_ACCESS_ACTIVE) == 0) {
2270                         (void) printf("%s\n", "Active");
2271                 } else if (strcmp(propVal,
2272                     STMF_ACCESS_ACTIVE_TO_STANDBY) == 0) {
2273                         (void) printf("%s\n", "Active->Standby");
2274                 } else if (strcmp(propVal, STMF_ACCESS_STANDBY) == 0) {
2275                         (void) printf("%s\n", "Standby");
2276                 } else if (strcmp(propVal,
2277                     STMF_ACCESS_STANDBY_TO_ACTIVE) == 0) {