xref: /freebsd/sys/contrib/openzfs/lib/libzutil/zutil_import.h (revision dd41de95a84d979615a2ef11df6850622bf6184e)
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 2015 Nexenta Systems, Inc. All rights reserved.
23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
25  * Copyright 2015 RackTop Systems.
26  * Copyright (c) 2016, Intel Corporation.
27  */
28 #ifndef _LIBZUTIL_ZUTIL_IMPORT_H_
29 #define	_LIBZUTIL_ZUTIL_IMPORT_H_
30 
31 #define	EZFS_BADCACHE	"invalid or missing cache file"
32 #define	EZFS_BADPATH	"must be an absolute path"
33 #define	EZFS_NOMEM	"out of memory"
34 #define	EZFS_EACESS	"some devices require root privileges"
35 
36 #define	IMPORT_ORDER_PREFERRED_1	1
37 #define	IMPORT_ORDER_PREFERRED_2	2
38 #define	IMPORT_ORDER_SCAN_OFFSET	10
39 #define	IMPORT_ORDER_DEFAULT		100
40 
41 typedef struct libpc_handle {
42 	boolean_t lpc_printerr;
43 	boolean_t lpc_open_access_error;
44 	boolean_t lpc_desc_active;
45 	char lpc_desc[1024];
46 	const pool_config_ops_t *lpc_ops;
47 	void *lpc_lib_handle;
48 } libpc_handle_t;
49 
50 
51 int label_paths(libpc_handle_t *hdl, nvlist_t *label, char **path,
52     char **devid);
53 int zpool_find_import_blkid(libpc_handle_t *hdl, pthread_mutex_t *lock,
54     avl_tree_t **slice_cache);
55 
56 void * zutil_alloc(libpc_handle_t *hdl, size_t size);
57 char *zutil_strdup(libpc_handle_t *hdl, const char *str);
58 
59 typedef struct rdsk_node {
60 	char *rn_name;			/* Full path to device */
61 	int rn_order;			/* Preferred order (low to high) */
62 	int rn_num_labels;		/* Number of valid labels */
63 	uint64_t rn_vdev_guid;		/* Expected vdev guid when set */
64 	libpc_handle_t *rn_hdl;
65 	nvlist_t *rn_config;		/* Label config */
66 	avl_tree_t *rn_avl;
67 	avl_node_t rn_node;
68 	pthread_mutex_t *rn_lock;
69 	boolean_t rn_labelpaths;
70 } rdsk_node_t;
71 
72 int slice_cache_compare(const void *, const void *);
73 
74 void zpool_open_func(void *);
75 
76 #endif /* _LIBZUTIL_ZUTIL_IMPORT_H_ */
77