Print this page
FITS: generating send-streams in portable format
This commit adds the command 'zfs fits-send', analogous to zfs send. The
generated send stream is compatible with the stream generated with that
from 'btrfs send' and can in principle easily be received to any filesystem.


 663         } else {
 664                 dsl_dir_name(ds->ds_dir, name);
 665                 VERIFY(0 == dsl_dataset_get_snapname(ds));
 666                 if (ds->ds_snapname[0]) {
 667                         (void) strcat(name, "@");
 668                         /*
 669                          * We use a "recursive" mutex so that we
 670                          * can call dprintf_ds() with ds_lock held.
 671                          */
 672                         if (!MUTEX_HELD(&ds->ds_lock)) {
 673                                 mutex_enter(&ds->ds_lock);
 674                                 (void) strcat(name, ds->ds_snapname);
 675                                 mutex_exit(&ds->ds_lock);
 676                         } else {
 677                                 (void) strcat(name, ds->ds_snapname);
 678                         }
 679                 }
 680         }
 681 }
 682 
 683 static int
 684 dsl_dataset_namelen(dsl_dataset_t *ds)
 685 {
 686         int result;
 687 
 688         if (ds == NULL) {
 689                 result = 3;     /* "mos" */
 690         } else {
 691                 result = dsl_dir_namelen(ds->ds_dir);
 692                 VERIFY(0 == dsl_dataset_get_snapname(ds));
 693                 if (ds->ds_snapname[0]) {
 694                         ++result;       /* adding one for the @-sign */
 695                         if (!MUTEX_HELD(&ds->ds_lock)) {
 696                                 mutex_enter(&ds->ds_lock);
 697                                 result += strlen(ds->ds_snapname);
 698                                 mutex_exit(&ds->ds_lock);
 699                         } else {
 700                                 result += strlen(ds->ds_snapname);
 701                         }
 702                 }
 703         }




 663         } else {
 664                 dsl_dir_name(ds->ds_dir, name);
 665                 VERIFY(0 == dsl_dataset_get_snapname(ds));
 666                 if (ds->ds_snapname[0]) {
 667                         (void) strcat(name, "@");
 668                         /*
 669                          * We use a "recursive" mutex so that we
 670                          * can call dprintf_ds() with ds_lock held.
 671                          */
 672                         if (!MUTEX_HELD(&ds->ds_lock)) {
 673                                 mutex_enter(&ds->ds_lock);
 674                                 (void) strcat(name, ds->ds_snapname);
 675                                 mutex_exit(&ds->ds_lock);
 676                         } else {
 677                                 (void) strcat(name, ds->ds_snapname);
 678                         }
 679                 }
 680         }
 681 }
 682 
 683 int
 684 dsl_dataset_namelen(dsl_dataset_t *ds)
 685 {
 686         int result;
 687 
 688         if (ds == NULL) {
 689                 result = 3;     /* "mos" */
 690         } else {
 691                 result = dsl_dir_namelen(ds->ds_dir);
 692                 VERIFY(0 == dsl_dataset_get_snapname(ds));
 693                 if (ds->ds_snapname[0]) {
 694                         ++result;       /* adding one for the @-sign */
 695                         if (!MUTEX_HELD(&ds->ds_lock)) {
 696                                 mutex_enter(&ds->ds_lock);
 697                                 result += strlen(ds->ds_snapname);
 698                                 mutex_exit(&ds->ds_lock);
 699                         } else {
 700                                 result += strlen(ds->ds_snapname);
 701                         }
 702                 }
 703         }