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 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
26 * Copyright (c) 2016 Martin Matuska. All rights reserved.
27 */
28
29 /*
30 * System includes
31 */
32
33 #include <assert.h>
34 #include <ctype.h>
35 #include <errno.h>
36 #include <libgen.h>
37 #include <libintl.h>
38 #include <libnvpair.h>
39 #include <libzfs.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <sys/mnttab.h>
44 #include <sys/mount.h>
2455 (void) close(srpipe[0]);
2456 (void) close(srpipe[1]);
2457 ZFS_CLOSE(zhp);
2458 return (errno_to_be_err(err));
2459 } else if (pid == 0) { /* child process */
2460 (void) close(srpipe[0]);
2461
2462 /* Send dataset */
2463 if (zfs_send(zhp, NULL, bt->obe_snap_name, &send_flags,
2464 srpipe[1], NULL, NULL, NULL) != 0) {
2465 _exit(1);
2466 }
2467 ZFS_CLOSE(zhp);
2468
2469 _exit(0);
2470 }
2471
2472 (void) close(srpipe[1]);
2473
2474 /* Receive dataset */
2475 if (zfs_receive(g_zfs, clone_ds, NULL, &flags, srpipe[0], NULL) != 0) {
2476 be_print_err(gettext("be_send_fs_callback: failed to "
2477 "recv dataset (%s)\n"), clone_ds);
2478 }
2479 (void) close(srpipe[0]);
2480
2481 /* wait for child to exit */
2482 do {
2483 retval = waitpid(pid, &status, 0);
2484 if (retval == -1) {
2485 status = 0;
2486 }
2487 } while (retval != pid);
2488
2489 if (WEXITSTATUS(status) != 0) {
2490 be_print_err(gettext("be_send_fs_callback: failed to "
2491 "send dataset (%s)\n"), zhp_name);
2492 ZFS_CLOSE(zhp);
2493 return (BE_ERR_ZFS);
2494 }
2495
|
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 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
26 * Copyright (c) 2016 Martin Matuska. All rights reserved.
27 */
28
29 /*
30 * System includes
31 */
32
33 #include <assert.h>
34 #include <ctype.h>
35 #include <errno.h>
36 #include <libgen.h>
37 #include <libintl.h>
38 #include <libnvpair.h>
39 #include <libzfs.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <sys/mnttab.h>
44 #include <sys/mount.h>
2455 (void) close(srpipe[0]);
2456 (void) close(srpipe[1]);
2457 ZFS_CLOSE(zhp);
2458 return (errno_to_be_err(err));
2459 } else if (pid == 0) { /* child process */
2460 (void) close(srpipe[0]);
2461
2462 /* Send dataset */
2463 if (zfs_send(zhp, NULL, bt->obe_snap_name, &send_flags,
2464 srpipe[1], NULL, NULL, NULL) != 0) {
2465 _exit(1);
2466 }
2467 ZFS_CLOSE(zhp);
2468
2469 _exit(0);
2470 }
2471
2472 (void) close(srpipe[1]);
2473
2474 /* Receive dataset */
2475 if (zfs_receive(g_zfs, clone_ds, &flags, srpipe[0], NULL, NULL,
2476 NULL) != 0) {
2477 be_print_err(gettext("be_send_fs_callback: failed to "
2478 "recv dataset (%s)\n"), clone_ds);
2479 }
2480 (void) close(srpipe[0]);
2481
2482 /* wait for child to exit */
2483 do {
2484 retval = waitpid(pid, &status, 0);
2485 if (retval == -1) {
2486 status = 0;
2487 }
2488 } while (retval != pid);
2489
2490 if (WEXITSTATUS(status) != 0) {
2491 be_print_err(gettext("be_send_fs_callback: failed to "
2492 "send dataset (%s)\n"), zhp_name);
2493 ZFS_CLOSE(zhp);
2494 return (BE_ERR_ZFS);
2495 }
2496
|