xref: /titanic_52/usr/src/common/zfs/zfs_comutil.c (revision b7b97454b9b1f6625e7e655e9651e744a8dee09d)
1*b7b97454Sperrin /*
2*b7b97454Sperrin  * CDDL HEADER START
3*b7b97454Sperrin  *
4*b7b97454Sperrin  * The contents of this file are subject to the terms of the
5*b7b97454Sperrin  * Common Development and Distribution License (the "License").
6*b7b97454Sperrin  * You may not use this file except in compliance with the License.
7*b7b97454Sperrin  *
8*b7b97454Sperrin  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*b7b97454Sperrin  * or http://www.opensolaris.org/os/licensing.
10*b7b97454Sperrin  * See the License for the specific language governing permissions
11*b7b97454Sperrin  * and limitations under the License.
12*b7b97454Sperrin  *
13*b7b97454Sperrin  * When distributing Covered Code, include this CDDL HEADER in each
14*b7b97454Sperrin  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*b7b97454Sperrin  * If applicable, add the following below this CDDL HEADER, with the
16*b7b97454Sperrin  * fields enclosed by brackets "[]" replaced with your own identifying
17*b7b97454Sperrin  * information: Portions Copyright [yyyy] [name of copyright owner]
18*b7b97454Sperrin  *
19*b7b97454Sperrin  * CDDL HEADER END
20*b7b97454Sperrin  */
21*b7b97454Sperrin /*
22*b7b97454Sperrin  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*b7b97454Sperrin  * Use is subject to license terms.
24*b7b97454Sperrin  */
25*b7b97454Sperrin 
26*b7b97454Sperrin #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*b7b97454Sperrin 
28*b7b97454Sperrin /*
29*b7b97454Sperrin  * This file is intended for functions that ought to be common between user
30*b7b97454Sperrin  * land (libzfs) and the kernel. When many common routines need to be shared
31*b7b97454Sperrin  * then a separate file should to be created.
32*b7b97454Sperrin  */
33*b7b97454Sperrin 
34*b7b97454Sperrin #if defined(_KERNEL)
35*b7b97454Sperrin #include <sys/systm.h>
36*b7b97454Sperrin #endif
37*b7b97454Sperrin 
38*b7b97454Sperrin #include <sys/types.h>
39*b7b97454Sperrin #include <sys/fs/zfs.h>
40*b7b97454Sperrin #include <sys/nvpair.h>
41*b7b97454Sperrin 
42*b7b97454Sperrin /*
43*b7b97454Sperrin  * Are there allocatable vdevs?
44*b7b97454Sperrin  */
45*b7b97454Sperrin boolean_t
46*b7b97454Sperrin zfs_allocatable_devs(nvlist_t *nv)
47*b7b97454Sperrin {
48*b7b97454Sperrin 	uint64_t is_log;
49*b7b97454Sperrin 	uint_t c;
50*b7b97454Sperrin 	nvlist_t **child;
51*b7b97454Sperrin 	uint_t children;
52*b7b97454Sperrin 
53*b7b97454Sperrin 	if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
54*b7b97454Sperrin 	    &child, &children) != 0) {
55*b7b97454Sperrin 		return (B_FALSE);
56*b7b97454Sperrin 	}
57*b7b97454Sperrin 	for (c = 0; c < children; c++) {
58*b7b97454Sperrin 		is_log = 0;
59*b7b97454Sperrin 		(void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
60*b7b97454Sperrin 		    &is_log);
61*b7b97454Sperrin 		if (!is_log)
62*b7b97454Sperrin 			return (B_TRUE);
63*b7b97454Sperrin 	}
64*b7b97454Sperrin 	return (B_FALSE);
65*b7b97454Sperrin }
66