fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
33f5ff17089e3a43e6e730bf80384c233123dbd9Milan Jurik * Copyright 2012 Milan Jurik. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libintl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <assert.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <getopt.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ctype.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libnvpair.h>
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#include <locale.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <cmdparse.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stmf_defines.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libstmf.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stmf_sbd_ioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MAX_LU_LIST 8192
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LU_LIST_MAX_RETRIES 3
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define GUID_INPUT 32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define VERSION_STRING_MAJOR "1"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define VERSION_STRING_MINOR "0"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto#define VERSION_STRING_MAX_LEN 10
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetochar *cmdName;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic char *getExecBasename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint delete_lu(int argc, char *argv[], cmdOptions_t *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *callData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint create_lu(int argc, char *argv[], cmdOptions_t *options, void *callData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint list_lus(int argc, char *argv[], cmdOptions_t *options, void *callData);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint modify_lu(int argc, char *argv[], cmdOptions_t *options, void *callData);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoint import_lu(int argc, char *argv[], cmdOptions_t *options, void *callData);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int callModify(char *, stmfGuid *, uint32_t, const char *, const char *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoint print_lu_attr(stmfGuid *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid print_guid(uint8_t *g, FILE *f);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid print_attr_header();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteoptionTbl_t options[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "disk-size", required_argument, 's',
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Size with <none>/k/m/g/t/p/e modifier" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "keep-views", no_arg, 'k',
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Dont delete view entries related to the LU" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL, 0, 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortesubCommandProps_t subCommands[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "create-lu", create_lu, "s", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_MANDATORY_SINGLE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Full path of the file to initialize" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "delete-lu", delete_lu, "k", NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_MANDATORY_SINGLE, "GUID of the LU to deregister" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "import-lu", import_lu, NULL, NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_MANDATORY_SINGLE, "filename of the LU to import" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "list-lu", list_lus, NULL, NULL, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_NONE, "List all the exported LUs" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "modify-lu", modify_lu, "s", "s", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPERAND_MANDATORY_SINGLE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Full path of the LU or GUID of a registered LU" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL, 0, 0, NULL, 0, NULL}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetocreate_lu(int argc, char *operands[], cmdOptions_t *options, void *callData)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto luResource hdl = NULL;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int ret = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfGuid createdGuid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = stmfCreateLuResource(STMF_DISK, &hdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName, gettext("Failure to create lu resource\n"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (; options->optval; options++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto switch (options->optval) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case 's':
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = stmfSetLuProp(hdl, STMF_LU_PROP_SIZE,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto options->optarg);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %c: %s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName, options->optval,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("size param invalid"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) stmfFreeLuResource(hdl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %c: %s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName, options->optval,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("unknown option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = stmfSetLuProp(hdl, STMF_LU_PROP_FILENAME, operands[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName, gettext("could not set filename"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = stmfCreateLu(hdl, &createdGuid);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto switch (ret) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_STATUS_SUCCESS:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_LU_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("resource busy"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_PERM:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("permission denied"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_FILE_IN_USE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: filename %s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto operands[0], gettext("in use"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_INVALID_BLKSIZE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("invalid block size"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_GUID_IN_USE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("guid in use"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_META_FILE_NAME:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("meta file error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_DATA_FILE_NAME:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("data file error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_SIZE_OUT_OF_RANGE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("invalid size"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_META_CREATION:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("could not create meta file"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("unknown error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) printf("Created the following LU:\n");
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto print_attr_header();
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = print_lu_attr(&createdGuid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetodone:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) stmfFreeLuResource(hdl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoimport_lu(int argc, char *operands[], cmdOptions_t *options, void *callData)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfGuid createdGuid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = stmfImportLu(STMF_DISK, operands[0], &createdGuid);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto switch (ret) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_STATUS_SUCCESS:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_LU_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("resource busy"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_PERM:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("permission denied"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_FILE_IN_USE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: filename %s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto operands[0], gettext("in use"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_GUID_IN_USE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("guid in use"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_META_FILE_NAME:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("meta file error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_DATA_FILE_NAME:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("data file error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_SIZE_OUT_OF_RANGE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("invalid size"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_META_CREATION:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("could not create meta file"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("unknown error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) printf("Imported the following LU:\n");
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto print_attr_header();
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = print_lu_attr(&createdGuid);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetodone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetodelete_lu(int operandLen, char *operands[], cmdOptions_t *options,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto void *callData)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int i, j;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int ret = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int stmfRet;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto unsigned int inGuid[sizeof (stmfGuid)];
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfGuid delGuid;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto boolean_t keepViews = B_FALSE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto boolean_t viewEntriesRemoved = B_FALSE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto boolean_t noLunFound = B_FALSE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto boolean_t views = B_FALSE;
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli boolean_t notValidHexNumber = B_FALSE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto char sGuid[GUID_INPUT + 1];
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfViewEntryList *viewEntryList = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (; options->optval; options++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (options->optval) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* Keep views for logical unit */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case 'k':
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto keepViews = B_TRUE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %c: %s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName, options->optval,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("unknown option"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < operandLen; i++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (j = 0; j < GUID_INPUT; j++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (!isxdigit(operands[i][j])) {
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli notValidHexNumber = B_TRUE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli sGuid[j] = tolower(operands[i][j]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli if ((notValidHexNumber == B_TRUE) ||
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli (strlen(operands[i]) != GUID_INPUT)) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s: %s%d%s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName, operands[i], gettext("must be "),
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto GUID_INPUT,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext(" hexadecimal digits long"));
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli notValidHexNumber = B_FALSE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sGuid[j] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) sscanf(sGuid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &inGuid[0], &inGuid[1], &inGuid[2], &inGuid[3],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &inGuid[4], &inGuid[5], &inGuid[6], &inGuid[7],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &inGuid[8], &inGuid[9], &inGuid[10], &inGuid[11],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &inGuid[12], &inGuid[13], &inGuid[14], &inGuid[15]);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (j = 0; j < sizeof (stmfGuid); j++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto delGuid.guid[j] = inGuid[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfDeleteLu(&delGuid);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto switch (stmfRet) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_STATUS_SUCCESS:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_NOT_FOUND:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto noLunFound = B_TRUE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("resource busy"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_PERM:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("permission denied"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("unknown error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (!keepViews) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfGetViewEntryList(&delGuid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &viewEntryList);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfRet == STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (j = 0; j < viewEntryList->cnt; j++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) stmfRemoveViewEntry(&delGuid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto viewEntryList->ve[j].veIndex);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli /* check if viewEntryList is empty */
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli if (viewEntryList->cnt != 0)
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli viewEntriesRemoved = B_TRUE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfFreeMemory(viewEntryList);
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli } else {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("unable to remove view entries\n"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
7b506e25917c371db526f76d85b9b1d17c8c5d39srivijitha dugganapalli }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (keepViews) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfGetViewEntryList(&delGuid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &viewEntryList);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfRet == STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto views = B_TRUE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfFreeMemory(viewEntryList);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((!viewEntriesRemoved && noLunFound && !views) ||
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (!views && keepViews && noLunFound)) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s: %s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName, sGuid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("not found"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto noLunFound = viewEntriesRemoved = views = B_FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetomodify_lu(int operandLen, char *operands[], cmdOptions_t *options,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto void *callData)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfGuid inGuid;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto unsigned int guid[sizeof (stmfGuid)];
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int ret = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int i;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto char *fname = NULL;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto char sGuid[GUID_INPUT + 1];
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto boolean_t fnameUsed = B_FALSE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (operands[0][0] == '/') {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto fnameUsed = B_TRUE;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto fname = operands[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* check input length */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (!fnameUsed && strlen(operands[0]) != GUID_INPUT) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s: %s%d%s\n", cmdName, operands[0],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("must be "), GUID_INPUT,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext(" hexadecimal digits"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (!fnameUsed) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* convert to lower case for scan */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < 32; i++)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sGuid[i] = tolower(operands[0][i]);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sGuid[i] = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) sscanf(sGuid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &guid[0], &guid[1], &guid[2], &guid[3], &guid[4], &guid[5],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &guid[6], &guid[7], &guid[8], &guid[9], &guid[10],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &guid[11], &guid[12], &guid[13], &guid[14], &guid[15]);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < sizeof (stmfGuid); i++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto inGuid.guid[i] = guid[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (; options->optval; options++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto switch (options->optval) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case 's':
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (callModify(fname, &inGuid,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto STMF_LU_PROP_SIZE, options->optarg,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto "size") != 0) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %c: %s\n",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName, options->optval,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("unknown option"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (ret);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto}
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetocallModify(char *fname, stmfGuid *luGuid, uint32_t prop, const char *propVal,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto const char *propString)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int ret = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int stmfRet = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (!fname) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfModifyLu(luGuid, prop, propVal);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfModifyLuByFname(STMF_DISK, fname, prop,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto propVal);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto switch (stmfRet) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_STATUS_SUCCESS:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_LU_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("resource busy"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_PERM:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("permission denied"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_INVALID_BLKSIZE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("invalid block size"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_GUID_IN_USE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("guid in use"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_META_FILE_NAME:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("meta file error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_DATA_FILE_NAME:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("data file error"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_FILE_SIZE_INVALID:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("file size invalid"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_SIZE_OUT_OF_RANGE:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("invalid size"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_META_CREATION:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("could not create meta file"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s: %s: %d\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("could not set property"), propString,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortelist_lus(int argc, char *argv[], cmdOptions_t *options, void *callData)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int stmfRet;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfGuidList *luList;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfLogicalUnitProperties luProps;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int sbdLuCnt = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((stmfRet = stmfGetLogicalUnitList(&luList))
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto switch (stmfRet) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_SERVICE_NOT_FOUND:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("STMF service not found"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("resource busy"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_PERM:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("permission denied"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_SERVICE_DATA_VERSION:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("STMF service version incorrect"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("list failed"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < luList->cnt; i++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfGetLogicalUnitProperties(&luList->guid[i],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &luProps);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfRet != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("list failed"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (strcmp(luProps.providerName, "sbd") == 0) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto sbdLuCnt++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (sbdLuCnt == 0)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (0);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) printf("\nFound %d LU(s)\n", sbdLuCnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_attr_header();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (i = 0; i < luList->cnt; i++) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfGetLogicalUnitProperties(&luList->guid[i],
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &luProps);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfRet != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("list failed"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (strcmp(luProps.providerName, "sbd") == 0) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) print_lu_attr(&luList->guid[i]);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_attr_header()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" GUID DATA SIZE "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " SOURCE\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("-------------------------------- -------------------"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " ----------------\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_guid(uint8_t *g, FILE *f)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < 16; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(f, "%02x", g[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoprint_lu_attr(stmfGuid *guid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto luResource hdl = NULL;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int stmfRet = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int ret = 0;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto char propVal[MAXPATHLEN];
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto size_t propValSize = sizeof (propVal);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((stmfRet = stmfGetLuResource(guid, &hdl)) != STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto switch (stmfRet) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_BUSY:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("resource busy"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_PERM:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("permission denied"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto case STMF_ERROR_NOT_FOUND:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* No error here */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (0);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto default:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) fprintf(stderr, "%s: %s\n", cmdName,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto gettext("get extended properties failed"));
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (1);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto print_guid((uint8_t *)guid, stdout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_SIZE, propVal,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &propValSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfRet == STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) printf(" %-19s ", propVal);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else if (stmfRet == STMF_ERROR_NO_PROP) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) printf("not set\n");
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else {
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte (void) printf("<error retrieving property>\n");
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_FILENAME, propVal,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto &propValSize);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (stmfRet == STMF_STATUS_SUCCESS) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) printf("%s\n", propVal);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else if (stmfRet == STMF_ERROR_NO_PROP) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) printf("not set\n");
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else {
450396635f70344c58b6b1e4db38cf17ff34445cJohn Forte (void) printf("<error retrieving property>\n");
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) stmfFreeLuResource(hdl);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (ret);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/*
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * input:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * execFullName - exec name of program (argv[0])
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * copied from usr/src/cmd/zoneadm/zoneadm.c in OS/Net
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * (changed name to lowerCamelCase to keep consistent with this file)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Returns:
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * command name portion of execFullName
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic char *
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetogetExecBasename(char *execFullname)
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto char *lastSlash, *execBasename;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* guard against '/' at end of command invocation */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto for (;;) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto lastSlash = strrchr(execFullname, '/');
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (lastSlash == NULL) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto execBasename = execFullname;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto execBasename = lastSlash + 1;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (*execBasename == '\0') {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto *lastSlash = '\0';
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto continue;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto break;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (execBasename);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoint
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetomain(int argc, char *argv[])
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto{
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto synTables_t synTables;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto char versionString[VERSION_STRING_MAX_LEN];
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int ret;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto int funcRet;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto void *subcommandArgs = NULL;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) setlocale(LC_ALL, "");
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) textdomain(TEXT_DOMAIN);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* set global command name */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto cmdName = getExecBasename(argv[0]);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto (void) snprintf(versionString, VERSION_STRING_MAX_LEN, "%s.%s",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto VERSION_STRING_MAJOR, VERSION_STRING_MINOR);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto synTables.versionString = versionString;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto synTables.longOptionTbl = options;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto synTables.subCommandPropsTbl = subCommands;
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = cmdParse(argc, argv, synTables, subcommandArgs, &funcRet);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret != 0) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (ret);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto }
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto return (funcRet);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto} /* end main */