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