comparison usr/src/lib/libbe/common/libbe_priv.h @ 13025:3c7681e3e323

PSARC 2010/059 SNAP BE Management 6964804 SNAP BE management into ON 6971379 libbe should capture and give useful error when installgrub or ict.py fails. 6971390 beadm does not support labeled brand zones 6971394 BEADM_ERR_BE_DOES_NOT_EXIST has an extra space 6971397 libbe error messages need internationalization 6971402 Remove be_get_last_zone_be_callback 6971409 be_create_menu returns errors from both be_errno_t and errno sets
author Glenn Lagasse <glenn.lagasse@oracle.com>
date Wed, 04 Aug 2010 12:28:19 -0700
parents
children c0863802718a
comparison
equal deleted inserted replaced
13024:c176c071a066 13025:3c7681e3e323
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 /*
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #ifndef _LIBBE_PRIV_H
27 #define _LIBBE_PRIV_H
28
29 #include <libnvpair.h>
30 #include <libzfs.h>
31 #include <instzones_api.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #define ARCH_LENGTH MAXNAMELEN
38 #define BE_AUTO_NAME_MAX_TRY 3
39 #define BE_AUTO_NAME_DELIM '-'
40 #define BE_CONTAINER_DS_NAME "ROOT"
41 #define BE_POLICY_PROPERTY "org.opensolaris.libbe:policy"
42 #define BE_UUID_PROPERTY "org.opensolaris.libbe:uuid"
43 #define BE_PLCY_STATIC "static"
44 #define BE_PLCY_VOLATILE "volatile"
45 #define BE_GRUB_MENU "/boot/grub/menu.lst"
46 #define BE_SPARC_MENU "/boot/menu.lst"
47 #define BE_GRUB_COMMENT "#============ End of LIBBE entry ============="
48 #define BE_WHITE_SPACE " \t\r\n"
49 #define BE_CAP_FILE "/boot/grub/capability"
50 #define BE_INSTALL_GRUB "/sbin/installgrub"
51 #define BE_STAGE_1 "/boot/grub/stage1"
52 #define BE_STAGE_2 "/boot/grub/stage2"
53 #define ZFS_CLOSE(_zhp) \
54 if (_zhp) { \
55 zfs_close(_zhp); \
56 _zhp = NULL; \
57 }
58
59 #define BE_ZONE_PARENTBE_PROPERTY "org.opensolaris.libbe:parentbe"
60 #define BE_ZONE_ACTIVE_PROPERTY "org.opensolaris.libbe:active"
61 #define BE_ZONE_SUPPORTED_BRANDS "ipkg labeled"
62 #define BE_ZONE_SUPPORTED_BRANDS_DELIM " "
63
64 /* Maximum length for the BE name. */
65 #define BE_NAME_MAX_LEN 64
66
67 #define MAX(a, b) ((a) > (b) ? (a) : (b))
68 #define MIN(a, b) ((a) < (b) ? (a) : (b))
69
70 typedef struct be_transaction_data {
71 char *obe_name; /* Original BE name */
72 char *obe_root_ds; /* Original BE root dataset */
73 char *obe_zpool; /* Original BE pool */
74 char *obe_snap_name; /* Original BE snapshot name */
75 char *obe_altroot; /* Original BE altroot */
76 char *nbe_name; /* New BE name */
77 char *nbe_root_ds; /* New BE root dataset */
78 char *nbe_zpool; /* New BE pool */
79 char *nbe_desc; /* New BE description */
80 nvlist_t *nbe_zfs_props; /* New BE dataset properties */
81 char *policy; /* BE policy type */
82 } be_transaction_data_t;
83
84 typedef struct be_mount_data {
85 char *altroot; /* Location of where to mount BE */
86 boolean_t shared_fs; /* Mount shared file sytsems */
87 boolean_t shared_rw; /* Mount shared file systems rw */
88 } be_mount_data_t;
89
90 typedef struct be_unmount_data {
91 char *altroot; /* Location of where BE is mounted */
92 boolean_t force; /* Forcibly unmount */
93 } be_unmount_data_t;
94
95 typedef struct be_destroy_data {
96 boolean_t destroy_snaps; /* Destroy snapshots of BE */
97 boolean_t force_unmount; /* Forcibly unmount BE if mounted */
98 uuid_t gz_be_uuid; /* UUID of the global zone BE */
99 } be_destroy_data_t;
100
101 typedef struct be_demote_data {
102 zfs_handle_t *clone_zhp; /* clone dataset to promote */
103 time_t origin_creation; /* snapshot creation time of clone */
104 const char *snapshot; /* snapshot of dataset being demoted */
105 boolean_t find_in_BE; /* flag noting to find clone in BE */
106 } be_demote_data_t;
107
108 typedef struct be_fs_list_data {
109 char *altroot;
110 char **fs_list;
111 int fs_num;
112 } be_fs_list_data_t;
113
114 typedef struct be_plcy_list {
115 char *be_plcy_name;
116 int be_num_max;
117 int be_num_min;
118 time_t be_age_max;
119 int be_usage_pcnt;
120 struct be_plcy_list *be_next_plcy;
121 }be_plcy_list_t;
122
123 /* Library globals */
124 extern libzfs_handle_t *g_zfs;
125 extern boolean_t do_print;
126
127 /* be_create.c */
128 int be_set_uuid(char *);
129 int be_get_uuid(const char *, uuid_t *);
130
131 /* be_list.c */
132 int _be_list(char *, be_node_list_t **);
133 int be_get_zone_be_list(char *, char *, be_node_list_t **);
134
135 /* be_mount.c */
136 int _be_mount(char *, char **, int);
137 int _be_unmount(char *, int);
138 int be_mount_pool(zfs_handle_t *, char **, char **, boolean_t *);
139 int be_unmount_pool(zfs_handle_t *, char *, char *);
140 int be_mount_zone_root(zfs_handle_t *, be_mount_data_t *);
141 int be_unmount_zone_root(zfs_handle_t *, be_unmount_data_t *);
142 int be_get_legacy_fs(char *, char *, char *, char *, be_fs_list_data_t *);
143 void be_free_fs_list(be_fs_list_data_t *);
144 char *be_get_ds_from_dir(char *);
145 int be_make_tmp_mountpoint(char **);
146
147 /* be_snapshot.c */
148 int _be_create_snapshot(char *, char **, char *);
149 int _be_destroy_snapshot(char *, char *);
150
151 /* be_utils.c */
152 boolean_t be_zfs_init(void);
153 void be_zfs_fini(void);
154 void be_make_root_ds(const char *, const char *, char *, int);
155 void be_make_container_ds(const char *, char *, int);
156 char *be_make_name_from_ds(const char *, char *);
157 int be_append_menu(char *, char *, char *, char *, char *);
158 int be_remove_menu(char *, char *, char *);
159 int be_update_menu(char *, char *, char *, char *);
160 int be_default_grub_bootfs(const char *, char **);
161 boolean_t be_has_menu_entry(char *, char *, int *);
162 int be_run_cmd(char *, char *, int, char *, int);
163 int be_change_grub_default(char *, char *);
164 int be_update_vfstab(char *, char *, char *, be_fs_list_data_t *, char *);
165 int be_update_zone_vfstab(zfs_handle_t *, char *, char *, char *,
166 be_fs_list_data_t *);
167 int be_maxsize_avail(zfs_handle_t *, uint64_t *);
168 char *be_auto_snap_name(void);
169 char *be_auto_be_name(char *);
170 char *be_auto_zone_be_name(char *, char *);
171 char *be_default_policy(void);
172 boolean_t valid_be_policy(char *);
173 boolean_t be_valid_auto_snap_name(char *);
174 boolean_t be_valid_be_name(const char *);
175 void be_print_err(char *, ...);
176 int be_find_current_be(be_transaction_data_t *);
177 int zfs_err_to_be_err(libzfs_handle_t *);
178 int errno_to_be_err(int);
179
180 /* be_activate.c */
181 int _be_activate(char *);
182 int be_activate_current_be(void);
183 boolean_t be_is_active_on_boot(char *);
184
185 /* be_zones.c */
186 void be_make_zoneroot(char *, char *, int);
187 int be_find_active_zone_root(zfs_handle_t *, char *, char *, int);
188 int be_find_mounted_zone_root(char *, char *, char *, int);
189 boolean_t be_zone_supported(char *);
190 zoneBrandList_t *be_get_supported_brandlist(void);
191 int be_zone_get_parent_uuid(const char *, uuid_t *);
192
193 /* check architecture functions */
194 char *be_get_default_isa(void);
195 boolean_t be_is_isa(char *);
196 boolean_t be_has_grub(void);
197
198 /* callback functions */
199 int be_exists_callback(zpool_handle_t *, void *);
200 int be_find_zpool_callback(zpool_handle_t *, void *);
201 int be_zpool_find_current_be_callback(zpool_handle_t *, void *);
202 int be_zfs_find_current_be_callback(zfs_handle_t *, void *);
203 int be_check_be_roots_callback(zpool_handle_t *, void *);
204
205 #ifdef __cplusplus
206 }
207 #endif
208
209 #endif /* _LIBBE_PRIV_H */