diff --git a/zfs/lib/libzfs/libzfs_dataset.c b/zfs/lib/libzfs/libzfs_dataset.c index 3f49652abb..c2c34ed176 100644 --- a/zfs/lib/libzfs/libzfs_dataset.c +++ b/zfs/lib/libzfs/libzfs_dataset.c @@ -3981,6 +3981,11 @@ zvol_create_link(libzfs_handle_t *hdl, const char *dataset) static int zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists) { +#if !defined(HAVE_ZVOL) + return (zfs_standard_error_fmt(hdl, ENOTSUP, + dgettext(TEXT_DOMAIN, "cannot create device links " + "for '%s'"), dataset)); +#else zfs_cmd_t zc = { 0 }; di_devlink_handle_t dhdl; priv_set_t *priv_effective; @@ -4069,6 +4074,7 @@ zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists) } return (0); +#endif } /* @@ -4205,6 +4211,9 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp) int zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred) { +#if !defined(HAVE_ZVOL) + return (ENOTSUP); +#else zfs_cmd_t zc = { 0 }; nvlist_t *nvp; gid_t gid; @@ -4246,6 +4255,7 @@ zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred) error = ioctl(hdl->libzfs_fd, ZFS_IOC_ISCSI_PERM_CHECK, &zc); nvlist_free(nvp); return (error); +#endif } int diff --git a/zfs/lib/libzfs/libzfs_pool.c b/zfs/lib/libzfs/libzfs_pool.c index 113abc9d34..048bb16cd7 100644 --- a/zfs/lib/libzfs/libzfs_pool.c +++ b/zfs/lib/libzfs/libzfs_pool.c @@ -2088,6 +2088,7 @@ int zpool_iter_zvol(zpool_handle_t *zhp, int (*cb)(const char *, void *), void *data) { +#ifdef HAVE_ZVOL libzfs_handle_t *hdl = zhp->zpool_hdl; char (*paths)[MAXPATHLEN]; size_t size = 4; @@ -2179,6 +2180,7 @@ zpool_iter_zvol(zpool_handle_t *zhp, int (*cb)(const char *, void *), err: free(paths); (void) close(base); +#endif return (-1); } diff --git a/zfs/lib/libzpool/zvol.c b/zfs/lib/libzpool/zvol.c index 4e993060ce..e686816af6 100644 --- a/zfs/lib/libzpool/zvol.c +++ b/zfs/lib/libzpool/zvol.c @@ -76,6 +76,11 @@ #include #include +#ifdef HAVE_SPL +#include +#include +#endif + #include "zfs_namecheck.h" static void *zvol_state; @@ -159,10 +164,22 @@ zvol_check_volsize(uint64_t volsize, uint64_t blocksize) if (volsize % blocksize != 0) return (EINVAL); -#ifdef _ILP32 +#ifdef HAVE_SPL + if (volsize % 512 != 0) + return (EINVAL); + + /* + * On Linux, the maximum allowed block device size depends on the size + * of sector_t. + */ + if (fls64(volsize / 512 - 1) > NBBY * sizeof (sector_t)) + return (EOVERFLOW); + +#elif defined(_ILP32) if (volsize - 1 > SPEC_MAXOFFSET_T) return (EOVERFLOW); #endif + return (0); }