libzfs_pool.c (fa9e4066) libzfs_pool.c (088e9d47)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *

--- 125 unchanged lines hidden (view full) ---

134/*
135 * Open a handle to the given pool, even if the pool is currently in the FAULTED
136 * state.
137 */
138zpool_handle_t *
139zpool_open_canfail(const char *pool)
140{
141 zpool_handle_t *zhp;
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *

--- 125 unchanged lines hidden (view full) ---

134/*
135 * Open a handle to the given pool, even if the pool is currently in the FAULTED
136 * state.
137 */
138zpool_handle_t *
139zpool_open_canfail(const char *pool)
140{
141 zpool_handle_t *zhp;
142 nvlist_t *newconfig;
143 int error;
144
145 /*
146 * Make sure the pool name is valid.
147 */
148 if (!zpool_name_valid(pool, NULL, 0)) {
149 zfs_error(dgettext(TEXT_DOMAIN, "cannot open '%s': invalid "
150 "pool name"), pool);
151 return (NULL);
152 }
153
154 zhp = zfs_malloc(sizeof (zpool_handle_t));
155
156 (void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
157
142 int error;
143
144 /*
145 * Make sure the pool name is valid.
146 */
147 if (!zpool_name_valid(pool, NULL, 0)) {
148 zfs_error(dgettext(TEXT_DOMAIN, "cannot open '%s': invalid "
149 "pool name"), pool);
150 return (NULL);
151 }
152
153 zhp = zfs_malloc(sizeof (zpool_handle_t));
154
155 (void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
156
158 if ((error = zpool_refresh_stats(zhp, NULL, &newconfig)) != 0) {
157 if ((error = zpool_refresh_stats(zhp)) != 0) {
159 if (error == ENOENT || error == EINVAL) {
160 zfs_error(dgettext(TEXT_DOMAIN, "cannot open '%s': no "
161 "such pool"), pool);
162 free(zhp);
163 return (NULL);
164 } else {
165 zhp->zpool_state = POOL_STATE_UNAVAIL;
166 }

--- 7 unchanged lines hidden (view full) ---

174/*
175 * Like the above, but silent on error. Used when iterating over pools (because
176 * the configuration cache may be out of date).
177 */
178zpool_handle_t *
179zpool_open_silent(const char *pool)
180{
181 zpool_handle_t *zhp;
158 if (error == ENOENT || error == EINVAL) {
159 zfs_error(dgettext(TEXT_DOMAIN, "cannot open '%s': no "
160 "such pool"), pool);
161 free(zhp);
162 return (NULL);
163 } else {
164 zhp->zpool_state = POOL_STATE_UNAVAIL;
165 }

--- 7 unchanged lines hidden (view full) ---

173/*
174 * Like the above, but silent on error. Used when iterating over pools (because
175 * the configuration cache may be out of date).
176 */
177zpool_handle_t *
178zpool_open_silent(const char *pool)
179{
180 zpool_handle_t *zhp;
182 nvlist_t *newconfig;
183 int error;
184
185 zhp = zfs_malloc(sizeof (zpool_handle_t));
186
187 (void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
188
181 int error;
182
183 zhp = zfs_malloc(sizeof (zpool_handle_t));
184
185 (void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name));
186
189 if ((error = zpool_refresh_stats(zhp, NULL, &newconfig)) != 0) {
187 if ((error = zpool_refresh_stats(zhp)) != 0) {
190 if (error == ENOENT || error == EINVAL) {
191 free(zhp);
192 return (NULL);
193 } else {
194 zhp->zpool_state = POOL_STATE_UNAVAIL;
195 }
196 } else {
197 zhp->zpool_state = POOL_STATE_ACTIVE;

--- 29 unchanged lines hidden (view full) ---

227/*
228 * Close the handle. Simply frees the memory associated with the handle.
229 */
230void
231zpool_close(zpool_handle_t *zhp)
232{
233 if (zhp->zpool_config)
234 nvlist_free(zhp->zpool_config);
188 if (error == ENOENT || error == EINVAL) {
189 free(zhp);
190 return (NULL);
191 } else {
192 zhp->zpool_state = POOL_STATE_UNAVAIL;
193 }
194 } else {
195 zhp->zpool_state = POOL_STATE_ACTIVE;

--- 29 unchanged lines hidden (view full) ---

225/*
226 * Close the handle. Simply frees the memory associated with the handle.
227 */
228void
229zpool_close(zpool_handle_t *zhp)
230{
231 if (zhp->zpool_config)
232 nvlist_free(zhp->zpool_config);
233 if (zhp->zpool_old_config)
234 nvlist_free(zhp->zpool_old_config);
235 free(zhp);
236}
237
238/*
239 * Return the name of the pool.
240 */
241const char *
242zpool_get_name(zpool_handle_t *zhp)

--- 912 unchanged lines hidden ---
235 free(zhp);
236}
237
238/*
239 * Return the name of the pool.
240 */
241const char *
242zpool_get_name(zpool_handle_t *zhp)

--- 912 unchanged lines hidden ---