2 * Copyright (c) 2011, 2012, 2013 Spectra Logic Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
30 * Authors: Justin T. Gibbs (Spectra Logic Corporation)
34 * \file zfsd_exception
36 * Implementation of the ZfsdException class.
38 #include <sys/cdefs.h>
39 #include <sys/byteorder.h>
40 #include <sys/fs/zfs.h>
48 #include <devdctl/exception.h>
49 #include <devdctl/guid.h>
54 #include "zfsd_exception.h"
56 __FBSDID("$FreeBSD$");
57 /*============================ Namespace Control =============================*/
60 using std::stringstream;
62 /*=========================== Class Implementations ==========================*/
63 /*------------------------------- ZfsdException ------------------------------*/
64 ZfsdException::ZfsdException(const char *fmt, ...)
65 : DevdCtl::Exception(),
76 ZfsdException::ZfsdException(zpool_handle_t *pool, const char *fmt, ...)
77 : DevdCtl::Exception(),
78 m_poolConfig(zpool_get_config(pool, NULL)),
88 ZfsdException::ZfsdException(nvlist_t *poolConfig, const char *fmt, ...)
89 : DevdCtl::Exception(),
90 m_poolConfig(poolConfig),
101 ZfsdException::Log() const
105 if (m_poolConfig != NULL) {
110 if (nvlist_lookup_string(m_poolConfig, ZPOOL_CONFIG_POOL_NAME,
118 if (m_vdevConfig != NULL) {
120 if (m_poolConfig != NULL) {
121 Vdev vdev(m_poolConfig, m_vdevConfig);
123 output << "Vdev " << vdev.GUID() << ": ";
125 Vdev vdev(m_vdevConfig);
127 output << "Pool " << vdev.PoolGUID() << ": ";
128 output << "Vdev " << vdev.GUID() << ": ";
132 output << m_log << endl;
133 syslog(LOG_ERR, "%s", output.str().c_str());