1 /*- 2 * Copyright (c) 2011, 2012, 2013 Spectra Logic Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions, and the following disclaimer, 10 * without modification. 11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12 * substantially similar to the "NO WARRANTY" disclaimer below 13 * ("Disclaimer") and any redistribution must be conditioned upon 14 * including a substantially similar Disclaimer requirement for further 15 * binary redistribution. 16 * 17 * NO WARRANTY 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGES. 29 * 30 * Authors: Justin T. Gibbs (Spectra Logic Corporation) 31 * 32 * $FreeBSD$ 33 */ 34 35 /** 36 * \file zfsd_exception.h 37 * 38 * Definition of the ZfsdException class hierarchy. All exceptions 39 * explicitly thrown by Zfsd are defined here. 40 * 41 * Header requirements: 42 * #include <string> 43 * 44 * #include <devdctl/exception.h> 45 */ 46 #ifndef _ZFSD_EXCEPTION_H_ 47 #define _ZFSD_EXCEPTION_H_ 48 49 /*=========================== Forward Declarations ===========================*/ 50 struct zpool_handle; 51 typedef struct zpool_handle zpool_handle_t; 52 53 struct nvlist; 54 typedef struct nvlist nvlist_t; 55 56 /*============================= Class Definitions ============================*/ 57 /*------------------------------- ZfsdException ------------------------------*/ 58 /** 59 * \brief Class allowing unified reporting/logging of exceptional events. 60 */ 61 class ZfsdException : public DevdCtl::Exception 62 { 63 public: 64 /** 65 * \brief ZfsdException constructor allowing arbitrary string 66 * data to be reported. 67 * 68 * \param fmt Printf-like string format specifier. 69 */ 70 ZfsdException(const char *fmt, ...); 71 72 /** 73 * \brief ZfsdException constructor allowing arbitrary string 74 * data to be reported and associated with the configuration 75 * data for a ZFS pool. 76 * 77 * \param pool Pool handle describing the pool to which this 78 * exception is associated. 79 * \param fmt Printf-like string format specifier. 80 * 81 * Instantiation with this method is used to report global 82 * pool errors. 83 */ 84 ZfsdException(zpool_handle_t *pool, const char *, ...); 85 86 /** 87 * \brief ZfsdException constructor allowing arbitrary string 88 * data to be reported and associated with the configuration 89 * data for a ZFS pool. 90 * 91 * \param poolConfig Pool configuration describing the pool to 92 * which this exception is associated. 93 * \param fmt Printf-like string format specifier. 94 * 95 * Instantiation with this method is used to report global 96 * pool errors. 97 */ 98 ZfsdException(nvlist_t *poolConfig, const char *, ...); 99 100 /** 101 * \brief Emit exception data to syslog(3). 102 */ 103 virtual void Log() const; 104 private: 105 nvlist_t *m_poolConfig; 106 nvlist_t *m_vdevConfig; 107 }; 108 109 #endif /* _ZFSD_EXCEPTION_H_ */ 110