Add linux topology support
[zfs.git] / lib / libzfs / libzfs_sendrecv.c
index c1d3b56..87ffd12 100644 (file)
@@ -43,7 +43,6 @@
 #include "zfs_prop.h"
 #include "zfs_fletcher.h"
 #include "libzfs_impl.h"
-#include <sha2.h>
 #include <sys/zio_checksum.h>
 #include <sys/ddt.h>
 
@@ -336,12 +335,11 @@ cksummer(void *arg)
                        if (ZIO_CHECKSUM_EQUAL(drrw->drr_key.ddk_cksum,
                            zero_cksum) ||
                            !DRR_IS_DEDUP_CAPABLE(drrw->drr_checksumflags)) {
-                               SHA256_CTX      ctx;
-                               zio_cksum_t     tmpsha256;
+                               zio_cksum_t tmpsha256;
+
+                               zio_checksum_SHA256(buf,
+                                   drrw->drr_length, &tmpsha256);
 
-                               SHA256Init(&ctx);
-                               SHA256Update(&ctx, buf, drrw->drr_length);
-                               SHA256Final(&tmpsha256, &ctx);
                                drrw->drr_key.ddk_cksum.zc_word[0] =
                                    BE_64(tmpsha256.zc_word[0]);
                                drrw->drr_key.ddk_cksum.zc_word[1] =
@@ -1297,7 +1295,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 = pipe(pipefd))) {
                        zfs_error_aux(zhp->zfs_hdl, strerror(errno));
                        return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED,
                            errbuf));
@@ -1305,7 +1303,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
                dda.outputfd = outfd;
                dda.inputfd = pipefd[1];
                dda.dedup_hdl = zhp->zfs_hdl;
-               if (err = pthread_create(&tid, NULL, cksummer, &dda)) {
+               if ((err = pthread_create(&tid, NULL, cksummer, &dda))) {
                        (void) close(pipefd[0]);
                        (void) close(pipefd[1]);
                        zfs_error_aux(zhp->zfs_hdl, strerror(errno));
@@ -1413,7 +1411,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
                ++holdseq;
                (void) snprintf(sdd.holdtag, sizeof (sdd.holdtag),
                    ".send-%d-%llu", getpid(), (u_longlong_t)holdseq);
-               sdd.cleanup_fd = open(ZFS_DEV, O_RDWR|O_EXCL);
+               sdd.cleanup_fd = open(ZFS_DEV, O_RDWR);
                if (sdd.cleanup_fd < 0) {
                        err = errno;
                        goto stderr_out;
@@ -2467,7 +2465,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
         */
        (void) strcpy(zc.zc_top_ds, tosnap);
        (void) strcpy(zc.zc_value, tosnap);
-       (void) strncat(zc.zc_value, chopprefix, sizeof (zc.zc_value));
+       (void) strlcat(zc.zc_value, chopprefix, sizeof (zc.zc_value));
        free(cp);
        if (!zfs_name_valid(zc.zc_value, ZFS_TYPE_SNAPSHOT)) {
                zcmd_free_nvlists(&zc);
@@ -2988,7 +2986,7 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, recvflags_t flags,
        int cleanup_fd;
        uint64_t action_handle = 0;
 
-       cleanup_fd = open(ZFS_DEV, O_RDWR|O_EXCL);
+       cleanup_fd = open(ZFS_DEV, O_RDWR);
        VERIFY(cleanup_fd >= 0);
 
        err = zfs_receive_impl(hdl, tosnap, flags, infd, NULL, NULL,