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/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*LINTLIBRARY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Administration program for SENA
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * subsystems and individual FC_AL devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I18N message number ranges
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file: 2000 - 2999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shared common messages: 1 - 1999
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* #define _POSIX_SOURCE 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These defines are used to map instance number from sf minor node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * They are copied from SF_INST_SHIFT4MINOR and SF_MINOR2INST in sfvar.h.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sfvar.h is not clean for userland use.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When it is cleaned up, these defines will be removed and sfvar.h
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will be included in luxadm.h header file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LUX_SF_INST_SHIFT4MINOR 6
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LUX_SF_MINOR2INST(x) (x >> LUX_SF_INST_SHIFT4MINOR)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Includes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/file.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/param.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ctype.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <dirent.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <limits.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdarg.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <termio.h> /* For password */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/scsi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "common.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "luxadm.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Global variables */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *dtype[16]; /* setting a global for later use. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *whoami;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint Options;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_A = 0x00000001;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_B = 0x00000002;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_C = 0x00000004;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_D = 0x00000008;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_E = 0x00000010;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_F = 0x00000020;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_L = 0x00000040;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_P = 0x00000080;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_R = 0x00000100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_T = 0x00000200;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_V = 0x00000400;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_Z = 0x00001000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_Y = 0x00002000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int OPTION_CAPF = 0x00004000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int PVERBOSE = 0x00008000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int SAVE = 0x00010000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst int EXPERT = 0x00020000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Given a pointer to a character array, print the character array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the character array will not necesarily be NULL terminated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Inputs:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * size - the max number of characters to print
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fill_flag - flag when set fills all NULL characters with spaces
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * N/A
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_chars(uchar_t *buffer, int size, int fill_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < size; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (buffer[i])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, "%c", buffer[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (fill_flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Name : memstrstr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input : pointer to buf1, pointer to buf2, size of buf1, size of buf2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pointer to start of contents-of-buf2 in buf1 if it is found
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL if buf1 does not contain contents of buf2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Synopsis:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function works similar to strstr(). The difference is that null
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * characters in the buffer are treated like any other character. So, buf1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and buf2 can have embedded null characters in them.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortememstrstr(char *s1, char *s2, int size1, int size2)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count1, count2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *s1_ptr, *s2_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count1 = size1; count2 = size2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s1_ptr = s1; s2_ptr = s2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (size2 == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (s1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (count1--) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*s1_ptr++ == *s2_ptr++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (--count2 == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (s1_ptr - size2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count2 = size2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s2_ptr = s2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Download host bus adapter FCode to all supported cards.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Specify a directory that holds the FCode files, or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it will use the default dir. Each file is dealt to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the appropriate function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -p prints current versions only, -d specifies a directory to load
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadm_fcode(int verbose, char *dir)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat statbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct dirent *dirp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DIR *dp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fbuf[BUFSIZ];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char file[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int retval = 0, strfound = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char manf[BUFSIZ];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find all adapters and print the current FCode version */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & OPTION_P) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* SOCAL (SBus) adapters are not supported on x86 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef __x86
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2215, "\n Searching for FC100/S cards:\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval += fcal_update(Options & PVERBOSE, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2216, "\n Searching for FC100/P, FC100/2P cards:\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval += q_qlgc_update(Options & PVERBOSE, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2503, "\n Searching for Emulex cards:\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval += emulex_update(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send files to the correct function for loading to the HBA */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!dir) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(2251,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Location of Fcode not specified.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (verbose) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(2217,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Using directory %s"), dir);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lstat(dir, &statbuf) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, MSGSTR(134,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s: lstat() failed - %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dir, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (S_ISDIR(statbuf.st_mode) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2218, "Error: %s is not a directory.\n"), dir);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dp = opendir(dir)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, MSGSTR(2219,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Error Cannot open directory %s\n"), dir);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((dirp = readdir(dp)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(dirp->d_name, ".") == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcmp(dirp->d_name, "..") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sprintf(file, "%s/%s", dir, dirp->d_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fp = open(file, O_RDONLY)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2220,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: open() failed to open file "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s\n"), file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We should just issue an error message and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make an attempt on the next file,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the open error is still an error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so the retval should be incremented
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((read(fp, fbuf, BUFSIZ)) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (memstrstr(fbuf, "SUNW,socal",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUFSIZ, strlen("SUNW,socal"))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(2221,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n Using file: %s\n"), file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval += fcal_update(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options & PVERBOSE, file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strfound++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((memstrstr(fbuf, "SUNW,ifp",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUFSIZ, strlen("SUNW,ifp"))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (memstrstr(fbuf, "SUNW,qlc",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BUFSIZ, strlen("SUNW,qlc"))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stdout, MSGSTR(2221,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n Using file: %s\n"), file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval += q_qlgc_update(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options & PVERBOSE, file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strfound++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!strfound) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check to see if this is an emulex fcode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(manf, 0, sizeof (manf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((emulex_fcode_reader(fp, "manufacturer",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte manf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (manf)) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strncmp(manf, "Emulex", sizeof (manf))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval += emulex_update(file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strfound = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, MSGSTR(2222,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\nError: %s is not a valid Fcode "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "file.\n"), file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte retval++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strfound = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte closedir(dp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (retval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Definition of getaction() routine which does keyword parsing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Operation: A character string containing the ascii cmd to be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parsed is passed in along with an array of structures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The 1st struct element is a recognizable cmd string, the second
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is the minimum number of characters from the start of this string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to succeed on a match. For example, { "offline", 3, ONLINE }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will match "off", "offli", "offline", but not "of" nor "offlinebarf"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The third element is the {usually but not necessarily unique}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * integer to return on a successful match. Note: compares are cAsE insensitive.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To change, extend or use this utility, just add or remove appropriate
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lines in the structure initializer below and in the #define s for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return values.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * N O T E
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Do not change the minimum number of characters to produce
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a match as someone may be building scripts that use this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * feature.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct keyword {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *match; /* Character String to match against */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int num_match; /* Minimum chars to produce a match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret_code; /* Value to return on a match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic struct keyword Keywords[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"display", 2, DISPLAY},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"download", 3, DOWNLOAD},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"enclosure_names", 2, ENCLOSURE_NAMES},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"failover", 3, FAILOVER},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"fcal_s_download", 4, FCAL_UPDATE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"fcode_download", 4, FCODE_UPDATE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"inquiry", 2, INQUIRY},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"insert_device", 3, INSERT_DEVICE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"led", 3, LED},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"led_on", 5, LED_ON},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"led_off", 5, LED_OFF},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"led_blink", 5, LED_BLINK},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"password", 2, PASSWORD},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"power_on", 8, POWER_ON},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"power_off", 9, POWER_OFF},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"probe", 2, PROBE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"qlgc_s_download", 4, QLGC_UPDATE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"remove_device", 3, REMOVE_DEVICE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"reserve", 5, RESERVE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"release", 3, RELEASE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"set_boot_dev", 5, SET_BOOT_DEV},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"start", 3, START},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"stop", 3, STOP},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"rdls", 2, RDLS},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"bypass", 3, BYPASS},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"enable", 3, ENABLE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"p_offline", 4, LUX_P_OFFLINE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"p_online", 4, LUX_P_ONLINE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"forcelip", 2, FORCELIP},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"dump", 2, DUMP},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"check_file", 2, CHECK_FILE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"dump_map", 2, DUMP_MAP},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"sysdump", 5, SYSDUMP},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"port", 4, PORT},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"external_loopback", 12, EXT_LOOPBACK},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"internal_loopback", 12, INT_LOOPBACK},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"no_loopback", 11, NO_LOOPBACK},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"version", 2, VERSION},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"create_fabric_device", 2, CREATE_FAB},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hotplugging device operations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"online", 2, DEV_ONLINE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"offline", 2, DEV_OFFLINE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"dev_getstate", 5, DEV_GETSTATE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"dev_reset", 5, DEV_RESET},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hotplugging bus operations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"bus_quiesce", 5, BUS_QUIESCE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"bus_unquiesce", 5, BUS_UNQUIESCE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"bus_getstate", 5, BUS_GETSTATE},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"bus_reset", 9, BUS_RESET},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {"bus_resetall", 12, BUS_RESETALL},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* hotplugging "helper" subcommands */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL, 0, 0}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef EOK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int EOK = 0; /* errno.h type success return code */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * function getaction() takes a character string, cmd, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tries to match it against a passed structure of known cmd
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * character strings. If a match is found, corresponding code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is returned in retval. Status returns as follows:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EOK = Match found, look for cmd's code in retval
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EFAULT = One of passed parameters was bad
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EINVAL = cmd did not match any in list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegetaction(char *cmd, struct keyword *matches, int *retval)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint actlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Idiot checking of pointers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (! cmd || ! matches || ! retval ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! (actlen = strlen(cmd))) /* Is there an cmd ? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EFAULT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Keep looping until NULL match string (end of list) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (matches->match) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Precedence: Make sure target is no longer than
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * current match string
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and target is at least as long as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * minimum # match chars,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then do case insensitive match
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * based on actual target size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((((int)strlen(matches->match)) >= actlen) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (actlen >= matches->num_match) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* can't get strncasecmp to work on SCR4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* (strncasecmp(matches->match, cmd, actlen) == 0) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strncmp(matches->match, cmd, actlen) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *retval = matches->ret_code; /* Found our match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EOK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matches++; /* Next match string/struct */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of matches loop */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} /* End of getaction() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* main functions. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemain(int argc, char **argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteregister int c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* getopt varbs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *optstring = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint path_index, err = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint cmd = 0; /* Cmd verb from cmd line */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint exit_code = 0; /* exit code for program */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint temp_fd; /* For -f option */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *file_name = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint option_t_input;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *path_phys = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint USE_FCHBA = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte whoami = argv[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Enable locale announcement
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i18n_catopen();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv, "ve"))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != EOF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'v':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= PVERBOSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'e':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= EXPERT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Note: getopt prints an error if invalid option */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch(c) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setbuf(stdout, NULL); /* set stdout unbuffered. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Build any i18n global variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[0] = MSGSTR(2192, "Disk device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[1] = MSGSTR(2193, "Tape device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[2] = MSGSTR(2194, "Printer device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[3] = MSGSTR(2195, "Processor device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[4] = MSGSTR(2196, "WORM device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[5] = MSGSTR(2197, "CD-ROM device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[6] = MSGSTR(2198, "Scanner device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[7] = MSGSTR(2199, "Optical memory device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[8] = MSGSTR(2200, "Medium changer device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[9] = MSGSTR(2201, "Communications device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[10] = MSGSTR(107, "Graphic arts device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[11] = MSGSTR(107, "Graphic arts device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[12] = MSGSTR(2202, "Array controller device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[13] = MSGSTR(2203, "SES device");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[14] = MSGSTR(71, "Reserved");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dtype[15] = MSGSTR(71, "Reserved");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get subcommand.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((getaction(argv[optind], Keywords, &cmd)) == EOK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optind++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cmd != PROBE) && (cmd != FCAL_UPDATE) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd != QLGC_UPDATE) && (cmd != FCODE_UPDATE) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd != INSERT_DEVICE) && (cmd != SYSDUMP) && (cmd != AU) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd != PORT) && (cmd != CREATE_FAB) && (optind >= argc)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2204,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: enclosure or pathname not specified.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2205, "%s: subcommand not specified.\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte whoami);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Extract & Save subcommand options */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cmd == ENABLE) || (cmd == BYPASS)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optstring = "Ffrab";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cmd == FCODE_UPDATE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optstring = "pd:";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cmd == REMOVE_DEVICE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optstring = "F";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cmd == CREATE_FAB) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optstring = "f:";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optstring = "Fryszabepcdlvt:f:w:";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv, optstring)) != EOF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'a':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_A;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'b':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_B;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'c':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_C;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'd':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_D;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cmd == FCODE_UPDATE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte file_name = optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'e':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_E;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'f':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_F;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!((cmd == ENABLE) || (cmd == BYPASS))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte file_name = optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'F':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_CAPF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'l':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_L;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'p':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_P;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'r':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_R;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 's':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= SAVE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 't':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_T;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte option_t_input = atoi(optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'v':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_V;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'z':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_Z;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'y':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options |= OPTION_Y;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Note: getopt prints an error if invalid option */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* End of switch(c) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cmd != PROBE) && (cmd != FCAL_UPDATE) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd != QLGC_UPDATE) && (cmd != FCODE_UPDATE) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd != INSERT_DEVICE) && (cmd != SYSDUMP) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd != AU) && (cmd != PORT) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cmd != CREATE_FAB) && (optind >= argc)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2206,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Error: enclosure or pathname not specified.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_index = optind;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if the file supplied with the -f option is valid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Some sub commands (bypass for example) use the -f option
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for other reasons. In such cases, "file_name" should be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((file_name != NULL) && (Options & OPTION_F)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((temp_fd = open(file_name, O_RDONLY)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror(file_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(temp_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Determine which mode to operate in (FC-HBA or original) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USE_FCHBA = use_fchba();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (cmd) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DISPLAY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ~(PVERBOSE | OPTION_A | OPTION_Z | OPTION_R |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPTION_P | OPTION_V | OPTION_L | OPTION_E | OPTION_T)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Display object(s) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = fchba_display_config(&argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte option_t_input, argc - path_index);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_display_config(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DOWNLOAD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ~(PVERBOSE | OPTION_F | SAVE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_download(&argv[path_index], file_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ENCLOSURE_NAMES:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~PVERBOSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte up_encl_name(&argv[path_index], argc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FAILOVER:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~PVERBOSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_failover(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case INQUIRY:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = fchba_inquiry(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_inquiry(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PROBE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE | OPTION_P)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A special check just in case someone entered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * any characters after the -p or the probe.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (I know, a nit.)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((Options & PVERBOSE) && (Options & OPTION_P) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (argc != 4)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(Options & PVERBOSE) && (Options & OPTION_P) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (argc != 3)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((Options & PVERBOSE) && (!(Options & OPTION_P)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (argc != 3)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(Options & PVERBOSE) && (!(Options & OPTION_P)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (argc != 2))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(114, "Error: Incorrect number of arguments.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, MSGSTR(2208,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Usage: %s [-v] subcommand [option]\n"), whoami);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = fchba_non_encl_probe();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pho_probe();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte non_encl_probe();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCODE_UPDATE: /* Update Fcode in all cards */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((Options & ~(PVERBOSE)) &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ~(OPTION_P | OPTION_D) || argv[path_index]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!((Options & (OPTION_P | OPTION_D)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !((Options & OPTION_P) && (Options & OPTION_D)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (adm_fcode(Options & PVERBOSE, file_name) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case QLGC_UPDATE: /* Update Fcode in PCI HBA card(s) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((Options & ~(PVERBOSE)) & ~(OPTION_F) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (q_qlgc_update(Options & PVERBOSE, file_name) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FCAL_UPDATE: /* Update Fcode in Sbus soc+ card */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((Options & ~(PVERBOSE)) & ~(OPTION_F) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = fcal_update(Options & PVERBOSE, file_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SET_BOOT_DEV: /* Set boot-device variable in nvram */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = setboot(Options & OPTION_Y,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options & PVERBOSE, argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LED:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_led(&argv[path_index], L_LED_STATUS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LED_ON:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_led(&argv[path_index], L_LED_ON);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LED_OFF:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_led(&argv[path_index], L_LED_OFF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LED_BLINK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_led(&argv[path_index], L_LED_RQST_IDENTIFY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PASSWORD:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte up_password(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case RESERVE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & (~PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte VERBPRINT(MSGSTR(2209,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " Reserving: \n %s\n"), argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat sbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Just stat the argument and make sure it exists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(argv[path_index], &sbuf) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: ", whoami);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_phys = argv[path_index];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = scsi_reserve(path_phys)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) print_errString(err, argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_reserve(argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case RELEASE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & (~PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte VERBPRINT(MSGSTR(2210, " Canceling Reservation for:\n %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat sbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Just stat the argument and make sure it exists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(argv[path_index], &sbuf) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: ", whoami);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(112, "Error: Invalid pathname (%s)"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte path_phys = argv[path_index];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = scsi_release(path_phys)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) print_errString(err, argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_release(argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case START:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_start(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case STOP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_stop(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case POWER_OFF:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE | OPTION_CAPF)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_power_off(&argv[path_index], 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case POWER_ON:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & (~PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_power_off(&argv[path_index], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EXPERT commands.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case FORCELIP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte E_USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_forcelip(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case BYPASS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPTION_CAPF | OPTION_A | OPTION_B | OPTION_F |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPTION_R)) || !(Options & (OPTION_A | OPTION_B)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((Options & OPTION_A) && (Options & OPTION_B))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte E_USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_bypass_enable(&argv[path_index], 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case ENABLE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPTION_CAPF | OPTION_A | OPTION_B | OPTION_F |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OPTION_R)) || !(Options & (OPTION_A | OPTION_B)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((Options & OPTION_A) && (Options & OPTION_B))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte E_USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adm_bypass_enable(&argv[path_index], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LUX_P_OFFLINE: /* Offline a port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte E_USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_port_offline_online(&argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LUX_P_OFFLINE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LUX_P_ONLINE: /* Online a port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte E_USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_port_offline_online(&argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LUX_P_ONLINE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case RDLS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte E_USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = fchba_display_link_status(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte display_link_status(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CREATE_FAB:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & (EXPERT | OPTION_F)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (Options & ~(PVERBOSE | EXPERT | OPTION_F))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte E_USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (read_repos_file(file_name) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Undocumented commands.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case CHECK_FILE: /* Undocumented Cmd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_check_file(&argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (Options & PVERBOSE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DUMP: /* Undocumented Cmd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dump(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DUMP_MAP: /* Undocumented Cmd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = fchba_dump_map(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dump_map(&argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SYSDUMP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Options & ~(PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = sysdump(Options & PVERBOSE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) print_errString(err, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case PORT: /* Undocumented command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = fchba_display_port(Options & PVERBOSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit_code = adm_display_port(Options & PVERBOSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case EXT_LOOPBACK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (adm_port_loopback(argv[path_index], EXT_LOOPBACK) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case INT_LOOPBACK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (adm_port_loopback(argv[path_index], INT_LOOPBACK) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case NO_LOOPBACK:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (adm_port_loopback(argv[path_index], NO_LOOPBACK) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case VERSION:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case INSERT_DEVICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argv[path_index] == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((err = h_insertSena_fcdev()) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) print_errString(err, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((err = hotplug(INSERT_DEVICE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options & PVERBOSE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options & OPTION_CAPF)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) print_errString(err, argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case REMOVE_DEVICE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (err = hotplug(REMOVE_DEVICE, &argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options & PVERBOSE, Options & OPTION_CAPF)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) print_errString(err, argv[path_index]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* for hotplug device operations */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEV_ONLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEV_OFFLINE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEV_GETSTATE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DEV_RESET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case BUS_QUIESCE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case BUS_UNQUIESCE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case BUS_GETSTATE:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case BUS_RESET:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case BUS_RESETALL:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(Options & EXPERT) || (Options & ~(PVERBOSE | EXPERT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte E_USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (USE_FCHBA) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fchba_hotplug_e(cmd, &argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options & PVERBOSE, Options & OPTION_CAPF) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hotplug_e(cmd, &argv[path_index],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Options & PVERBOSE, Options & OPTION_CAPF) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MSGSTR(2213, "%s: subcommand decode failed.\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte whoami);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte USEAGE();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (exit_code);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}