Print this page
5679 be_sort_list(): Possible null pointer dereference
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libbe/common/libbe.h
+++ new/usr/src/lib/libbe/common/libbe.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 /*
27 27 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
28 28 * Copyright 2015 Toomas Soome <tsoome@me.com>
29 + * Copyright 2015 Gary Mills
29 30 */
30 31
31 32 #ifndef _LIBBE_H
32 33 #define _LIBBE_H
33 34
34 35 #include <libnvpair.h>
35 36 #include <uuid/uuid.h>
36 37 #include <libzfs.h>
37 38
38 39 #ifdef __cplusplus
39 40 extern "C" {
40 41 #endif
41 42
42 43 #define BE_ATTR_ORIG_BE_NAME "orig_be_name"
43 44 #define BE_ATTR_ORIG_BE_POOL "orig_be_pool"
44 45 #define BE_ATTR_SNAP_NAME "snap_name"
45 46
46 47 #define BE_ATTR_NEW_BE_NAME "new_be_name"
47 48 #define BE_ATTR_NEW_BE_POOL "new_be_pool"
48 49 #define BE_ATTR_NEW_BE_DESC "new_be_desc"
49 50 #define BE_ATTR_POLICY "policy"
50 51 #define BE_ATTR_ZFS_PROPERTIES "zfs_properties"
51 52
52 53 #define BE_ATTR_FS_NAMES "fs_names"
53 54 #define BE_ATTR_FS_NUM "fs_num"
54 55 #define BE_ATTR_SHARED_FS_NAMES "shared_fs_names"
55 56 #define BE_ATTR_SHARED_FS_NUM "shared_fs_num"
56 57
57 58 #define BE_ATTR_MOUNTPOINT "mountpoint"
58 59 #define BE_ATTR_MOUNT_FLAGS "mount_flags"
59 60 #define BE_ATTR_UNMOUNT_FLAGS "unmount_flags"
60 61 #define BE_ATTR_DESTROY_FLAGS "destroy_flags"
61 62 #define BE_ATTR_ROOT_DS "root_ds"
62 63 #define BE_ATTR_UUID_STR "uuid_str"
63 64
64 65 #define BE_ATTR_ACTIVE "active"
65 66 #define BE_ATTR_ACTIVE_ON_BOOT "active_boot"
66 67 #define BE_ATTR_GLOBAL_ACTIVE "global_active"
67 68 #define BE_ATTR_SPACE "space_used"
68 69 #define BE_ATTR_DATASET "dataset"
69 70 #define BE_ATTR_STATUS "status"
70 71 #define BE_ATTR_DATE "date"
71 72 #define BE_ATTR_MOUNTED "mounted"
72 73
73 74 /*
74 75 * libbe error codes
75 76 *
76 77 * NOTE: there is a copy of this enum in beadm/messages.py. To keep these
77 78 * in sync please make sure to add any new error messages at the end
78 79 * of this enumeration.
79 80 */
80 81 enum {
81 82 BE_SUCCESS = 0,
82 83 BE_ERR_ACCESS = 4000, /* permission denied */
83 84 BE_ERR_ACTIVATE_CURR, /* Activation of current BE failed */
84 85 BE_ERR_AUTONAME, /* auto naming failed */
85 86 BE_ERR_BE_NOENT, /* No such BE */
86 87 BE_ERR_BUSY, /* mount busy */
87 88 BE_ERR_CANCELED, /* operation canceled */
88 89 BE_ERR_CLONE, /* BE clone failed */
89 90 BE_ERR_COPY, /* BE copy failed */
90 91 BE_ERR_CREATDS, /* dataset creation failed */
91 92 BE_ERR_CURR_BE_NOT_FOUND, /* Can't find current BE */
92 93 BE_ERR_DESTROY, /* failed to destroy BE or snapshot */
93 94 BE_ERR_DEMOTE, /* BE demotion failed */
94 95 BE_ERR_DSTYPE, /* invalid dataset type */
95 96 BE_ERR_BE_EXISTS, /* BE exists */
96 97 BE_ERR_INIT, /* be_zfs_init failed */
97 98 BE_ERR_INTR, /* interupted system call */
98 99 BE_ERR_INVAL, /* invalid argument */
99 100 BE_ERR_INVALPROP, /* invalid property for dataset */
100 101 BE_ERR_INVALMOUNTPOINT, /* Unexpected mountpoint */
101 102 BE_ERR_MOUNT, /* mount failed */
102 103 BE_ERR_MOUNTED, /* already mounted */
103 104 BE_ERR_NAMETOOLONG, /* name > BUFSIZ */
104 105 BE_ERR_NOENT, /* Doesn't exist */
105 106 BE_ERR_POOL_NOENT, /* No such pool */
106 107 BE_ERR_NODEV, /* No such device */
107 108 BE_ERR_NOTMOUNTED, /* File system not mounted */
108 109 BE_ERR_NOMEM, /* not enough memory */
109 110 BE_ERR_NONINHERIT, /* property is not inheritable for BE dataset */
110 111 BE_ERR_NXIO, /* No such device or address */
111 112 BE_ERR_NOSPC, /* No space on device */
112 113 BE_ERR_NOTSUP, /* Operation not supported */
113 114 BE_ERR_OPEN, /* open failed */
114 115 BE_ERR_PERM, /* Not owner */
115 116 BE_ERR_UNAVAIL, /* The BE is currently unavailable */
116 117 BE_ERR_PROMOTE, /* BE promotion failed */
117 118 BE_ERR_ROFS, /* read only file system */
118 119 BE_ERR_READONLYDS, /* read only dataset */
119 120 BE_ERR_READONLYPROP, /* read only property */
120 121 BE_ERR_SS_EXISTS, /* snapshot exists */
121 122 BE_ERR_SS_NOENT, /* No such snapshot */
122 123 BE_ERR_UMOUNT, /* unmount failed */
123 124 BE_ERR_UMOUNT_CURR_BE, /* Can't unmount current BE */
124 125 BE_ERR_UMOUNT_SHARED, /* unmount of shared File System failed */
125 126 BE_ERR_UNKNOWN, /* Unknown error */
126 127 BE_ERR_ZFS, /* ZFS returned an error */
127 128 BE_ERR_DESTROY_CURR_BE, /* Cannot destroy current BE */
128 129 BE_ERR_GEN_UUID, /* Failed to generate uuid */
129 130 BE_ERR_PARSE_UUID, /* Failed to parse uuid */
130 131 BE_ERR_NO_UUID, /* BE has no uuid */
131 132 BE_ERR_ZONE_NO_PARENTBE, /* Zone root dataset has no parent uuid */
132 133 BE_ERR_ZONE_MULTIPLE_ACTIVE, /* Zone has multiple active roots */
133 134 BE_ERR_ZONE_NO_ACTIVE_ROOT, /* Zone has no active root for this BE */
134 135 BE_ERR_ZONE_ROOT_NOT_LEGACY, /* Zone root dataset mntpt is not legacy */
135 136 BE_ERR_NO_MOUNTED_ZONE, /* Zone not mounted in alternate BE */
136 137 BE_ERR_MOUNT_ZONEROOT, /* Failed to mount a zone root */
137 138 BE_ERR_UMOUNT_ZONEROOT, /* Failed to unmount a zone root */
138 139 BE_ERR_ZONES_UNMOUNT, /* Unable to unmount a zone. */
139 140 BE_ERR_FAULT, /* Bad Address */
140 141 BE_ERR_RENAME_ACTIVE, /* Renaming the active BE is not supported */
141 142 BE_ERR_NO_MENU, /* Missing boot menu file */
142 143 BE_ERR_DEV_BUSY, /* Device is Busy */
143 144 BE_ERR_BAD_MENU_PATH, /* Invalid path for menu.lst file */
144 145 BE_ERR_ZONE_SS_EXISTS, /* zone snapshot already exists */
145 146 BE_ERR_ADD_SPLASH_ICT, /* Add_splash_image ICT failed */
146 147 BE_ERR_BOOTFILE_INST, /* Error installing boot files */
147 148 BE_ERR_EXTCMD /* External command error */
148 149 } be_errno_t;
149 150
150 151 /*
151 152 * Data structures used to return the listing and information of BEs.
152 153 */
153 154 typedef struct be_dataset_list {
154 155 uint64_t be_ds_space_used;
155 156 boolean_t be_ds_mounted;
156 157 char *be_dataset_name;
157 158 time_t be_ds_creation; /* Date/time stamp when created */
158 159 char *be_ds_mntpt;
159 160 char *be_ds_plcy_type; /* cleanup policy type */
160 161 struct be_dataset_list *be_next_dataset;
161 162 } be_dataset_list_t;
162 163
163 164 typedef struct be_snapshot_list {
164 165 uint64_t be_snapshot_space_used; /* bytes of disk space used */
165 166 char *be_snapshot_name;
166 167 time_t be_snapshot_creation; /* Date/time stamp when created */
167 168 char *be_snapshot_type; /* cleanup policy type */
168 169 struct be_snapshot_list *be_next_snapshot;
169 170 } be_snapshot_list_t;
170 171
171 172 typedef struct be_node_list {
172 173 boolean_t be_mounted; /* is BE currently mounted */
173 174 boolean_t be_active_on_boot; /* is this BE active on boot */
174 175 boolean_t be_active; /* is this BE active currently */
175 176 boolean_t be_global_active; /* is zone's BE associated with */
176 177 /* an active global BE */
177 178 uint64_t be_space_used;
178 179 char *be_node_name;
179 180 char *be_rpool;
180 181 char *be_root_ds;
181 182 char *be_mntpt;
182 183 char *be_policy_type; /* cleanup policy type */
183 184 char *be_uuid_str; /* string representation of uuid */
184 185 time_t be_node_creation; /* Date/time stamp when created */
185 186 struct be_dataset_list *be_node_datasets;
186 187 uint_t be_node_num_datasets;
187 188 struct be_snapshot_list *be_node_snapshots;
188 189 uint_t be_node_num_snapshots;
189 190 struct be_node_list *be_next_node;
190 191 } be_node_list_t;
191 192
192 193 /* Flags used with mounting a BE */
193 194 #define BE_MOUNT_FLAG_NULL 0x00000000
194 195 #define BE_MOUNT_FLAG_SHARED_FS 0x00000001
195 196 #define BE_MOUNT_FLAG_SHARED_RW 0x00000002
196 197 #define BE_MOUNT_FLAG_NO_ZONES 0x00000004
197 198
198 199 /* Flags used with unmounting a BE */
199 200 #define BE_UNMOUNT_FLAG_NULL 0x00000000
200 201 #define BE_UNMOUNT_FLAG_FORCE 0x00000001
201 202
202 203 /* Flags used with destroying a BE */
203 204 #define BE_DESTROY_FLAG_NULL 0x00000000
204 205 #define BE_DESTROY_FLAG_SNAPSHOTS 0x00000001
205 206 #define BE_DESTROY_FLAG_FORCE_UNMOUNT 0x00000002
206 207
207 208 /* sort rules for be_sort() */
208 209 typedef enum {
209 210 BE_SORT_UNSPECIFIED = -1,
210 211 BE_SORT_DATE = 0,
211 212 BE_SORT_DATE_REV,
212 213 BE_SORT_NAME,
213 214 BE_SORT_NAME_REV,
214 215 BE_SORT_SPACE,
215 216 BE_SORT_SPACE_REV
216 217 } be_sort_t;
217 218
218 219 /*
219 220 * BE functions
220 221 */
221 222 int be_init(nvlist_t *);
222 223 int be_destroy(nvlist_t *);
223 224 int be_copy(nvlist_t *);
224 225
225 226 int be_mount(nvlist_t *);
226 227 int be_unmount(nvlist_t *);
227 228
228 229 int be_rename(nvlist_t *);
229 230
230 231 int be_activate(nvlist_t *);
231 232
232 233 int be_create_snapshot(nvlist_t *);
↓ open down ↓ |
194 lines elided |
↑ open up ↑ |
233 234 int be_destroy_snapshot(nvlist_t *);
234 235 int be_rollback(nvlist_t *);
235 236
236 237 /*
237 238 * Functions for listing and getting information about existing BEs.
238 239 */
239 240 int be_list(char *, be_node_list_t **);
240 241 void be_free_list(be_node_list_t *);
241 242 int be_max_avail(char *, uint64_t *);
242 243 char *be_err_to_str(int);
243 -void be_sort(be_node_list_t **, int);
244 +int be_sort(be_node_list_t **, int);
244 245
245 246 /*
246 247 * Library functions
247 248 */
248 249 void libbe_print_errors(boolean_t);
249 250
250 251 #ifdef __cplusplus
251 252 }
252 253 #endif
253 254
254 255 #endif /* _LIBBE_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX