xref: /illumos-gate/usr/src/cmd/zpool/zpool_util.h (revision 436b964b)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
599653d4eSeschrock  * Common Development and Distribution License (the "License").
699653d4eSeschrock  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
223f9d6ad7SLin Ling  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23fa9e4066Sahrens  */
24fa9e4066Sahrens 
25fa9e4066Sahrens #ifndef	ZPOOL_UTIL_H
26fa9e4066Sahrens #define	ZPOOL_UTIL_H
27fa9e4066Sahrens 
28fa9e4066Sahrens #include <libnvpair.h>
29fa9e4066Sahrens #include <libzfs.h>
30fa9e4066Sahrens 
31fa9e4066Sahrens #ifdef	__cplusplus
32fa9e4066Sahrens extern "C" {
33fa9e4066Sahrens #endif
34fa9e4066Sahrens 
35fa9e4066Sahrens /*
36fa9e4066Sahrens  * Basic utility functions
37fa9e4066Sahrens  */
38*436b964bSToomas Soome extern void *safe_malloc(size_t);
39*436b964bSToomas Soome extern void zpool_no_memory(void);
40*436b964bSToomas Soome extern uint_t num_logs(nvlist_t *nv);
41*436b964bSToomas Soome extern uint64_t array64_max(uint64_t array[], unsigned int len);
42*436b964bSToomas Soome extern int highbit64(uint64_t i);
43*436b964bSToomas Soome extern int lowbit64(uint64_t i);
44*436b964bSToomas Soome extern int isnumber(char *str);
45fa9e4066Sahrens 
46fa9e4066Sahrens /*
47fa9e4066Sahrens  * Virtual device functions
48fa9e4066Sahrens  */
498488aeb5Staylor 
50*436b964bSToomas Soome extern nvlist_t *make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, int force,
515711d393Sloli     int check_rep, boolean_t replacing, boolean_t dryrun,
525711d393Sloli     zpool_boot_label_t boot_type, uint64_t boot_size, int argc, char **argv);
53*436b964bSToomas Soome extern nvlist_t *split_mirror_vdev(zpool_handle_t *zhp, char *newname,
541195e687SMark J Musante     nvlist_t *props, splitflags_t flags, int argc, char **argv);
55fa9e4066Sahrens 
56fa9e4066Sahrens /*
57fa9e4066Sahrens  * Pool list functions
58fa9e4066Sahrens  */
59*436b964bSToomas Soome extern int for_each_pool(int, char **, boolean_t unavail, zprop_list_t **,
60b1b8ab34Slling     zpool_iter_f, void *);
61fa9e4066Sahrens 
62dd50e0ccSTony Hutter /* Vdev list functions */
63dd50e0ccSTony Hutter typedef int (*pool_vdev_iter_f)(zpool_handle_t *, nvlist_t *, void *);
64*436b964bSToomas Soome extern int for_each_vdev(zpool_handle_t *, pool_vdev_iter_f, void *);
65dd50e0ccSTony Hutter 
66fa9e4066Sahrens typedef struct zpool_list zpool_list_t;
67fa9e4066Sahrens 
68*436b964bSToomas Soome extern zpool_list_t *pool_list_get(int, char **, zprop_list_t **, int *);
69*436b964bSToomas Soome extern void pool_list_update(zpool_list_t *);
70*436b964bSToomas Soome extern int pool_list_iter(zpool_list_t *, int unavail, zpool_iter_f, void *);
71*436b964bSToomas Soome extern void pool_list_free(zpool_list_t *);
72*436b964bSToomas Soome extern int pool_list_count(zpool_list_t *);
73*436b964bSToomas Soome extern void pool_list_remove(zpool_list_t *, zpool_handle_t *);
74fa9e4066Sahrens 
75*436b964bSToomas Soome extern libzfs_handle_t *g_zfs;
7699653d4eSeschrock 
77fa9e4066Sahrens #ifdef	__cplusplus
78fa9e4066Sahrens }
79fa9e4066Sahrens #endif
80fa9e4066Sahrens 
81fa9e4066Sahrens #endif	/* ZPOOL_UTIL_H */
82