Solved zfs receive - cannot open 'zhost4t/vm-freebsd-disk0/': trailing slash in name

Hello

Facing this issue today while tying to receive ZFS snapshot:
Bash:
zfs create -sV32G -o volblocksize=4k -o volmode=dev zhost4t/vm-freebsd-disk0
...
zfs snapshot zhost4t/vm-freebsd-disk0@test
zfs send zhost4t/vm-freebsd-disk0@test | gzip > zfs-test.gz
...
zcat zfs-test.gz | zfs receive -F zhost4t/vm-freebsd-disk0
> cannot open 'zhost4t/vm-freebsd-disk0/': trailing slash in name

What am I doing wrong ???

Forgot the OS name: FreeBSD 12.2-RELEASE-p1 GENERIC amd64
 
FreeBSD 12.2-RELEASE-p1
Not related to your issue but you should be more diligent when it comes to installing patches. We're at 12.2-RELEASE-p7 now. You're missing all these security advisories:
And these errata:

Take note of this one, it might actually apply to your situation.
 
SirDice, yes, i know, unfortunately i cannot update machine at the moment .... it is a production server ..... :( and after I saw this issue with snapshot importing it become even more complicated .. so I need to test all of this first ...
 
SirDice, test pc, FreeBSD 12.2-RELEASE-p7 GENERIC amd64, same result.

so the issue is still present.
 
either destroy the destination zvol first or apply the patch
Code:
--- libzfs_sendrecv.c.orig    2021-06-15 22:30:12.935572000 +0300
+++ libzfs_sendrecv.c    2021-06-15 22:29:17.128199000 +0300
@@ -3403,6 +3403,7 @@
                     zc.zc_name);
                 return (zfs_error(hdl, EZFS_EXISTS, errbuf));
             }
+            int zc_name_orig_len = strlen(zc.zc_name);
             if (is_volume &&
                 ioctl(hdl->libzfs_fd, ZFS_IOC_DATASET_LIST_NEXT,
                 &zc) == 0) {
@@ -3414,6 +3415,8 @@
                 return (zfs_error(hdl, EZFS_WRONG_PARENT,
                     errbuf));
             }
+            if(is_volume)
+                zc.zc_name[zc_name_orig_len] = '\0';
         }
        
         if ((zhp = zfs_open(hdl, zc.zc_name,
cd /usr/src/cddl/lib/libzfs
make
export LD_LIBRARY_PATH=$(make -V MAKEOBJDIR)
now you can test /sbin/zfs with the patched lib
 
Back
Top