libzfs_core.c (248461) | libzfs_core.c (248498) |
---|---|
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 --- 142 unchanged lines hidden (view full) --- 151 } 152#endif 153 154 packed = fnvlist_pack(source, &size); 155 zc.zc_nvlist_src = (uint64_t)(uintptr_t)packed; 156 zc.zc_nvlist_src_size = size; 157 158 if (resultp != NULL) { | 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 --- 142 unchanged lines hidden (view full) --- 151 } 152#endif 153 154 packed = fnvlist_pack(source, &size); 155 zc.zc_nvlist_src = (uint64_t)(uintptr_t)packed; 156 zc.zc_nvlist_src_size = size; 157 158 if (resultp != NULL) { |
159 *resultp = NULL; |
|
159 zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024); 160 zc.zc_nvlist_dst = (uint64_t)(uintptr_t) 161 malloc(zc.zc_nvlist_dst_size); 162#ifdef illumos 163 if (zc.zc_nvlist_dst == NULL) { 164#else 165 if (zc.zc_nvlist_dst == 0) { 166#endif --- 24 unchanged lines hidden (view full) --- 191 192#ifdef __FreeBSD__ 193 if (zfs_ioctl_version < ZFS_IOCVER_LZC) 194 lzc_compat_post(&zc, ioc); 195#endif 196 if (zc.zc_nvlist_dst_filled) { 197 *resultp = fnvlist_unpack((void *)(uintptr_t)zc.zc_nvlist_dst, 198 zc.zc_nvlist_dst_size); | 160 zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024); 161 zc.zc_nvlist_dst = (uint64_t)(uintptr_t) 162 malloc(zc.zc_nvlist_dst_size); 163#ifdef illumos 164 if (zc.zc_nvlist_dst == NULL) { 165#else 166 if (zc.zc_nvlist_dst == 0) { 167#endif --- 24 unchanged lines hidden (view full) --- 192 193#ifdef __FreeBSD__ 194 if (zfs_ioctl_version < ZFS_IOCVER_LZC) 195 lzc_compat_post(&zc, ioc); 196#endif 197 if (zc.zc_nvlist_dst_filled) { 198 *resultp = fnvlist_unpack((void *)(uintptr_t)zc.zc_nvlist_dst, 199 zc.zc_nvlist_dst_size); |
199 } else if (resultp != NULL) { 200 *resultp = NULL; | |
201 } 202#ifdef __FreeBSD__ 203 if (zfs_ioctl_version < ZFS_IOCVER_LZC) 204 lzc_compat_outnvl(&zc, ioc, resultp); 205#endif 206out: 207#ifdef __FreeBSD__ 208 if (zfs_ioctl_version < ZFS_IOCVER_LZC) { --- 42 unchanged lines hidden (view full) --- 251 * 252 * The props nvlist is properties to set. Currently only user properties 253 * are supported. { user:prop_name -> string value } 254 * 255 * The returned results nvlist will have an entry for each snapshot that failed. 256 * The value will be the (int32) error code. 257 * 258 * The return value will be 0 if all snapshots were created, otherwise it will | 200 } 201#ifdef __FreeBSD__ 202 if (zfs_ioctl_version < ZFS_IOCVER_LZC) 203 lzc_compat_outnvl(&zc, ioc, resultp); 204#endif 205out: 206#ifdef __FreeBSD__ 207 if (zfs_ioctl_version < ZFS_IOCVER_LZC) { --- 42 unchanged lines hidden (view full) --- 250 * 251 * The props nvlist is properties to set. Currently only user properties 252 * are supported. { user:prop_name -> string value } 253 * 254 * The returned results nvlist will have an entry for each snapshot that failed. 255 * The value will be the (int32) error code. 256 * 257 * The return value will be 0 if all snapshots were created, otherwise it will |
259 * be the errno of a (undetermined) snapshot that failed. | 258 * be the errno of a (unspecified) snapshot that failed. |
260 */ 261int 262lzc_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t **errlist) 263{ 264 nvpair_t *elem; 265 nvlist_t *args; 266 int error; 267 char pool[MAXNAMELEN]; --- 32 unchanged lines hidden (view full) --- 300 * 301 * If 'defer' is set, and a snapshot has user holds or clones, it will be 302 * marked for deferred destruction, and will be destroyed when the last hold 303 * or clone is removed/destroyed. 304 * 305 * The return value will be 0 if all snapshots were destroyed (or marked for 306 * later destruction if 'defer' is set) or didn't exist to begin with. 307 * | 259 */ 260int 261lzc_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t **errlist) 262{ 263 nvpair_t *elem; 264 nvlist_t *args; 265 int error; 266 char pool[MAXNAMELEN]; --- 32 unchanged lines hidden (view full) --- 299 * 300 * If 'defer' is set, and a snapshot has user holds or clones, it will be 301 * marked for deferred destruction, and will be destroyed when the last hold 302 * or clone is removed/destroyed. 303 * 304 * The return value will be 0 if all snapshots were destroyed (or marked for 305 * later destruction if 'defer' is set) or didn't exist to begin with. 306 * |
308 * Otherwise the return value will be the errno of a (undetermined) snapshot | 307 * Otherwise the return value will be the errno of a (unspecified) snapshot |
309 * that failed, no snapshots will be destroyed, and the errlist will have an 310 * entry for each snapshot that failed. The value in the errlist will be 311 * the (int32) error code. 312 */ 313int 314lzc_destroy_snaps(nvlist_t *snaps, boolean_t defer, nvlist_t **errlist) 315{ 316 nvpair_t *elem; --- 58 unchanged lines hidden (view full) --- 375 */ 376 zfs_cmd_t zc = { 0 }; 377 378 (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name)); 379 return (ioctl(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0); 380} 381 382/* | 308 * that failed, no snapshots will be destroyed, and the errlist will have an 309 * entry for each snapshot that failed. The value in the errlist will be 310 * the (int32) error code. 311 */ 312int 313lzc_destroy_snaps(nvlist_t *snaps, boolean_t defer, nvlist_t **errlist) 314{ 315 nvpair_t *elem; --- 58 unchanged lines hidden (view full) --- 374 */ 375 zfs_cmd_t zc = { 0 }; 376 377 (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name)); 378 return (ioctl(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0); 379} 380 381/* |
382 * Create "user holds" on snapshots. If there is a hold on a snapshot, 383 * the snapshot can not be destroyed. (However, it can be marked for deletion 384 * by lzc_destroy_snaps(defer=B_TRUE).) 385 * 386 * The keys in the nvlist are snapshot names. 387 * The snapshots must all be in the same pool. 388 * The value is the name of the hold (string type). 389 * 390 * If cleanup_fd is not -1, it must be the result of open("/dev/zfs", O_EXCL). 391 * In this case, when the cleanup_fd is closed (including on process 392 * termination), the holds will be released. If the system is shut down 393 * uncleanly, the holds will be released when the pool is next opened 394 * or imported. 395 * 396 * The return value will be 0 if all holds were created. Otherwise the return 397 * value will be the errno of a (unspecified) hold that failed, no holds will 398 * be created, and the errlist will have an entry for each hold that 399 * failed (name = snapshot). The value in the errlist will be the error 400 * code (int32). 401 */ 402int 403lzc_hold(nvlist_t *holds, int cleanup_fd, nvlist_t **errlist) 404{ 405 char pool[MAXNAMELEN]; 406 nvlist_t *args; 407 nvpair_t *elem; 408 int error; 409 410 /* determine the pool name */ 411 elem = nvlist_next_nvpair(holds, NULL); 412 if (elem == NULL) 413 return (0); 414 (void) strlcpy(pool, nvpair_name(elem), sizeof (pool)); 415 pool[strcspn(pool, "/@")] = '\0'; 416 417 args = fnvlist_alloc(); 418 fnvlist_add_nvlist(args, "holds", holds); 419 if (cleanup_fd != -1) 420 fnvlist_add_int32(args, "cleanup_fd", cleanup_fd); 421 422 error = lzc_ioctl(ZFS_IOC_HOLD, pool, args, errlist); 423 nvlist_free(args); 424 return (error); 425} 426 427/* 428 * Release "user holds" on snapshots. If the snapshot has been marked for 429 * deferred destroy (by lzc_destroy_snaps(defer=B_TRUE)), it does not have 430 * any clones, and all the user holds are removed, then the snapshot will be 431 * destroyed. 432 * 433 * The keys in the nvlist are snapshot names. 434 * The snapshots must all be in the same pool. 435 * The value is a nvlist whose keys are the holds to remove. 436 * 437 * The return value will be 0 if all holds were removed. 438 * Otherwise the return value will be the errno of a (unspecified) release 439 * that failed, no holds will be released, and the errlist will have an 440 * entry for each snapshot that has failed releases (name = snapshot). 441 * The value in the errlist will be the error code (int32) of a failed release. 442 */ 443int 444lzc_release(nvlist_t *holds, nvlist_t **errlist) 445{ 446 char pool[MAXNAMELEN]; 447 nvpair_t *elem; 448 449 /* determine the pool name */ 450 elem = nvlist_next_nvpair(holds, NULL); 451 if (elem == NULL) 452 return (0); 453 (void) strlcpy(pool, nvpair_name(elem), sizeof (pool)); 454 pool[strcspn(pool, "/@")] = '\0'; 455 456 return (lzc_ioctl(ZFS_IOC_RELEASE, pool, holds, errlist)); 457} 458 459/* 460 * Retrieve list of user holds on the specified snapshot. 461 * 462 * On success, *holdsp will be set to a nvlist which the caller must free. 463 * The keys are the names of the holds, and the value is the creation time 464 * of the hold (uint64) in seconds since the epoch. 465 */ 466int 467lzc_get_holds(const char *snapname, nvlist_t **holdsp) 468{ 469 int error; 470 nvlist_t *innvl = fnvlist_alloc(); 471 error = lzc_ioctl(ZFS_IOC_GET_HOLDS, snapname, innvl, holdsp); 472 fnvlist_free(innvl); 473 return (error); 474} 475 476/* |
|
383 * If fromsnap is NULL, a full (non-incremental) stream will be sent. 384 */ 385int 386lzc_send(const char *snapname, const char *fromsnap, int fd) 387{ 388 nvlist_t *args; 389 int err; 390 --- 134 unchanged lines hidden --- | 477 * If fromsnap is NULL, a full (non-incremental) stream will be sent. 478 */ 479int 480lzc_send(const char *snapname, const char *fromsnap, int fd) 481{ 482 nvlist_t *args; 483 int err; 484 --- 134 unchanged lines hidden --- |