Print this page
Placeholder


   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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
  25  * Copyright 2012 Milan Jurik. All rights reserved.
  26  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  27  * Copyright (c) 2013 Steven Hartland.  All rights reserved.
  28  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.

  29  */
  30 
  31 #include <assert.h>
  32 #include <ctype.h>
  33 #include <errno.h>
  34 #include <libgen.h>
  35 #include <libintl.h>
  36 #include <libuutil.h>
  37 #include <libnvpair.h>
  38 #include <locale.h>
  39 #include <stddef.h>
  40 #include <stdio.h>
  41 #include <stdlib.h>
  42 #include <strings.h>
  43 #include <unistd.h>
  44 #include <fcntl.h>
  45 #include <zone.h>
  46 #include <grp.h>
  47 #include <pwd.h>
  48 #include <signal.h>


 242                     "[filesystem|volume|snapshot] ...\n"));
 243         case HELP_MOUNT:
 244                 return (gettext("\tmount\n"
 245                     "\tmount [-vO] [-o opts] <-a | filesystem>\n"));
 246         case HELP_PROMOTE:
 247                 return (gettext("\tpromote <clone-filesystem>\n"));
 248         case HELP_RECEIVE:
 249                 return (gettext("\treceive [-vnsFu] <filesystem|volume|"
 250                     "snapshot>\n"
 251                     "\treceive [-vnsFu] [-o origin=<snapshot>] [-d | -e] "
 252                     "<filesystem>\n"
 253                     "\treceive -A <filesystem|volume>\n"));
 254         case HELP_RENAME:
 255                 return (gettext("\trename [-f] <filesystem|volume|snapshot> "
 256                     "<filesystem|volume|snapshot>\n"
 257                     "\trename [-f] -p <filesystem|volume> <filesystem|volume>\n"
 258                     "\trename -r <snapshot> <snapshot>\n"));
 259         case HELP_ROLLBACK:
 260                 return (gettext("\trollback [-rRf] <snapshot>\n"));
 261         case HELP_SEND:
 262                 return (gettext("\tsend [-DnPpRvLe] [-[iI] snapshot] "
 263                     "<snapshot>\n"
 264                     "\tsend [-Le] [-i snapshot|bookmark] "
 265                     "<filesystem|volume|snapshot>\n"
 266                     "\tsend [-nvPe] -t <receive_resume_token>\n"));
 267         case HELP_SET:
 268                 return (gettext("\tset <property=value> ... "
 269                     "<filesystem|volume|snapshot> ...\n"));
 270         case HELP_SHARE:
 271                 return (gettext("\tshare <-a | filesystem>\n"));
 272         case HELP_SNAPSHOT:
 273                 return (gettext("\tsnapshot [-r] [-o property=value] ... "
 274                     "<filesystem|volume>@<snap> ...\n"));
 275         case HELP_UNMOUNT:
 276                 return (gettext("\tunmount [-f] "
 277                     "<-a | filesystem|mountpoint>\n"));
 278         case HELP_UNSHARE:
 279                 return (gettext("\tunshare "
 280                     "<-a | filesystem|mountpoint>\n"));
 281         case HELP_ALLOW:
 282                 return (gettext("\tallow <filesystem|volume>\n"
 283                     "\tallow [-ldug] "
 284                     "<\"everyone\"|user|group>[,...] <perm|@setname>[,...]\n"


3670         return (-1);
3671 }
3672 
3673 /*
3674  * Send a backup stream to stdout.
3675  */
3676 static int
3677 zfs_do_send(int argc, char **argv)
3678 {
3679         char *fromname = NULL;
3680         char *toname = NULL;
3681         char *resume_token = NULL;
3682         char *cp;
3683         zfs_handle_t *zhp;
3684         sendflags_t flags = { 0 };
3685         int c, err;
3686         nvlist_t *dbgnv = NULL;
3687         boolean_t extraverbose = B_FALSE;
3688 
3689         /* check options */
3690         while ((c = getopt(argc, argv, ":i:I:RDpvnPLet:")) != -1) {
3691                 switch (c) {
3692                 case 'i':
3693                         if (fromname)
3694                                 usage(B_FALSE);
3695                         fromname = optarg;
3696                         break;
3697                 case 'I':
3698                         if (fromname)
3699                                 usage(B_FALSE);
3700                         fromname = optarg;
3701                         flags.doall = B_TRUE;
3702                         break;
3703                 case 'R':
3704                         flags.replicate = B_TRUE;
3705                         break;
3706                 case 'p':
3707                         flags.props = B_TRUE;
3708                         break;
3709                 case 'P':
3710                         flags.parsable = B_TRUE;


3713                 case 'v':
3714                         if (flags.verbose)
3715                                 extraverbose = B_TRUE;
3716                         flags.verbose = B_TRUE;
3717                         flags.progress = B_TRUE;
3718                         break;
3719                 case 'D':
3720                         flags.dedup = B_TRUE;
3721                         break;
3722                 case 'n':
3723                         flags.dryrun = B_TRUE;
3724                         break;
3725                 case 'L':
3726                         flags.largeblock = B_TRUE;
3727                         break;
3728                 case 'e':
3729                         flags.embed_data = B_TRUE;
3730                         break;
3731                 case 't':
3732                         resume_token = optarg;



3733                         break;
3734                 case ':':
3735                         (void) fprintf(stderr, gettext("missing argument for "
3736                             "'%c' option\n"), optopt);
3737                         usage(B_FALSE);
3738                         break;
3739                 case '?':
3740                         (void) fprintf(stderr, gettext("invalid option '%c'\n"),
3741                             optopt);
3742                         usage(B_FALSE);
3743                 }
3744         }
3745 
3746         argc -= optind;
3747         argv += optind;
3748 
3749         if (resume_token != NULL) {
3750                 if (fromname != NULL || flags.replicate || flags.props ||
3751                     flags.dedup) {
3752                         (void) fprintf(stderr,




   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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
  25  * Copyright 2012 Milan Jurik. All rights reserved.
  26  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  27  * Copyright (c) 2013 Steven Hartland.  All rights reserved.
  28  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  29  * Copyright 2015 RackTop Systems.
  30  */
  31 
  32 #include <assert.h>
  33 #include <ctype.h>
  34 #include <errno.h>
  35 #include <libgen.h>
  36 #include <libintl.h>
  37 #include <libuutil.h>
  38 #include <libnvpair.h>
  39 #include <locale.h>
  40 #include <stddef.h>
  41 #include <stdio.h>
  42 #include <stdlib.h>
  43 #include <strings.h>
  44 #include <unistd.h>
  45 #include <fcntl.h>
  46 #include <zone.h>
  47 #include <grp.h>
  48 #include <pwd.h>
  49 #include <signal.h>


 243                     "[filesystem|volume|snapshot] ...\n"));
 244         case HELP_MOUNT:
 245                 return (gettext("\tmount\n"
 246                     "\tmount [-vO] [-o opts] <-a | filesystem>\n"));
 247         case HELP_PROMOTE:
 248                 return (gettext("\tpromote <clone-filesystem>\n"));
 249         case HELP_RECEIVE:
 250                 return (gettext("\treceive [-vnsFu] <filesystem|volume|"
 251                     "snapshot>\n"
 252                     "\treceive [-vnsFu] [-o origin=<snapshot>] [-d | -e] "
 253                     "<filesystem>\n"
 254                     "\treceive -A <filesystem|volume>\n"));
 255         case HELP_RENAME:
 256                 return (gettext("\trename [-f] <filesystem|volume|snapshot> "
 257                     "<filesystem|volume|snapshot>\n"
 258                     "\trename [-f] -p <filesystem|volume> <filesystem|volume>\n"
 259                     "\trename -r <snapshot> <snapshot>\n"));
 260         case HELP_ROLLBACK:
 261                 return (gettext("\trollback [-rRf] <snapshot>\n"));
 262         case HELP_SEND:
 263                 return (gettext("\tsend [-DnPpRvLeF] [-[iI] snapshot] "
 264                     "<snapshot>\n"
 265                     "\tsend [-LeF] [-i snapshot|bookmark] "
 266                     "<filesystem|volume|snapshot>\n"
 267                     "\tsend [-nvPe] -t <receive_resume_token>\n"));
 268         case HELP_SET:
 269                 return (gettext("\tset <property=value> ... "
 270                     "<filesystem|volume|snapshot> ...\n"));
 271         case HELP_SHARE:
 272                 return (gettext("\tshare <-a | filesystem>\n"));
 273         case HELP_SNAPSHOT:
 274                 return (gettext("\tsnapshot [-r] [-o property=value] ... "
 275                     "<filesystem|volume>@<snap> ...\n"));
 276         case HELP_UNMOUNT:
 277                 return (gettext("\tunmount [-f] "
 278                     "<-a | filesystem|mountpoint>\n"));
 279         case HELP_UNSHARE:
 280                 return (gettext("\tunshare "
 281                     "<-a | filesystem|mountpoint>\n"));
 282         case HELP_ALLOW:
 283                 return (gettext("\tallow <filesystem|volume>\n"
 284                     "\tallow [-ldug] "
 285                     "<\"everyone\"|user|group>[,...] <perm|@setname>[,...]\n"


3671         return (-1);
3672 }
3673 
3674 /*
3675  * Send a backup stream to stdout.
3676  */
3677 static int
3678 zfs_do_send(int argc, char **argv)
3679 {
3680         char *fromname = NULL;
3681         char *toname = NULL;
3682         char *resume_token = NULL;
3683         char *cp;
3684         zfs_handle_t *zhp;
3685         sendflags_t flags = { 0 };
3686         int c, err;
3687         nvlist_t *dbgnv = NULL;
3688         boolean_t extraverbose = B_FALSE;
3689 
3690         /* check options */
3691         while ((c = getopt(argc, argv, ":i:I:RDpvnPLet:F")) != -1) {
3692                 switch (c) {
3693                 case 'i':
3694                         if (fromname)
3695                                 usage(B_FALSE);
3696                         fromname = optarg;
3697                         break;
3698                 case 'I':
3699                         if (fromname)
3700                                 usage(B_FALSE);
3701                         fromname = optarg;
3702                         flags.doall = B_TRUE;
3703                         break;
3704                 case 'R':
3705                         flags.replicate = B_TRUE;
3706                         break;
3707                 case 'p':
3708                         flags.props = B_TRUE;
3709                         break;
3710                 case 'P':
3711                         flags.parsable = B_TRUE;


3714                 case 'v':
3715                         if (flags.verbose)
3716                                 extraverbose = B_TRUE;
3717                         flags.verbose = B_TRUE;
3718                         flags.progress = B_TRUE;
3719                         break;
3720                 case 'D':
3721                         flags.dedup = B_TRUE;
3722                         break;
3723                 case 'n':
3724                         flags.dryrun = B_TRUE;
3725                         break;
3726                 case 'L':
3727                         flags.largeblock = B_TRUE;
3728                         break;
3729                 case 'e':
3730                         flags.embed_data = B_TRUE;
3731                         break;
3732                 case 't':
3733                         resume_token = optarg;
3734                         break;
3735                 case 'F':
3736                         flags.skip_free = B_TRUE;
3737                         break;
3738                 case ':':
3739                         (void) fprintf(stderr, gettext("missing argument for "
3740                             "'%c' option\n"), optopt);
3741                         usage(B_FALSE);
3742                         break;
3743                 case '?':
3744                         (void) fprintf(stderr, gettext("invalid option '%c'\n"),
3745                             optopt);
3746                         usage(B_FALSE);
3747                 }
3748         }
3749 
3750         argc -= optind;
3751         argv += optind;
3752 
3753         if (resume_token != NULL) {
3754                 if (fromname != NULL || flags.replicate || flags.props ||
3755                     flags.dedup) {
3756                         (void) fprintf(stderr,