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)
38 * ZpoolList class definition. ZpoolList is a standard container
39 * allowing filtering and iteration of imported ZFS pool information.
41 * Header requirements:
46 #ifndef _ZPOOL_LIST_H_
47 #define _ZPOOL_LIST_H_
49 /*============================ Namespace Control =============================*/
52 /*=========================== Forward Declarations ===========================*/
54 typedef struct zpool_handle zpool_handle_t;
57 typedef struct nvlist nvlist_t;
61 /*============================= Class Definitions ============================*/
62 /*--------------------------------- ZpoolList --------------------------------*/
64 typedef bool PoolFilter_t(zpool_handle_t *pool, nvlist_t *poolConfig,
68 * \brief Container of imported ZFS pool data.
70 * ZpoolList is a convenience class that converts libzfs's ZFS
71 * pool methods into a standard list container.
73 class ZpoolList : public std::list<zpool_handle_t *>
77 * \brief Utility ZpoolList construction filter that causes all
78 * pools known to the system to be included in the
79 * instantiated ZpoolList.
81 static PoolFilter_t ZpoolAll;
84 * \brief Utility ZpoolList construction filter that causes only
85 * a pool known to the system and having the specified GUID
86 * to be included in the instantiated ZpoolList.
88 static PoolFilter_t ZpoolByGUID;
91 * \brief Utility ZpoolList construction filter that causes only
92 * pools known to the system and having the specified name
93 * to be included in the instantiated ZpoolList.
95 static PoolFilter_t ZpoolByName;
98 * \brief ZpoolList contructor
100 * \param filter The filter function to use when constructing
101 * the ZpoolList. This may be one of the static
102 * utility filters defined for ZpoolList or a
103 * user defined function.
104 * \param filterArg A single argument to pass into the filter function
105 * when it is invoked on each candidate pool.
107 ZpoolList(PoolFilter_t *filter = ZpoolAll, void *filterArg = NULL);
112 * \brief Helper routine used to populate the internal
113 * data store of ZFS pool objects using libzfs's
114 * zpool_iter() function.
116 * \param pool The ZFS pool object to filter.
117 * \param data User argument passed through zpool_iter().
119 static int LoadIterator(zpool_handle_t *pool, void *data);
122 * \brief The filter with which this ZpoolList was constructed.
124 PoolFilter_t *m_filter;
127 * \brief The filter argument with which this ZpoolList was
133 #endif /* _ZPOOL_ITERATOR_H_ */