Path: blob/main/cddl/usr.sbin/zfsd/zfsd_exception.h
106842 views
/*-1* Copyright (c) 2011, 2012, 2013 Spectra Logic Corporation2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions, and the following disclaimer,9* without modification.10* 2. Redistributions in binary form must reproduce at minimum a disclaimer11* substantially similar to the "NO WARRANTY" disclaimer below12* ("Disclaimer") and any redistribution must be conditioned upon13* including a substantially similar Disclaimer requirement for further14* binary redistribution.15*16* NO WARRANTY17* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS18* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT19* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR20* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT21* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,25* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING26* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE27* POSSIBILITY OF SUCH DAMAGES.28*29* Authors: Justin T. Gibbs (Spectra Logic Corporation)30*/3132/**33* \file zfsd_exception.h34*35* Definition of the ZfsdException class hierarchy. All exceptions36* explicitly thrown by Zfsd are defined here.37*38* Header requirements:39* #include <string>40*41* #include <devdctl/exception.h>42*/43#ifndef _ZFSD_EXCEPTION_H_44#define _ZFSD_EXCEPTION_H_4546/*=========================== Forward Declarations ===========================*/47struct zpool_handle;48typedef struct zpool_handle zpool_handle_t;4950struct nvlist;51typedef struct nvlist nvlist_t;5253/*============================= Class Definitions ============================*/54/*------------------------------- ZfsdException ------------------------------*/55/**56* \brief Class allowing unified reporting/logging of exceptional events.57*/58class ZfsdException : public DevdCtl::Exception59{60public:61/**62* \brief ZfsdException constructor allowing arbitrary string63* data to be reported.64*65* \param fmt Printf-like string format specifier.66*/67ZfsdException(const char *fmt, ...);6869/**70* \brief ZfsdException constructor allowing arbitrary string71* data to be reported and associated with the configuration72* data for a ZFS pool.73*74* \param pool Pool handle describing the pool to which this75* exception is associated.76* \param fmt Printf-like string format specifier.77*78* Instantiation with this method is used to report global79* pool errors.80*/81ZfsdException(zpool_handle_t *pool, const char *, ...);8283/**84* \brief ZfsdException constructor allowing arbitrary string85* data to be reported and associated with the configuration86* data for a ZFS pool.87*88* \param poolConfig Pool configuration describing the pool to89* which this exception is associated.90* \param fmt Printf-like string format specifier.91*92* Instantiation with this method is used to report global93* pool errors.94*/95ZfsdException(nvlist_t *poolConfig, const char *, ...);9697/**98* \brief Emit exception data to syslog(3).99*/100virtual void Log() const;101private:102nvlist_t *m_poolConfig;103nvlist_t *m_vdevConfig;104};105106#endif /* _ZFSD_EXCEPTION_H_ */107108109