Print this page
4012 Upper limit of zfs set bounds check for refreservation on volumes is too low
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libzfs/common/libzfs.h
+++ new/usr/src/lib/libzfs/common/libzfs.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]
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25 25 * Copyright (c) 2012 by Delphix. All rights reserved.
26 26 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
27 27 * Copyright (c) 2013 Steven Hartland. All rights reserved.
28 + * Copyright 2013 DEY Storage Systems, Inc.
28 29 */
29 30
30 31 #ifndef _LIBZFS_H
31 32 #define _LIBZFS_H
32 33
33 34 #include <assert.h>
34 35 #include <libnvpair.h>
35 36 #include <sys/mnttab.h>
36 37 #include <sys/param.h>
37 38 #include <sys/types.h>
38 39 #include <sys/varargs.h>
39 40 #include <sys/fs/zfs.h>
40 41 #include <sys/avl.h>
41 42 #include <ucred.h>
42 43
43 44 #ifdef __cplusplus
44 45 extern "C" {
45 46 #endif
46 47
47 48 /*
48 49 * Miscellaneous ZFS constants
49 50 */
50 51 #define ZFS_MAXNAMELEN MAXNAMELEN
51 52 #define ZPOOL_MAXNAMELEN MAXNAMELEN
52 53 #define ZFS_MAXPROPLEN MAXPATHLEN
53 54 #define ZPOOL_MAXPROPLEN MAXPATHLEN
54 55
55 56 /*
56 57 * libzfs errors
57 58 */
58 59 typedef enum zfs_error {
59 60 EZFS_SUCCESS = 0, /* no error -- success */
60 61 EZFS_NOMEM = 2000, /* out of memory */
61 62 EZFS_BADPROP, /* invalid property value */
62 63 EZFS_PROPREADONLY, /* cannot set readonly property */
63 64 EZFS_PROPTYPE, /* property does not apply to dataset type */
64 65 EZFS_PROPNONINHERIT, /* property is not inheritable */
65 66 EZFS_PROPSPACE, /* bad quota or reservation */
66 67 EZFS_BADTYPE, /* dataset is not of appropriate type */
67 68 EZFS_BUSY, /* pool or dataset is busy */
68 69 EZFS_EXISTS, /* pool or dataset already exists */
69 70 EZFS_NOENT, /* no such pool or dataset */
70 71 EZFS_BADSTREAM, /* bad backup stream */
71 72 EZFS_DSREADONLY, /* dataset is readonly */
72 73 EZFS_VOLTOOBIG, /* volume is too large for 32-bit system */
73 74 EZFS_INVALIDNAME, /* invalid dataset name */
74 75 EZFS_BADRESTORE, /* unable to restore to destination */
75 76 EZFS_BADBACKUP, /* backup failed */
76 77 EZFS_BADTARGET, /* bad attach/detach/replace target */
77 78 EZFS_NODEVICE, /* no such device in pool */
78 79 EZFS_BADDEV, /* invalid device to add */
79 80 EZFS_NOREPLICAS, /* no valid replicas */
80 81 EZFS_RESILVERING, /* currently resilvering */
81 82 EZFS_BADVERSION, /* unsupported version */
82 83 EZFS_POOLUNAVAIL, /* pool is currently unavailable */
83 84 EZFS_DEVOVERFLOW, /* too many devices in one vdev */
84 85 EZFS_BADPATH, /* must be an absolute path */
85 86 EZFS_CROSSTARGET, /* rename or clone across pool or dataset */
86 87 EZFS_ZONED, /* used improperly in local zone */
87 88 EZFS_MOUNTFAILED, /* failed to mount dataset */
88 89 EZFS_UMOUNTFAILED, /* failed to unmount dataset */
89 90 EZFS_UNSHARENFSFAILED, /* unshare(1M) failed */
90 91 EZFS_SHARENFSFAILED, /* share(1M) failed */
91 92 EZFS_PERM, /* permission denied */
92 93 EZFS_NOSPC, /* out of space */
93 94 EZFS_FAULT, /* bad address */
94 95 EZFS_IO, /* I/O error */
95 96 EZFS_INTR, /* signal received */
96 97 EZFS_ISSPARE, /* device is a hot spare */
97 98 EZFS_INVALCONFIG, /* invalid vdev configuration */
98 99 EZFS_RECURSIVE, /* recursive dependency */
99 100 EZFS_NOHISTORY, /* no history object */
100 101 EZFS_POOLPROPS, /* couldn't retrieve pool props */
101 102 EZFS_POOL_NOTSUP, /* ops not supported for this type of pool */
102 103 EZFS_POOL_INVALARG, /* invalid argument for this pool operation */
103 104 EZFS_NAMETOOLONG, /* dataset name is too long */
104 105 EZFS_OPENFAILED, /* open of device failed */
105 106 EZFS_NOCAP, /* couldn't get capacity */
106 107 EZFS_LABELFAILED, /* write of label failed */
107 108 EZFS_BADWHO, /* invalid permission who */
108 109 EZFS_BADPERM, /* invalid permission */
109 110 EZFS_BADPERMSET, /* invalid permission set name */
110 111 EZFS_NODELEGATION, /* delegated administration is disabled */
111 112 EZFS_UNSHARESMBFAILED, /* failed to unshare over smb */
112 113 EZFS_SHARESMBFAILED, /* failed to share over smb */
113 114 EZFS_BADCACHE, /* bad cache file */
114 115 EZFS_ISL2CACHE, /* device is for the level 2 ARC */
115 116 EZFS_VDEVNOTSUP, /* unsupported vdev type */
116 117 EZFS_NOTSUP, /* ops not supported on this dataset */
117 118 EZFS_ACTIVE_SPARE, /* pool has active shared spare devices */
118 119 EZFS_UNPLAYED_LOGS, /* log device has unplayed logs */
119 120 EZFS_REFTAG_RELE, /* snapshot release: tag not found */
120 121 EZFS_REFTAG_HOLD, /* snapshot hold: tag already exists */
121 122 EZFS_TAGTOOLONG, /* snapshot hold/rele: tag too long */
122 123 EZFS_PIPEFAILED, /* pipe create failed */
123 124 EZFS_THREADCREATEFAILED, /* thread create failed */
124 125 EZFS_POSTSPLIT_ONLINE, /* onlining a disk after splitting it */
125 126 EZFS_SCRUBBING, /* currently scrubbing */
126 127 EZFS_NO_SCRUB, /* no active scrub */
127 128 EZFS_DIFF, /* general failure of zfs diff */
128 129 EZFS_DIFFDATA, /* bad zfs diff data */
129 130 EZFS_POOLREADONLY, /* pool is in read-only mode */
130 131 EZFS_UNKNOWN
131 132 } zfs_error_t;
132 133
133 134 /*
134 135 * The following data structures are all part
135 136 * of the zfs_allow_t data structure which is
136 137 * used for printing 'allow' permissions.
137 138 * It is a linked list of zfs_allow_t's which
138 139 * then contain avl tree's for user/group/sets/...
139 140 * and each one of the entries in those trees have
140 141 * avl tree's for the permissions they belong to and
141 142 * whether they are local,descendent or local+descendent
142 143 * permissions. The AVL trees are used primarily for
143 144 * sorting purposes, but also so that we can quickly find
144 145 * a given user and or permission.
145 146 */
146 147 typedef struct zfs_perm_node {
147 148 avl_node_t z_node;
148 149 char z_pname[MAXPATHLEN];
149 150 } zfs_perm_node_t;
150 151
151 152 typedef struct zfs_allow_node {
152 153 avl_node_t z_node;
153 154 char z_key[MAXPATHLEN]; /* name, such as joe */
154 155 avl_tree_t z_localdescend; /* local+descendent perms */
155 156 avl_tree_t z_local; /* local permissions */
156 157 avl_tree_t z_descend; /* descendent permissions */
157 158 } zfs_allow_node_t;
158 159
159 160 typedef struct zfs_allow {
160 161 struct zfs_allow *z_next;
161 162 char z_setpoint[MAXPATHLEN];
162 163 avl_tree_t z_sets;
163 164 avl_tree_t z_crperms;
164 165 avl_tree_t z_user;
165 166 avl_tree_t z_group;
166 167 avl_tree_t z_everyone;
167 168 } zfs_allow_t;
168 169
169 170 /*
170 171 * Basic handle types
171 172 */
172 173 typedef struct zfs_handle zfs_handle_t;
173 174 typedef struct zpool_handle zpool_handle_t;
174 175 typedef struct libzfs_handle libzfs_handle_t;
175 176
176 177 /*
177 178 * Library initialization
178 179 */
179 180 extern libzfs_handle_t *libzfs_init(void);
180 181 extern void libzfs_fini(libzfs_handle_t *);
181 182
182 183 extern libzfs_handle_t *zpool_get_handle(zpool_handle_t *);
183 184 extern libzfs_handle_t *zfs_get_handle(zfs_handle_t *);
184 185
185 186 extern void libzfs_print_on_error(libzfs_handle_t *, boolean_t);
186 187
187 188 extern void zfs_save_arguments(int argc, char **, char *, int);
188 189 extern int zpool_log_history(libzfs_handle_t *, const char *);
189 190
190 191 extern int libzfs_errno(libzfs_handle_t *);
191 192 extern const char *libzfs_error_action(libzfs_handle_t *);
192 193 extern const char *libzfs_error_description(libzfs_handle_t *);
193 194 extern void libzfs_mnttab_init(libzfs_handle_t *);
194 195 extern void libzfs_mnttab_fini(libzfs_handle_t *);
195 196 extern void libzfs_mnttab_cache(libzfs_handle_t *, boolean_t);
196 197 extern int libzfs_mnttab_find(libzfs_handle_t *, const char *,
197 198 struct mnttab *);
198 199 extern void libzfs_mnttab_add(libzfs_handle_t *, const char *,
199 200 const char *, const char *);
200 201 extern void libzfs_mnttab_remove(libzfs_handle_t *, const char *);
201 202
202 203 /*
203 204 * Basic handle functions
204 205 */
205 206 extern zpool_handle_t *zpool_open(libzfs_handle_t *, const char *);
206 207 extern zpool_handle_t *zpool_open_canfail(libzfs_handle_t *, const char *);
207 208 extern void zpool_close(zpool_handle_t *);
208 209 extern const char *zpool_get_name(zpool_handle_t *);
209 210 extern int zpool_get_state(zpool_handle_t *);
210 211 extern char *zpool_state_to_name(vdev_state_t, vdev_aux_t);
211 212 extern void zpool_free_handles(libzfs_handle_t *);
212 213
213 214 /*
214 215 * Iterate over all active pools in the system.
215 216 */
216 217 typedef int (*zpool_iter_f)(zpool_handle_t *, void *);
217 218 extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *);
218 219
219 220 /*
220 221 * Functions to create and destroy pools
221 222 */
222 223 extern int zpool_create(libzfs_handle_t *, const char *, nvlist_t *,
223 224 nvlist_t *, nvlist_t *);
224 225 extern int zpool_destroy(zpool_handle_t *, const char *);
225 226 extern int zpool_add(zpool_handle_t *, nvlist_t *);
226 227
227 228 typedef struct splitflags {
228 229 /* do not split, but return the config that would be split off */
229 230 int dryrun : 1;
230 231
231 232 /* after splitting, import the pool */
232 233 int import : 1;
233 234 } splitflags_t;
234 235
235 236 /*
236 237 * Functions to manipulate pool and vdev state
237 238 */
238 239 extern int zpool_scan(zpool_handle_t *, pool_scan_func_t);
239 240 extern int zpool_clear(zpool_handle_t *, const char *, nvlist_t *);
240 241 extern int zpool_reguid(zpool_handle_t *);
241 242 extern int zpool_reopen(zpool_handle_t *);
242 243
243 244 extern int zpool_vdev_online(zpool_handle_t *, const char *, int,
244 245 vdev_state_t *);
245 246 extern int zpool_vdev_offline(zpool_handle_t *, const char *, boolean_t);
246 247 extern int zpool_vdev_attach(zpool_handle_t *, const char *,
247 248 const char *, nvlist_t *, int);
248 249 extern int zpool_vdev_detach(zpool_handle_t *, const char *);
249 250 extern int zpool_vdev_remove(zpool_handle_t *, const char *);
250 251 extern int zpool_vdev_split(zpool_handle_t *, char *, nvlist_t **, nvlist_t *,
251 252 splitflags_t);
252 253
253 254 extern int zpool_vdev_fault(zpool_handle_t *, uint64_t, vdev_aux_t);
254 255 extern int zpool_vdev_degrade(zpool_handle_t *, uint64_t, vdev_aux_t);
255 256 extern int zpool_vdev_clear(zpool_handle_t *, uint64_t);
256 257
257 258 extern nvlist_t *zpool_find_vdev(zpool_handle_t *, const char *, boolean_t *,
258 259 boolean_t *, boolean_t *);
259 260 extern nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *,
260 261 boolean_t *, boolean_t *, boolean_t *);
261 262 extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, char *);
262 263
263 264 /*
264 265 * Functions to manage pool properties
265 266 */
266 267 extern int zpool_set_prop(zpool_handle_t *, const char *, const char *);
267 268 extern int zpool_get_prop(zpool_handle_t *, zpool_prop_t, char *,
268 269 size_t proplen, zprop_source_t *);
269 270 extern uint64_t zpool_get_prop_int(zpool_handle_t *, zpool_prop_t,
270 271 zprop_source_t *);
271 272
272 273 extern const char *zpool_prop_to_name(zpool_prop_t);
273 274 extern const char *zpool_prop_values(zpool_prop_t);
274 275
275 276 /*
276 277 * Pool health statistics.
277 278 */
278 279 typedef enum {
279 280 /*
280 281 * The following correspond to faults as defined in the (fault.fs.zfs.*)
281 282 * event namespace. Each is associated with a corresponding message ID.
282 283 */
283 284 ZPOOL_STATUS_CORRUPT_CACHE, /* corrupt /kernel/drv/zpool.cache */
284 285 ZPOOL_STATUS_MISSING_DEV_R, /* missing device with replicas */
285 286 ZPOOL_STATUS_MISSING_DEV_NR, /* missing device with no replicas */
286 287 ZPOOL_STATUS_CORRUPT_LABEL_R, /* bad device label with replicas */
287 288 ZPOOL_STATUS_CORRUPT_LABEL_NR, /* bad device label with no replicas */
288 289 ZPOOL_STATUS_BAD_GUID_SUM, /* sum of device guids didn't match */
289 290 ZPOOL_STATUS_CORRUPT_POOL, /* pool metadata is corrupted */
290 291 ZPOOL_STATUS_CORRUPT_DATA, /* data errors in user (meta)data */
291 292 ZPOOL_STATUS_FAILING_DEV, /* device experiencing errors */
292 293 ZPOOL_STATUS_VERSION_NEWER, /* newer on-disk version */
293 294 ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */
294 295 ZPOOL_STATUS_IO_FAILURE_WAIT, /* failed I/O, failmode 'wait' */
295 296 ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */
296 297 ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */
297 298
298 299 /*
299 300 * If the pool has unsupported features but can still be opened in
300 301 * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the
301 302 * pool has unsupported features but cannot be opened at all, its
302 303 * status is ZPOOL_STATUS_UNSUP_FEAT_READ.
303 304 */
304 305 ZPOOL_STATUS_UNSUP_FEAT_READ, /* unsupported features for read */
305 306 ZPOOL_STATUS_UNSUP_FEAT_WRITE, /* unsupported features for write */
306 307
307 308 /*
308 309 * These faults have no corresponding message ID. At the time we are
309 310 * checking the status, the original reason for the FMA fault (I/O or
310 311 * checksum errors) has been lost.
311 312 */
312 313 ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */
313 314 ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */
314 315
315 316 /*
316 317 * The following are not faults per se, but still an error possibly
317 318 * requiring administrative attention. There is no corresponding
318 319 * message ID.
319 320 */
320 321 ZPOOL_STATUS_VERSION_OLDER, /* older legacy on-disk version */
321 322 ZPOOL_STATUS_FEAT_DISABLED, /* supported features are disabled */
322 323 ZPOOL_STATUS_RESILVERING, /* device being resilvered */
323 324 ZPOOL_STATUS_OFFLINE_DEV, /* device online */
324 325 ZPOOL_STATUS_REMOVED_DEV, /* removed device */
325 326
326 327 /*
327 328 * Finally, the following indicates a healthy pool.
328 329 */
329 330 ZPOOL_STATUS_OK
330 331 } zpool_status_t;
331 332
332 333 extern zpool_status_t zpool_get_status(zpool_handle_t *, char **);
333 334 extern zpool_status_t zpool_import_status(nvlist_t *, char **);
334 335 extern void zpool_dump_ddt(const ddt_stat_t *dds, const ddt_histogram_t *ddh);
335 336
336 337 /*
337 338 * Statistics and configuration functions.
338 339 */
339 340 extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **);
340 341 extern nvlist_t *zpool_get_features(zpool_handle_t *);
341 342 extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *);
342 343 extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **);
343 344
344 345 /*
345 346 * Import and export functions
346 347 */
347 348 extern int zpool_export(zpool_handle_t *, boolean_t, const char *);
348 349 extern int zpool_export_force(zpool_handle_t *, const char *);
349 350 extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *,
350 351 char *altroot);
351 352 extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *,
352 353 nvlist_t *, int);
353 354 extern void zpool_print_unsup_feat(nvlist_t *config);
354 355
355 356 /*
356 357 * Search for pools to import
357 358 */
358 359
359 360 typedef struct importargs {
360 361 char **path; /* a list of paths to search */
361 362 int paths; /* number of paths to search */
362 363 char *poolname; /* name of a pool to find */
363 364 uint64_t guid; /* guid of a pool to find */
364 365 char *cachefile; /* cachefile to use for import */
365 366 int can_be_active : 1; /* can the pool be active? */
366 367 int unique : 1; /* does 'poolname' already exist? */
367 368 int exists : 1; /* set on return if pool already exists */
368 369 } importargs_t;
369 370
370 371 extern nvlist_t *zpool_search_import(libzfs_handle_t *, importargs_t *);
371 372
372 373 /* legacy pool search routines */
373 374 extern nvlist_t *zpool_find_import(libzfs_handle_t *, int, char **);
374 375 extern nvlist_t *zpool_find_import_cached(libzfs_handle_t *, const char *,
375 376 char *, uint64_t);
376 377
377 378 /*
378 379 * Miscellaneous pool functions
379 380 */
380 381 struct zfs_cmd;
381 382
382 383 extern const char *zfs_history_event_names[];
383 384
384 385 extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *,
385 386 boolean_t verbose);
386 387 extern int zpool_upgrade(zpool_handle_t *, uint64_t);
387 388 extern int zpool_get_history(zpool_handle_t *, nvlist_t **);
388 389 extern int zpool_history_unpack(char *, uint64_t, uint64_t *,
389 390 nvlist_t ***, uint_t *);
390 391 extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *,
391 392 size_t len);
392 393 extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *);
393 394 extern int zpool_get_physpath(zpool_handle_t *, char *, size_t);
394 395 extern void zpool_explain_recover(libzfs_handle_t *, const char *, int,
395 396 nvlist_t *);
396 397
397 398 /*
398 399 * Basic handle manipulations. These functions do not create or destroy the
399 400 * underlying datasets, only the references to them.
400 401 */
401 402 extern zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int);
402 403 extern zfs_handle_t *zfs_handle_dup(zfs_handle_t *);
403 404 extern void zfs_close(zfs_handle_t *);
404 405 extern zfs_type_t zfs_get_type(const zfs_handle_t *);
405 406 extern const char *zfs_get_name(const zfs_handle_t *);
406 407 extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *);
407 408
408 409 /*
409 410 * Property management functions. Some functions are shared with the kernel,
410 411 * and are found in sys/fs/zfs.h.
411 412 */
412 413
413 414 /*
414 415 * zfs dataset property management
415 416 */
416 417 extern const char *zfs_prop_default_string(zfs_prop_t);
417 418 extern uint64_t zfs_prop_default_numeric(zfs_prop_t);
418 419 extern const char *zfs_prop_column_name(zfs_prop_t);
419 420 extern boolean_t zfs_prop_align_right(zfs_prop_t);
420 421
421 422 extern nvlist_t *zfs_valid_proplist(libzfs_handle_t *, zfs_type_t,
422 423 nvlist_t *, uint64_t, zfs_handle_t *, const char *);
423 424
424 425 extern const char *zfs_prop_to_name(zfs_prop_t);
425 426 extern int zfs_prop_set(zfs_handle_t *, const char *, const char *);
426 427 extern int zfs_prop_get(zfs_handle_t *, zfs_prop_t, char *, size_t,
427 428 zprop_source_t *, char *, size_t, boolean_t);
428 429 extern int zfs_prop_get_recvd(zfs_handle_t *, const char *, char *, size_t,
429 430 boolean_t);
430 431 extern int zfs_prop_get_numeric(zfs_handle_t *, zfs_prop_t, uint64_t *,
431 432 zprop_source_t *, char *, size_t);
432 433 extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname,
433 434 uint64_t *propvalue);
434 435 extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
435 436 char *propbuf, int proplen, boolean_t literal);
436 437 extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname,
437 438 uint64_t *propvalue);
438 439 extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
439 440 char *propbuf, int proplen, boolean_t literal);
440 441 extern int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname,
441 442 char *buf, size_t len);
442 443 extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t);
443 444 extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t);
444 445 extern const char *zfs_prop_values(zfs_prop_t);
445 446 extern int zfs_prop_is_string(zfs_prop_t prop);
446 447 extern nvlist_t *zfs_get_user_props(zfs_handle_t *);
447 448 extern nvlist_t *zfs_get_recvd_props(zfs_handle_t *);
448 449 extern nvlist_t *zfs_get_clones_nvl(zfs_handle_t *);
449 450
450 451
451 452 typedef struct zprop_list {
452 453 int pl_prop;
453 454 char *pl_user_prop;
454 455 struct zprop_list *pl_next;
455 456 boolean_t pl_all;
456 457 size_t pl_width;
457 458 size_t pl_recvd_width;
458 459 boolean_t pl_fixed;
459 460 } zprop_list_t;
460 461
461 462 extern int zfs_expand_proplist(zfs_handle_t *, zprop_list_t **, boolean_t);
462 463 extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *);
463 464
464 465 #define ZFS_MOUNTPOINT_NONE "none"
465 466 #define ZFS_MOUNTPOINT_LEGACY "legacy"
466 467
467 468 #define ZFS_FEATURE_DISABLED "disabled"
468 469 #define ZFS_FEATURE_ENABLED "enabled"
469 470 #define ZFS_FEATURE_ACTIVE "active"
470 471
471 472 #define ZFS_UNSUPPORTED_INACTIVE "inactive"
472 473 #define ZFS_UNSUPPORTED_READONLY "readonly"
473 474
474 475 /*
475 476 * zpool property management
476 477 */
477 478 extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **);
478 479 extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *,
479 480 size_t);
480 481 extern const char *zpool_prop_default_string(zpool_prop_t);
481 482 extern uint64_t zpool_prop_default_numeric(zpool_prop_t);
482 483 extern const char *zpool_prop_column_name(zpool_prop_t);
483 484 extern boolean_t zpool_prop_align_right(zpool_prop_t);
484 485
485 486 /*
486 487 * Functions shared by zfs and zpool property management.
487 488 */
488 489 extern int zprop_iter(zprop_func func, void *cb, boolean_t show_all,
489 490 boolean_t ordered, zfs_type_t type);
490 491 extern int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **,
491 492 zfs_type_t);
492 493 extern void zprop_free_list(zprop_list_t *);
493 494
494 495 #define ZFS_GET_NCOLS 5
495 496
496 497 typedef enum {
497 498 GET_COL_NONE,
498 499 GET_COL_NAME,
499 500 GET_COL_PROPERTY,
500 501 GET_COL_VALUE,
501 502 GET_COL_RECVD,
502 503 GET_COL_SOURCE
503 504 } zfs_get_column_t;
504 505
505 506 /*
506 507 * Functions for printing zfs or zpool properties
507 508 */
508 509 typedef struct zprop_get_cbdata {
509 510 int cb_sources;
510 511 zfs_get_column_t cb_columns[ZFS_GET_NCOLS];
511 512 int cb_colwidths[ZFS_GET_NCOLS + 1];
512 513 boolean_t cb_scripted;
513 514 boolean_t cb_literal;
514 515 boolean_t cb_first;
515 516 zprop_list_t *cb_proplist;
516 517 zfs_type_t cb_type;
517 518 } zprop_get_cbdata_t;
518 519
519 520 void zprop_print_one_property(const char *, zprop_get_cbdata_t *,
520 521 const char *, const char *, zprop_source_t, const char *,
521 522 const char *);
522 523
523 524 /*
524 525 * Iterator functions.
525 526 */
526 527 typedef int (*zfs_iter_f)(zfs_handle_t *, void *);
527 528 extern int zfs_iter_root(libzfs_handle_t *, zfs_iter_f, void *);
528 529 extern int zfs_iter_children(zfs_handle_t *, zfs_iter_f, void *);
529 530 extern int zfs_iter_dependents(zfs_handle_t *, boolean_t, zfs_iter_f, void *);
530 531 extern int zfs_iter_filesystems(zfs_handle_t *, zfs_iter_f, void *);
531 532 extern int zfs_iter_snapshots(zfs_handle_t *, zfs_iter_f, void *);
532 533 extern int zfs_iter_snapshots_sorted(zfs_handle_t *, zfs_iter_f, void *);
533 534 extern int zfs_iter_snapspec(zfs_handle_t *, const char *, zfs_iter_f, void *);
534 535
535 536 typedef struct get_all_cb {
536 537 zfs_handle_t **cb_handles;
537 538 size_t cb_alloc;
538 539 size_t cb_used;
539 540 boolean_t cb_verbose;
540 541 int (*cb_getone)(zfs_handle_t *, void *);
541 542 } get_all_cb_t;
542 543
543 544 void libzfs_add_handle(get_all_cb_t *, zfs_handle_t *);
544 545 int libzfs_dataset_cmp(const void *, const void *);
545 546
546 547 /*
547 548 * Functions to create and destroy datasets.
548 549 */
549 550 extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t,
550 551 nvlist_t *);
551 552 extern int zfs_create_ancestors(libzfs_handle_t *, const char *);
552 553 extern int zfs_destroy(zfs_handle_t *, boolean_t);
553 554 extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t);
554 555 extern int zfs_destroy_snaps_nvl(libzfs_handle_t *, nvlist_t *, boolean_t);
555 556 extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *);
556 557 extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, nvlist_t *);
557 558 extern int zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps,
558 559 nvlist_t *props);
559 560 extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t);
560 561 extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t);
561 562
562 563 typedef struct sendflags {
563 564 /* print informational messages (ie, -v was specified) */
564 565 boolean_t verbose;
565 566
566 567 /* recursive send (ie, -R) */
567 568 boolean_t replicate;
568 569
569 570 /* for incrementals, do all intermediate snapshots */
570 571 boolean_t doall;
571 572
572 573 /* if dataset is a clone, do incremental from its origin */
573 574 boolean_t fromorigin;
574 575
575 576 /* do deduplication */
576 577 boolean_t dedup;
577 578
578 579 /* send properties (ie, -p) */
579 580 boolean_t props;
580 581
581 582 /* do not send (no-op, ie. -n) */
582 583 boolean_t dryrun;
583 584
584 585 /* parsable verbose output (ie. -P) */
585 586 boolean_t parsable;
586 587
587 588 /* show progress (ie. -v) */
588 589 boolean_t progress;
589 590 } sendflags_t;
590 591
591 592 typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *);
592 593
↓ open down ↓ |
555 lines elided |
↑ open up ↑ |
593 594 extern int zfs_send(zfs_handle_t *, const char *, const char *,
594 595 sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **);
595 596
596 597 extern int zfs_promote(zfs_handle_t *);
597 598 extern int zfs_hold(zfs_handle_t *, const char *, const char *,
598 599 boolean_t, int);
599 600 extern int zfs_hold_nvl(zfs_handle_t *, int, nvlist_t *);
600 601 extern int zfs_release(zfs_handle_t *, const char *, const char *, boolean_t);
601 602 extern int zfs_get_holds(zfs_handle_t *, nvlist_t **);
602 603 extern uint64_t zvol_volsize_to_reservation(uint64_t, nvlist_t *);
604 +extern uint64_t zvol_volsize_to_reservation_impl(uint64_t volsize,
605 + uint64_t volblocksize, int ncopies);
603 606
604 607 typedef int (*zfs_userspace_cb_t)(void *arg, const char *domain,
605 608 uid_t rid, uint64_t space);
606 609
607 610 extern int zfs_userspace(zfs_handle_t *, zfs_userquota_prop_t,
608 611 zfs_userspace_cb_t, void *);
609 612
610 613 extern int zfs_get_fsacl(zfs_handle_t *, nvlist_t **);
611 614 extern int zfs_set_fsacl(zfs_handle_t *, boolean_t, nvlist_t *);
612 615
613 616 typedef struct recvflags {
614 617 /* print informational messages (ie, -v was specified) */
615 618 boolean_t verbose;
616 619
617 620 /* the destination is a prefix, not the exact fs (ie, -d) */
618 621 boolean_t isprefix;
619 622
620 623 /*
621 624 * Only the tail of the sent snapshot path is appended to the
622 625 * destination to determine the received snapshot name (ie, -e).
623 626 */
624 627 boolean_t istail;
625 628
626 629 /* do not actually do the recv, just check if it would work (ie, -n) */
627 630 boolean_t dryrun;
628 631
629 632 /* rollback/destroy filesystems as necessary (eg, -F) */
630 633 boolean_t force;
631 634
632 635 /* set "canmount=off" on all modified filesystems */
633 636 boolean_t canmountoff;
634 637
635 638 /* byteswap flag is used internally; callers need not specify */
636 639 boolean_t byteswap;
637 640
638 641 /* do not mount file systems as they are extracted (private) */
639 642 boolean_t nomount;
640 643 } recvflags_t;
641 644
642 645 extern int zfs_receive(libzfs_handle_t *, const char *, recvflags_t *,
643 646 int, avl_tree_t *);
644 647
645 648 typedef enum diff_flags {
646 649 ZFS_DIFF_PARSEABLE = 0x1,
647 650 ZFS_DIFF_TIMESTAMP = 0x2,
648 651 ZFS_DIFF_CLASSIFY = 0x4
649 652 } diff_flags_t;
650 653
651 654 extern int zfs_show_diffs(zfs_handle_t *, int, const char *, const char *,
652 655 int);
653 656
654 657 /*
655 658 * Miscellaneous functions.
656 659 */
657 660 extern const char *zfs_type_to_name(zfs_type_t);
658 661 extern void zfs_refresh_properties(zfs_handle_t *);
659 662 extern int zfs_name_valid(const char *, zfs_type_t);
660 663 extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, char *, zfs_type_t);
661 664 extern boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *,
662 665 zfs_type_t);
663 666 extern int zfs_spa_version(zfs_handle_t *, int *);
664 667
665 668 /*
666 669 * Mount support functions.
667 670 */
668 671 extern boolean_t is_mounted(libzfs_handle_t *, const char *special, char **);
669 672 extern boolean_t zfs_is_mounted(zfs_handle_t *, char **);
670 673 extern int zfs_mount(zfs_handle_t *, const char *, int);
671 674 extern int zfs_unmount(zfs_handle_t *, const char *, int);
672 675 extern int zfs_unmountall(zfs_handle_t *, int);
673 676
674 677 /*
675 678 * Share support functions.
676 679 */
677 680 extern boolean_t zfs_is_shared(zfs_handle_t *);
678 681 extern int zfs_share(zfs_handle_t *);
679 682 extern int zfs_unshare(zfs_handle_t *);
680 683
681 684 /*
682 685 * Protocol-specific share support functions.
683 686 */
684 687 extern boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **);
685 688 extern boolean_t zfs_is_shared_smb(zfs_handle_t *, char **);
686 689 extern int zfs_share_nfs(zfs_handle_t *);
687 690 extern int zfs_share_smb(zfs_handle_t *);
688 691 extern int zfs_shareall(zfs_handle_t *);
689 692 extern int zfs_unshare_nfs(zfs_handle_t *, const char *);
690 693 extern int zfs_unshare_smb(zfs_handle_t *, const char *);
691 694 extern int zfs_unshareall_nfs(zfs_handle_t *);
692 695 extern int zfs_unshareall_smb(zfs_handle_t *);
693 696 extern int zfs_unshareall_bypath(zfs_handle_t *, const char *);
694 697 extern int zfs_unshareall(zfs_handle_t *);
695 698 extern int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *,
696 699 void *, void *, int, zfs_share_op_t);
697 700
698 701 /*
699 702 * When dealing with nvlists, verify() is extremely useful
700 703 */
701 704 #ifdef NDEBUG
702 705 #define verify(EX) ((void)(EX))
703 706 #else
704 707 #define verify(EX) assert(EX)
705 708 #endif
706 709
707 710 /*
708 711 * Utility function to convert a number to a human-readable form.
709 712 */
710 713 extern void zfs_nicenum(uint64_t, char *, size_t);
711 714 extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *);
712 715
713 716 /*
714 717 * Given a device or file, determine if it is part of a pool.
715 718 */
716 719 extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **,
717 720 boolean_t *);
718 721
719 722 /*
720 723 * Label manipulation.
721 724 */
722 725 extern int zpool_read_label(int, nvlist_t **);
723 726 extern int zpool_clear_label(int);
724 727
725 728 /* is this zvol valid for use as a dump device? */
726 729 extern int zvol_check_dump_config(char *);
727 730
728 731 /*
729 732 * Management interfaces for SMB ACL files
730 733 */
731 734
732 735 int zfs_smb_acl_add(libzfs_handle_t *, char *, char *, char *);
733 736 int zfs_smb_acl_remove(libzfs_handle_t *, char *, char *, char *);
734 737 int zfs_smb_acl_purge(libzfs_handle_t *, char *, char *);
735 738 int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, char *);
736 739
737 740 /*
738 741 * Enable and disable datasets within a pool by mounting/unmounting and
739 742 * sharing/unsharing them.
740 743 */
741 744 extern int zpool_enable_datasets(zpool_handle_t *, const char *, int);
742 745 extern int zpool_disable_datasets(zpool_handle_t *, boolean_t);
743 746
744 747 /*
745 748 * Mappings between vdev and FRU.
746 749 */
747 750 extern void libzfs_fru_refresh(libzfs_handle_t *);
748 751 extern const char *libzfs_fru_lookup(libzfs_handle_t *, const char *);
749 752 extern const char *libzfs_fru_devpath(libzfs_handle_t *, const char *);
750 753 extern boolean_t libzfs_fru_compare(libzfs_handle_t *, const char *,
751 754 const char *);
752 755 extern boolean_t libzfs_fru_notself(libzfs_handle_t *, const char *);
753 756 extern int zpool_fru_set(zpool_handle_t *, uint64_t, const char *);
754 757
755 758 #ifdef __cplusplus
756 759 }
757 760 #endif
758 761
759 762 #endif /* _LIBZFS_H */
↓ open down ↓ |
147 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX