Illumos #734: Use taskq_dispatch_ent() interface
[zfs.git] / lib / libzfs / libzfs_sendrecv.c
index 87ffd12..7a95de0 100644 (file)
 #include <stddef.h>
 #include <fcntl.h>
 #include <sys/mount.h>
+#include <sys/mntent.h>
+#include <sys/mnttab.h>
+#include <sys/avl.h>
+#include <sys/debug.h>
+#include <stddef.h>
 #include <pthread.h>
 #include <umem.h>
 
@@ -45,6 +50,7 @@
 #include "libzfs_impl.h"
 #include <sys/zio_checksum.h>
 #include <sys/ddt.h>
+#include <sys/socket.h>
 
 /* in libzfs_dataset.c */
 extern void zfs_setprop_error(libzfs_handle_t *, zfs_prop_t, int, char *);
@@ -1295,7 +1301,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
        if (flags.dedup) {
                featureflags |= (DMU_BACKUP_FEATURE_DEDUP |
                    DMU_BACKUP_FEATURE_DEDUPPROPS);
-               if ((err = pipe(pipefd))) {
+               if ((err = socketpair(AF_UNIX, SOCK_STREAM, 0, pipefd))) {
                        zfs_error_aux(zhp->zfs_hdl, strerror(errno));
                        return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED,
                            errbuf));
@@ -2608,6 +2614,12 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
                                return (-1);
                        }
                }
+               if (!flags.dryrun && zhp->zfs_type == ZFS_TYPE_VOLUME &&
+                   zvol_remove_link(hdl, zhp->zfs_name) != 0) {
+                       zfs_close(zhp);
+                       zcmd_free_nvlists(&zc);
+                       return (-1);
+               }
                zfs_close(zhp);
        } else {
                /*
@@ -2813,6 +2825,10 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
                if (h != NULL) {
                        if (h->zfs_type == ZFS_TYPE_VOLUME) {
                                *cp = '@';
+                               err = zvol_create_link(hdl, h->zfs_name);
+                               if (err == 0 && ioctl_err == 0)
+                                       err = zvol_create_link(hdl,
+                                           zc.zc_value);
                        } else if (newfs || stream_avl) {
                                /*
                                 * Track the first/top of hierarchy fs,