Print this page
FAR: generating send-streams in portable format
This commit adds a switch '-F' to  zfs send. This set, zfs send generates
a stream in FAR-format instead of the traditional zfs stream format. The
generated send stream is compatible with the stream generated from 'btrfs send'
and can in principle easily be received to any filesystem.

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zfs/zfs_main.c
          +++ new/usr/src/cmd/zfs/zfs_main.c
↓ open down ↓ 244 lines elided ↑ open up ↑
 245  245                  "snapshot>\n"
 246  246                  "\treceive [-vnFu] [-d | -e] <filesystem>\n"));
 247  247          case HELP_RENAME:
 248  248                  return (gettext("\trename [-f] <filesystem|volume|snapshot> "
 249  249                      "<filesystem|volume|snapshot>\n"
 250  250                      "\trename [-f] -p <filesystem|volume> <filesystem|volume>\n"
 251  251                      "\trename -r <snapshot> <snapshot>"));
 252  252          case HELP_ROLLBACK:
 253  253                  return (gettext("\trollback [-rRf] <snapshot>\n"));
 254  254          case HELP_SEND:
 255      -                return (gettext("\tsend [-DnPpRv] [-[iI] snapshot] "
 256      -                    "<snapshot>\n"));
      255 +                return (gettext("\tsend [-DnPpRv] [-[iI] snapshot] <snapshot>\n"
      256 +                    "\tsend -F [-nPRv] [-[iI] snapshot] <snapshot>\n"));
 257  257          case HELP_SET:
 258  258                  return (gettext("\tset <property=value> "
 259  259                      "<filesystem|volume|snapshot> ...\n"));
 260  260          case HELP_SHARE:
 261  261                  return (gettext("\tshare <-a | filesystem>\n"));
 262  262          case HELP_SNAPSHOT:
 263  263                  return (gettext("\tsnapshot [-r] [-o property=value] ... "
 264  264                      "<filesystem@snapname|volume@snapname> ...\n"));
 265  265          case HELP_UNMOUNT:
 266  266                  return (gettext("\tunmount [-f] "
↓ open down ↓ 3247 lines elided ↑ open up ↑
3514 3514          char *fromname = NULL;
3515 3515          char *toname = NULL;
3516 3516          char *cp;
3517 3517          zfs_handle_t *zhp;
3518 3518          sendflags_t flags = { 0 };
3519 3519          int c, err;
3520 3520          nvlist_t *dbgnv = NULL;
3521 3521          boolean_t extraverbose = B_FALSE;
3522 3522  
3523 3523          /* check options */
3524      -        while ((c = getopt(argc, argv, ":i:I:RDpvnP")) != -1) {
     3524 +        while ((c = getopt(argc, argv, ":i:I:RDpvnPF")) != -1) {
3525 3525                  switch (c) {
3526 3526                  case 'i':
3527 3527                          if (fromname)
3528 3528                                  usage(B_FALSE);
3529 3529                          fromname = optarg;
3530 3530                          break;
3531 3531                  case 'I':
3532 3532                          if (fromname)
3533 3533                                  usage(B_FALSE);
3534 3534                          fromname = optarg;
↓ open down ↓ 14 lines elided ↑ open up ↑
3549 3549                                  extraverbose = B_TRUE;
3550 3550                          flags.verbose = B_TRUE;
3551 3551                          flags.progress = B_TRUE;
3552 3552                          break;
3553 3553                  case 'D':
3554 3554                          flags.dedup = B_TRUE;
3555 3555                          break;
3556 3556                  case 'n':
3557 3557                          flags.dryrun = B_TRUE;
3558 3558                          break;
     3559 +                case 'F':
     3560 +                        flags.far = B_TRUE;
     3561 +                        break;
3559 3562                  case ':':
3560 3563                          (void) fprintf(stderr, gettext("missing argument for "
3561 3564                              "'%c' option\n"), optopt);
3562 3565                          usage(B_FALSE);
3563 3566                          break;
3564 3567                  case '?':
3565 3568                          (void) fprintf(stderr, gettext("invalid option '%c'\n"),
3566 3569                              optopt);
3567 3570                          usage(B_FALSE);
3568 3571                  }
↓ open down ↓ 5 lines elided ↑ open up ↑
3574 3577          /* check number of arguments */
3575 3578          if (argc < 1) {
3576 3579                  (void) fprintf(stderr, gettext("missing snapshot argument\n"));
3577 3580                  usage(B_FALSE);
3578 3581          }
3579 3582          if (argc > 1) {
3580 3583                  (void) fprintf(stderr, gettext("too many arguments\n"));
3581 3584                  usage(B_FALSE);
3582 3585          }
3583 3586  
     3587 +        if (flags.far && (flags.dedup || flags.props)) {
     3588 +                (void) fprintf(stderr, gettext("options -D and -p are not "
     3589 +                    "allowed with -F\n"));
     3590 +                usage(B_FALSE);
     3591 +        }
3584 3592          if (!flags.dryrun && isatty(STDOUT_FILENO)) {
3585 3593                  (void) fprintf(stderr,
3586 3594                      gettext("Error: Stream can not be written to a terminal.\n"
3587 3595                      "You must redirect standard output.\n"));
3588 3596                  return (1);
3589 3597          }
3590 3598  
3591 3599          cp = strchr(argv[0], '@');
3592 3600          if (cp == NULL) {
3593 3601                  (void) fprintf(stderr,
↓ open down ↓ 2995 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX