From owner-svn-src-projects@FreeBSD.ORG Sun Mar 17 22:24:10 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 18D8936E; Sun, 17 Mar 2013 22:24:10 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F03DD6C8; Sun, 17 Mar 2013 22:24:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2HMO9oJ076664; Sun, 17 Mar 2013 22:24:09 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2HMO9To076660; Sun, 17 Mar 2013 22:24:09 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201303172224.r2HMO9To076660@svn.freebsd.org> From: Martin Matuska Date: Sun, 17 Mar 2013 22:24:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r248445 - in projects/libzfs_core/cddl/contrib/opensolaris/lib: libzfs/common libzfs_core/common X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Mar 2013 22:24:10 -0000 Author: mm Date: Sun Mar 17 22:24:08 2013 New Revision: 248445 URL: http://svnweb.freebsd.org/changeset/base/248445 Log: Fix working with zfs_ioctl_version in libzfs_compat.h and include mirror lzc_ioctl_version in libzfs_core Modified: projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.h projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core_compat.c Modified: projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.h ============================================================================== --- projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.h Sun Mar 17 20:44:09 2013 (r248444) +++ projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.h Sun Mar 17 22:24:08 2013 (r248445) @@ -32,8 +32,23 @@ extern "C" { #endif +static int zfs_ioctl_version = -1; static int zfs_kernel_version = 0; -static int zfs_ioctl_version = 0; + +/* + * Get zfs_ioctl_version + */ +static __inline int +get_zfs_ioctl_version(void) +{ + size_t ver_size; + int ver = 0; + + ver_size = sizeof(ver); + sysctlbyname("vfs.zfs.version.ioctl", &ver, &ver_size, NULL, 0); + + return (ver); +} /* * This is FreeBSD version of ioctl, because Solaris' ioctl() updates @@ -43,14 +58,11 @@ static int zfs_ioctl_version = 0; static __inline int zcmd_ioctl(int fd, int request, zfs_cmd_t *zc) { - size_t oldsize, zfs_kernel_version_size, zfs_ioctl_version_size; + size_t oldsize, zfs_kernel_version_size; int version, ret, cflag = ZFS_CMD_COMPAT_NONE; - zfs_ioctl_version_size = sizeof(zfs_ioctl_version); - if (zfs_ioctl_version == 0) { - sysctlbyname("vfs.zfs.version.ioctl", &zfs_ioctl_version, - &zfs_ioctl_version_size, NULL, 0); - } + if (zfs_ioctl_version == -1) + zfs_ioctl_version = get_zfs_ioctl_version(); if (zfs_ioctl_version == ZFS_IOCVER_DEADMAN) cflag = ZFS_CMD_COMPAT_DEADMAN; Modified: projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c ============================================================================== --- projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c Sun Mar 17 20:44:09 2013 (r248444) +++ projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c Sun Mar 17 22:24:08 2013 (r248445) @@ -84,10 +84,11 @@ #include #include #include -#include +#include "libzfs_core_compat.h" +#include "libzfs_compat.h" #ifdef __FreeBSD__ -extern int zfs_ioctl_version; +int lzc_ioctl_version = -1; #endif static int g_fd; @@ -107,6 +108,7 @@ libzfs_core_init(void) } g_refcount++; (void) pthread_mutex_unlock(&g_lock); + return (0); } @@ -138,7 +140,10 @@ lzc_ioctl(zfs_ioc_t ioc, const char *nam (void) strlcpy(zc.zc_name, name, sizeof (zc.zc_name)); #ifdef __FreeBSD__ - if (zfs_ioctl_version < ZFS_IOCVER_LZC) { + if (lzc_ioctl_version == -1) + lzc_ioctl_version = get_zfs_ioctl_version(); + + if (lzc_ioctl_version < ZFS_IOCVER_LZC) { oldsource = source; error = lzc_compat_pre(&zc, &ioc, &source); if (error) @@ -185,7 +190,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *nam } #ifdef __FreeBSD__ - if (zfs_ioctl_version < ZFS_IOCVER_LZC) + if (lzc_ioctl_version < ZFS_IOCVER_LZC) lzc_compat_post(&zc, ioc); #endif if (zc.zc_nvlist_dst_filled) { @@ -195,12 +200,12 @@ lzc_ioctl(zfs_ioc_t ioc, const char *nam *resultp = NULL; } #ifdef __FreeBSD__ - if (zfs_ioctl_version < ZFS_IOCVER_LZC) + if (lzc_ioctl_version < ZFS_IOCVER_LZC) lzc_compat_outnvl(&zc, ioc, resultp); #endif out: #ifdef __FreeBSD__ - if (zfs_ioctl_version < ZFS_IOCVER_LZC) { + if (lzc_ioctl_version < ZFS_IOCVER_LZC) { if (source != oldsource) nvlist_free(source); source = oldsource; Modified: projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h ============================================================================== --- projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h Sun Mar 17 20:44:09 2013 (r248444) +++ projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h Sun Mar 17 22:24:08 2013 (r248445) @@ -31,9 +31,6 @@ #include #include #include -#ifdef __FreeBSD__ -#include "libzfs_core_compat.h" -#endif #ifdef __cplusplus extern "C" { Modified: projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core_compat.c ============================================================================== --- projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core_compat.c Sun Mar 17 20:44:09 2013 (r248444) +++ projects/libzfs_core/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core_compat.c Sun Mar 17 22:24:08 2013 (r248445) @@ -24,9 +24,10 @@ */ #include -#include +#include +#include "libzfs_core_compat.h" -extern int zfs_ioctl_version; +extern int lzc_ioctl_version; int lzc_compat_pre(zfs_cmd_t *zc, zfs_ioc_t *ioc, nvlist_t **source) @@ -39,7 +40,7 @@ lzc_compat_pre(zfs_cmd_t *zc, zfs_ioc_t int error = 0; int pos; - if (zfs_ioctl_version >= ZFS_IOCVER_LZC) + if (lzc_ioctl_version >= ZFS_IOCVER_LZC) return (0); vecnum = *ioc; @@ -98,7 +99,7 @@ lzc_compat_pre(zfs_cmd_t *zc, zfs_ioc_t void lzc_compat_post(zfs_cmd_t *zc, const zfs_ioc_t ioc) { - if (zfs_ioctl_version >= ZFS_IOCVER_LZC) + if (lzc_ioctl_version >= ZFS_IOCVER_LZC) return; switch (ioc) { @@ -117,7 +118,7 @@ lzc_compat_outnvl(zfs_cmd_t *zc, const z { nvlist_t *nvl; - if (zfs_ioctl_version >= ZFS_IOCVER_LZC) + if (lzc_ioctl_version >= ZFS_IOCVER_LZC) return (0); switch (ioc) {