Print this page
blah
XXX - fix get_all_datasets call
XXX - fix get_all_datasets call


6837                         node->un_zhp = zhp;
6838                         node->un_mountp = safe_strdup(entry.mnt_mountp);
6839 
6840                         uu_avl_node_init(node, &node->un_avlnode, pool);
6841 
6842                         if (uu_avl_find(tree, node, NULL, &idx) == NULL) {
6843                                 uu_avl_insert(tree, node, idx);
6844                         } else {
6845                                 zfs_close(node->un_zhp);
6846                                 free(node->un_mountp);
6847                                 free(node);
6848                         }
6849                 }
6850 
6851                 /*
6852                  * Initilialize libshare SA_INIT_SHARE_API_SELECTIVE here
6853                  * to avoid unneccesary load/unload of the libshare API
6854                  * per shared dataset downstream.
6855                  */
6856                 if (op == OP_SHARE) {
6857                         zfs_handle_t **dslist = NULL;
6858                         size_t count = 0;
6859                         get_all_datasets(&dslist, &count, B_FALSE);
6860 
6861                         if (count > 0) {
6862                                 sa_init_selective_arg_t sharearg;
6863                                 sharearg.zhandle_arr = dslist;
6864                                 sharearg.zhandle_len = count;
6865                                 if ((ret = zfs_init_libshare_arg(
6866                                     zfs_get_handle(dslist[0]),
6867                                     SA_INIT_SHARE_API_SELECTIVE, &sharearg))
6868                                     != SA_OK) {
6869                                         (void) fprintf(stderr, gettext(
6870                                             "Could not initialize libshare,"
6871                                             "%d"), ret);
6872                                         return (1);
6873                                 }
6874                         }
6875                 }
6876 
6877                 /*
6878                  * Walk the AVL tree in reverse, unmounting each filesystem and
6879                  * removing it from the AVL tree in the process.
6880                  */
6881                 if ((walk = uu_avl_walk_start(tree,
6882                     UU_WALK_REVERSE | UU_WALK_ROBUST)) == NULL)
6883                         nomem();
6884 
6885                 while ((node = uu_avl_walk_next(walk)) != NULL) {
6886                         uu_avl_remove(tree, node);
6887 
6888                         switch (op) {
6889                         case OP_SHARE:
6890                                 if (zfs_unshareall_bypath(node->un_zhp,
6891                                     node->un_mountp) != 0)
6892                                         ret = 1;




6837                         node->un_zhp = zhp;
6838                         node->un_mountp = safe_strdup(entry.mnt_mountp);
6839 
6840                         uu_avl_node_init(node, &node->un_avlnode, pool);
6841 
6842                         if (uu_avl_find(tree, node, NULL, &idx) == NULL) {
6843                                 uu_avl_insert(tree, node, idx);
6844                         } else {
6845                                 zfs_close(node->un_zhp);
6846                                 free(node->un_mountp);
6847                                 free(node);
6848                         }
6849                 }
6850 
6851                 /*
6852                  * Initilialize libshare SA_INIT_SHARE_API_SELECTIVE here
6853                  * to avoid unneccesary load/unload of the libshare API
6854                  * per shared dataset downstream.
6855                  */
6856                 if (op == OP_SHARE) {
6857                         get_all_cb_t dslist = { 0 };
6858                         get_all_datasets(&dslist, B_FALSE);

6859 
6860                         if (dslist.cb_used != 0) {
6861                                 sa_init_selective_arg_t sharearg;
6862                                 sharearg.zhandle_arr = dslist.cb_handles;
6863                                 sharearg.zhandle_len = dslist.cb_used;
6864                                 if ((ret = zfs_init_libshare_arg(g_zfs,
6865                                     SA_INIT_SHARE_API_SELECTIVE, &sharearg)) !=
6866                                         SA_OK) {

6867                                         (void) fprintf(stderr, gettext(
6868                                             "Could not initialize libshare, "
6869                                             "%d"), ret);
6870                                         return (ret);
6871                                 }
6872                         }
6873                 }
6874 
6875                 /*
6876                  * Walk the AVL tree in reverse, unmounting each filesystem and
6877                  * removing it from the AVL tree in the process.
6878                  */
6879                 if ((walk = uu_avl_walk_start(tree,
6880                     UU_WALK_REVERSE | UU_WALK_ROBUST)) == NULL)
6881                         nomem();
6882 
6883                 while ((node = uu_avl_walk_next(walk)) != NULL) {
6884                         uu_avl_remove(tree, node);
6885 
6886                         switch (op) {
6887                         case OP_SHARE:
6888                                 if (zfs_unshareall_bypath(node->un_zhp,
6889                                     node->un_mountp) != 0)
6890                                         ret = 1;