FreeBSD/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c
/*
 * This is FreeBSD version of ioctl, because Solaris' ioctl() updates
 * zc_nvlist_dst_size even if an error is returned, on FreeBSD if an
 * error is returned zc_nvlist_dst_size won't be updated.
 */
This is FreeBSD version of ioctl, because Solaris' ioctl() updates
zc_nvlist_dst_size even if an error is returned, on FreeBSD if an
error is returned zc_nvlist_dst_size won't be updated.
This is FreeBSD version of ioctl because Solaris ' ioctl () updates zc_nvlist_dst_size even if an error is returned on FreeBSD if an error is returned zc_nvlist_dst_size won ' t be updated .
int
zcmd_ioctl(int fd, int request, zfs_cmd_t *zc)
{
	size_t oldsize;
	int ret, cflag = ZFS_CMD_COMPAT_NONE;
	if (zfs_ioctl_version == ZFS_IOCVER_UNDEF)
		zfs_ioctl_version = get_zfs_ioctl_version();
	if (zfs_ioctl_version >= ZFS_IOCVER_DEADMAN) {
		switch (zfs_ioctl_version) {
		case ZFS_IOCVER_RESUME:
			cflag = ZFS_CMD_COMPAT_RESUME;
			break;
		case ZFS_IOCVER_EDBP:
			cflag = ZFS_CMD_COMPAT_EDBP;
			break;
		case ZFS_IOCVER_ZCMD:
			cflag = ZFS_CMD_COMPAT_ZCMD;
			break;
		case ZFS_IOCVER_LZC:
			cflag = ZFS_CMD_COMPAT_LZC;
			break;
		case ZFS_IOCVER_DEADMAN:
			cflag = ZFS_CMD_COMPAT_DEADMAN;
			break;
		}
	} else {
		cflag = ZFS_CMD_COMPAT_V28;
		if (zfs_spa_version < 0)
			zfs_spa_version = get_zfs_spa_version();
		if (zfs_spa_version == SPA_VERSION_15 ||
		    zfs_spa_version == SPA_VERSION_14 ||
		    zfs_spa_version == SPA_VERSION_13)
			cflag = ZFS_CMD_COMPAT_V15;
	}
	oldsize = zc->zc_nvlist_dst_size;
	ret = zcmd_ioctl_compat(fd, request, zc, cflag);
	if (ret == 0 && oldsize < zc->zc_nvlist_dst_size) {
		ret = -1;
		errno = ENOMEM;
	}
	return (ret);
}
int zcmd_ioctl ( int fd , int request , zfs_cmd_t * zc ) { size_t oldsize ; int ret , cflag = ZFS_CMD_COMPAT_NONE ; if ( zfs_ioctl_version == ZFS_IOCVER_UNDEF ) zfs_ioctl_version = get_zfs_ioctl_version ( ) ; if ( zfs_ioctl_version >= ZFS_IOCVER_DEADMAN ) { switch ( zfs_ioctl_version ) { case ZFS_IOCVER_RESUME : cflag = ZFS_CMD_COMPAT_RESUME ; break ; case ZFS_IOCVER_EDBP : cflag = ZFS_CMD_COMPAT_EDBP ; break ; case ZFS_IOCVER_ZCMD : cflag = ZFS_CMD_COMPAT_ZCMD ; break ; case ZFS_IOCVER_LZC : cflag = ZFS_CMD_COMPAT_LZC ; break ; case ZFS_IOCVER_DEADMAN : cflag = ZFS_CMD_COMPAT_DEADMAN ; break ; } } else { cflag = ZFS_CMD_COMPAT_V28 ; if ( zfs_spa_version < 0 ) zfs_spa_version = get_zfs_spa_version ( ) ; if ( zfs_spa_version == SPA_VERSION_15 || zfs_spa_version == SPA_VERSION_14 || zfs_spa_version == SPA_VERSION_13 ) cflag = ZFS_CMD_COMPAT_V15 ; } oldsize = zc -> zc_nvlist_dst_size ; ret = zcmd_ioctl_compat ( fd , request , zc , cflag ) ; if ( ret == 0 && oldsize < zc -> zc_nvlist_dst_size ) { ret = -1 ; errno = ENOMEM ; } return ( ret ) ; }
This is FreeBSD version of ioctl, because Solaris' ioctl() updates
 zc_nvlist_dst_size even if an error is returned, on FreeBSD if an
 error is returned zc_nvlist_dst_size won't be updated.
This is FreeBSD version of ioctl because Solaris ' ioctl () updates zc_nvlist_dst_size even if an error is returned on FreeBSD if an error is returned zc_nvlist_dst_size won ' t be updated .
/*
		 * If vfs.zfs.version.ioctl is not defined, assume we have v28
		 * compatible binaries and use vfs.zfs.version.spa to test for v15
		 */