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#include "Exceptions.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "Trace.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sun_fc.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <iostream>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <iomanip>
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 <stropts.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <cstring>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <cerrno>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteusing namespace std;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @memo Log a simple I/O error message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param message The message to log
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIOError::IOError(string message) : HBAException(HBA_STATUS_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("IOError::IOError(string)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError("%s (%s)", message.c_str(), strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @memo Log a handle I/O error message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param handle The handle where the I/O error took place
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIOError::IOError(Handle *handle) : HBAException(HBA_STATUS_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("IOError::IOError(Handle)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "On handle %08lx (%s)", handle->getHandle(), strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @memo Log an HBAPort I/O error message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param port The port where the I/O error took place
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIOError::IOError(HBAPort *port) : HBAException(HBA_STATUS_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("IOError::IOError(HBAPort)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "On HBA port %016llx (%s)", port->getPortWWN(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @memo Log a target I/O error message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param port The port where the I/O error took place
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param target The target wwn which failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIOError::IOError(HBAPort *port, uint64_t target) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAException(HBA_STATUS_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("IOError::IOError(HBAPort, wwn)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "On HBA port %016llx target %016llx (%s)", port->getPortWWN(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte target, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/**
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @memo Log a LUN I/O error message
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param port The port where the I/O error took place
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param target The target wwn which failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param lun The unit number which failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteIOError::IOError(HBAPort *port, uint64_t target, uint64_t lun) :
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAException(HBA_STATUS_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("IOError::IOError(HBAPort, wwn, lun)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "On HBA port %016llx target %016llx lun %016llx (%s)",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->getPortWWN(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte target,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}