Reamove grub support.
[unleashed.git] / usr / src / lib / libbe / common / libbe_priv.h
blob705f96067c604ac41562daea453948cfae007eea
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2016 Toomas Soome <tsoome@me.com>
26 * Copyright (c) 2015 by Delphix. All rights reserved.
29 #ifndef _LIBBE_PRIV_H
30 #define _LIBBE_PRIV_H
32 #include <libnvpair.h>
33 #include <libzfs.h>
34 #include <instzones_api.h>
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #define ARCH_LENGTH MAXNAMELEN
41 #define BE_AUTO_NAME_MAX_TRY 3
42 #define BE_AUTO_NAME_DELIM '-'
43 #define BE_DEFAULTS "/etc/default/be"
44 #define BE_DFLT_BENAME_STARTS "BENAME_STARTS_WITH="
45 #define BE_CONTAINER_DS_NAME "ROOT"
46 #define BE_POLICY_PROPERTY "org.opensolaris.libbe:policy"
47 #define BE_UUID_PROPERTY "org.opensolaris.libbe:uuid"
48 #define BE_PLCY_STATIC "static"
49 #define BE_PLCY_VOLATILE "volatile"
50 #define BE_SPARC_MENU "/boot/menu.lst"
51 #define BE_WHITE_SPACE " \t\r\n"
52 #define BE_INSTALL_BOOT "/usr/sbin/installboot"
53 #define BE_LOADER_STAGE_1 "/boot/pmbr"
54 #define BE_LOADER_STAGE_2 "/boot/gptzfsboot"
55 #define BE_SPARC_BOOTBLK "/lib/fs/zfs/bootblk"
57 #define ZFS_CLOSE(_zhp) \
58 if (_zhp) { \
59 zfs_close(_zhp); \
60 _zhp = NULL; \
63 #define BE_ZONE_PARENTBE_PROPERTY "org.opensolaris.libbe:parentbe"
64 #define BE_ZONE_ACTIVE_PROPERTY "org.opensolaris.libbe:active"
65 #define BE_ZONE_SUPPORTED_BRANDS "ipkg labeled nlipkg"
66 #define BE_ZONE_SUPPORTED_BRANDS_DELIM " "
68 /* Maximum length for the BE name. */
69 #define BE_NAME_MAX_LEN 64
71 #define MAX(a, b) ((a) > (b) ? (a) : (b))
72 #define MIN(a, b) ((a) < (b) ? (a) : (b))
74 typedef struct be_transaction_data {
75 char *obe_name; /* Original BE name */
76 char *obe_root_ds; /* Original BE root dataset */
77 char *obe_zpool; /* Original BE pool */
78 char *obe_snap_name; /* Original BE snapshot name */
79 char *obe_altroot; /* Original BE altroot */
80 char *nbe_name; /* New BE name */
81 char *nbe_root_ds; /* New BE root dataset */
82 char *nbe_zpool; /* New BE pool */
83 char *nbe_desc; /* New BE description */
84 nvlist_t *nbe_zfs_props; /* New BE dataset properties */
85 char *policy; /* BE policy type */
86 } be_transaction_data_t;
88 typedef struct be_mount_data {
89 char *altroot; /* Location of where to mount BE */
90 boolean_t shared_fs; /* Mount shared file sytsems */
91 boolean_t shared_rw; /* Mount shared file systems rw */
92 } be_mount_data_t;
94 typedef struct be_unmount_data {
95 char *altroot; /* Location of where BE is mounted */
96 boolean_t force; /* Forcibly unmount */
97 } be_unmount_data_t;
99 typedef struct be_destroy_data {
100 boolean_t destroy_snaps; /* Destroy snapshots of BE */
101 boolean_t force_unmount; /* Forcibly unmount BE if mounted */
102 uuid_t gz_be_uuid; /* UUID of the global zone BE */
103 } be_destroy_data_t;
105 typedef struct be_demote_data {
106 zfs_handle_t *clone_zhp; /* clone dataset to promote */
107 time_t origin_creation; /* snapshot creation time of clone */
108 const char *snapshot; /* snapshot of dataset being demoted */
109 boolean_t find_in_BE; /* flag noting to find clone in BE */
110 } be_demote_data_t;
112 typedef struct be_fs_list_data {
113 char *altroot;
114 char **fs_list;
115 int fs_num;
116 } be_fs_list_data_t;
118 typedef struct be_plcy_list {
119 char *be_plcy_name;
120 int be_num_max;
121 int be_num_min;
122 time_t be_age_max;
123 int be_usage_pcnt;
124 struct be_plcy_list *be_next_plcy;
125 }be_plcy_list_t;
127 struct be_defaults {
128 boolean_t be_deflt_rpool_container;
129 char be_deflt_bename_starts_with[ZFS_MAX_DATASET_NAME_LEN];
132 /* Library globals */
133 extern libzfs_handle_t *g_zfs;
134 extern boolean_t do_print;
136 /* be_create.c */
137 int be_set_uuid(char *);
138 int be_get_uuid(const char *, uuid_t *);
140 /* be_list.c */
141 int _be_list(char *, be_node_list_t **);
142 int be_get_zone_be_list(char *, char *, be_node_list_t **);
144 /* be_mount.c */
145 int _be_mount(char *, char **, int);
146 int _be_unmount(char *, int);
147 int be_mount_pool(zfs_handle_t *, char **, char **, boolean_t *);
148 int be_unmount_pool(zfs_handle_t *, char *, char *);
149 int be_mount_zone_root(zfs_handle_t *, be_mount_data_t *);
150 int be_unmount_zone_root(zfs_handle_t *, be_unmount_data_t *);
151 int be_get_legacy_fs(char *, char *, char *, char *, be_fs_list_data_t *);
152 void be_free_fs_list(be_fs_list_data_t *);
153 char *be_get_ds_from_dir(char *);
154 int be_make_tmp_mountpoint(char **);
156 /* be_snapshot.c */
157 int _be_create_snapshot(char *, char **, char *);
158 int _be_destroy_snapshot(char *, char *);
160 /* be_utils.c */
161 boolean_t be_zfs_init(void);
162 void be_zfs_fini(void);
163 void be_make_root_ds(const char *, const char *, char *, int);
164 void be_make_container_ds(const char *, char *, int);
165 char *be_make_name_from_ds(const char *, char *);
166 int be_append_menu(char *, char *, char *, char *, char *);
167 int be_remove_menu(char *, char *, char *);
168 int be_update_menu(char *, char *, char *, char *);
169 boolean_t be_has_menu_entry(char *, char *, int *);
170 int be_run_cmd(char *, char *, int, char *, int);
171 int be_update_vfstab(char *, char *, char *, be_fs_list_data_t *, char *);
172 int be_update_zone_vfstab(zfs_handle_t *, char *, char *, char *,
173 be_fs_list_data_t *);
174 int be_maxsize_avail(zfs_handle_t *, uint64_t *);
175 char *be_auto_snap_name(void);
176 char *be_auto_be_name(char *);
177 char *be_auto_zone_be_name(char *, char *);
178 char *be_default_policy(void);
179 boolean_t valid_be_policy(char *);
180 boolean_t be_valid_auto_snap_name(char *);
181 boolean_t be_valid_be_name(const char *);
182 void be_print_err(char *, ...);
183 int be_find_current_be(be_transaction_data_t *);
184 int zfs_err_to_be_err(libzfs_handle_t *);
185 int errno_to_be_err(int);
187 /* be_activate.c */
188 int _be_activate(char *);
189 int be_activate_current_be(void);
190 boolean_t be_is_active_on_boot(char *);
192 /* be_zones.c */
193 void be_make_zoneroot(char *, char *, int);
194 int be_find_active_zone_root(zfs_handle_t *, char *, char *, int);
195 int be_find_mounted_zone_root(char *, char *, char *, int);
196 boolean_t be_zone_supported(char *);
197 zoneBrandList_t *be_get_supported_brandlist(void);
198 int be_zone_get_parent_uuid(const char *, uuid_t *);
199 int be_zone_set_parent_uuid(char *, uuid_t);
200 boolean_t be_zone_compare_uuids(char *);
202 /* check architecture functions */
203 char *be_get_default_isa(void);
204 char *be_get_platform(void);
205 boolean_t be_is_isa(char *);
207 /* callback functions */
208 int be_exists_callback(zpool_handle_t *, void *);
209 int be_find_zpool_callback(zpool_handle_t *, void *);
210 int be_zpool_find_current_be_callback(zpool_handle_t *, void *);
211 int be_zfs_find_current_be_callback(zfs_handle_t *, void *);
212 int be_check_be_roots_callback(zpool_handle_t *, void *);
214 /* defaults */
215 void be_get_defaults(struct be_defaults *defaults);
217 #ifdef __cplusplus
219 #endif
221 #endif /* _LIBBE_PRIV_H */